Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the most egregious bugs so you can actually walk around at a somewhat decent framerate #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="textures"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/out/
/TerraFrame.iml
/worlds/
/bin/
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TerraClone</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
6 changes: 0 additions & 6 deletions src/DoubleContainer.java

This file was deleted.

1 change: 0 additions & 1 deletion src/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public Entity(double x, double y, double vx, double vy, short id, short num, sho
this.y = y;
this.vx = vx;
this.vy = vy;
this.name = name;
this.id = id;
this.num = num;
this.dur = dur;
Expand Down
23 changes: 10 additions & 13 deletions src/Inventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ public void update(int i) {
width = TerrariaClone.getItemImgs().get(ids[i]).getWidth();
height = TerrariaClone.getItemImgs().get(ids[i]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ids[i]),
px*46+14+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*46+14+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2), px*46+38-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*46+38-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2),
px*46+14+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*46+14+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2), px*46+38-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*46+38-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2),
0, 0, width, height,
null);

Expand Down Expand Up @@ -1240,7 +1240,8 @@ public int removeLocationIC(ItemCollection ic, int i, short quantity) {
return quantity;
}

public void updateIC(ItemCollection ic, int i) {
@SuppressWarnings("unlikely-arg-type")
public void updateIC(ItemCollection ic, int i) {
if (ic.type.equals("cic")) {
py = (int)(i/2);
px = i-(py*2);
Expand All @@ -1258,7 +1259,7 @@ public void updateIC(ItemCollection ic, int i) {
width = TerrariaClone.getItemImgs().get(ic.ids[i]).getWidth();
height = TerrariaClone.getItemImgs().get(ic.ids[i]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ic.ids[i]),
px*40+8+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*40+8+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2), px*40+32-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*40+32-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2),
px*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2), px*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2),
0, 0, width, height,
null);
if (ic.nums[i] > 1) {
Expand Down Expand Up @@ -1324,7 +1325,7 @@ public void updateIC(ItemCollection ic, int i) {
width = TerrariaClone.getItemImgs().get(ic.ids[4]).getWidth();
height = TerrariaClone.getItemImgs().get(ic.ids[4]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ic.ids[4]),
3*40+8+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), 20+8+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2), 3*40+32-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), 20+32-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2),
3*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), 20+8+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2), 3*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), 20+32-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2),
0, 0, width, height,
null);

Expand Down Expand Up @@ -1352,7 +1353,7 @@ public void updateIC(ItemCollection ic, int i) {
width = TerrariaClone.getItemImgs().get(ic.ids[i]).getWidth();
height = TerrariaClone.getItemImgs().get(ic.ids[i]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ic.ids[i]),
px*46+8+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*46+8+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2), px*46+32-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*46+32-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2),
px*46+8+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*46+8+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2), px*46+32-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*46+32-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2),
0, 0, width, height,
null);

Expand Down Expand Up @@ -1380,7 +1381,7 @@ public void updateIC(ItemCollection ic, int i) {
width = TerrariaClone.getItemImgs().get(ic.ids[i]).getWidth();
height = TerrariaClone.getItemImgs().get(ic.ids[i]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ic.ids[i]),
px*40+8+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*40+8+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2), px*40+32-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*40+32-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2),
px*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2), px*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2),
0, 0, width, height,
null);
if (ic.nums[i] > 1) {
Expand Down Expand Up @@ -1446,7 +1447,7 @@ public void updateIC(ItemCollection ic, int i) {
width = TerrariaClone.getItemImgs().get(ic.ids[9]).getWidth();
height = TerrariaClone.getItemImgs().get(ic.ids[9]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ic.ids[9]),
4*40+8+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), 1*40+8+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2), 4*40+32-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), 1*40+32-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2),
4*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), 1*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2), 4*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), 1*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2),
0, 0, width, height,
null);

Expand Down Expand Up @@ -1478,7 +1479,7 @@ public void updateIC(ItemCollection ic, int i) {
width = TerrariaClone.getItemImgs().get(ic.ids[i]).getWidth();
height = TerrariaClone.getItemImgs().get(ic.ids[i]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ic.ids[i]),
px*46+8+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*46+8+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2), px*46+32-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2), py*46+32-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2),
px*46+8+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*46+8+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2), px*46+32-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2), py*46+32-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2),
0, 0, width, height,
null);

Expand Down Expand Up @@ -1539,7 +1540,7 @@ public void updateIC(ItemCollection ic, int i) {
width = TerrariaClone.getItemImgs().get(ic.ids[i]).getWidth();
height = TerrariaClone.getItemImgs().get(ic.ids[i]).getHeight();
g2.drawImage(TerrariaClone.getItemImgs().get(ic.ids[i]),
(int)(fpx*40+8+((int)(24-(double)12/this.max(width, height, 12)*width*2)/2)), (int)(fpy*40+8+((int)(24-(double)12/this.max(width, height, 12)*height*2)/2)), (int)(fpx*40+32-((int)(24-(double)12/this.max(width, height, 12)*width*2)/2)), (int)(fpy*40+32-((int)(24-(double)12/this.max(width, height, 12)*height*2)/2)),
(int)(fpx*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2)), (int)(fpy*40+8+((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2)), (int)(fpx*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*width*2)/2)), (int)(fpy*40+32-((int)(24-(double)12/Inventory.max(width, height, 12)*height*2)/2)),
0, 0, width, height,
null);

Expand Down Expand Up @@ -1674,10 +1675,6 @@ public static int max(int a, int b, int c) {
return Math.max(Math.max(a, b), c);
}

public static void print(String text) {
System.out.println(text);
}

public static void print(int text) {
System.out.println(text);
}
Expand Down
13 changes: 8 additions & 5 deletions src/LightConverter.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.Scanner;

import javax.imageio.ImageIO;

public class LightConverter {
Expand All @@ -22,7 +23,9 @@ public class LightConverter {
public static void main(String[] args) {
for (int i=0; i<17; i++) {
System.out.print("Generate new textures [" + i + "] for: ");
String name = (new Scanner(System.in)).nextLine();
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
scanner.close();
BufferedImage light = loadImage("light/" + i + ".png");
for (int j=1; j<9; j++) {
BufferedImage texture = loadImage("blocks/" + name + "/texture" + j + ".png");
Expand Down
6 changes: 0 additions & 6 deletions src/Player.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import java.awt.image.*;
import java.io.*;
import java.lang.Math;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.*;

public class Player implements Serializable {
transient BufferedImage image;
Expand Down
19 changes: 13 additions & 6 deletions src/RandConverter.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

import javax.imageio.ImageIO;

public class RandConverter {
Expand All @@ -21,10 +24,12 @@ public class RandConverter {

public static void main(String[] args) {
System.out.print("[D]uplicate, [R]andomize, or [O]utline? ");
char option = new Scanner(System.in).next().charAt(0);

Scanner scanner = new Scanner(System.in);
char option = scanner.next().charAt(0);
while (true) {
System.out.print("Generate new textures for: ");
String name = (new Scanner(System.in)).nextLine();
String name = scanner.nextLine();
if (name.equals("exit")) {
break;
}
Expand Down Expand Up @@ -92,6 +97,8 @@ public static void main(String[] args) {
}
}
}

scanner.close();
}

private static BufferedImage loadImage(String path) {
Expand Down
Loading