v0.4.2: levels now precompute their length for better performance

This commit is contained in:
Evan Debenham 2016-08-24 14:48:29 -04:00 committed by Evan Debenham
parent 2bd1962b34
commit 7b16e75553

View File

@ -105,6 +105,7 @@ public abstract class Level implements Bundlable {
protected int width; protected int width;
protected int height; protected int height;
protected int length;
protected static final float TIME_TO_RESPAWN = 50; protected static final float TIME_TO_RESPAWN = 50;
@ -278,6 +279,7 @@ public abstract class Level implements Bundlable {
protected void setupSize(){ protected void setupSize(){
width = height = 32; width = height = 32;
length = width * height;
} }
public void reset() { public void reset() {
@ -300,6 +302,7 @@ public abstract class Level implements Bundlable {
height = bundle.getInt("height"); height = bundle.getInt("height");
} else } else
width = height = 32; //default sizes width = height = 32; //default sizes
length = width * height;
PathFinder.setMapSize(width(), height()); PathFinder.setMapSize(width(), height());
mobs = new HashSet<>(); mobs = new HashSet<>();
@ -410,7 +413,7 @@ public abstract class Level implements Bundlable {
} }
public int length() { public int length() {
return width() * height(); return length;
} }
public String tilesTex() { public String tilesTex() {