Added support for draw debug entity sizes

Added support for draw debug entity sizes
Fixed bug with debug shape type in draw walkable tiles
Assigned Player entities to size 2
This commit is contained in:
Collin Smith 2019-05-03 17:50:10 -07:00
parent 1b7b7ed350
commit e672466200
3 changed files with 52 additions and 0 deletions

View File

@ -220,6 +220,12 @@ public abstract class Entity implements Animation.AnimationListener {
Arrays.fill(DEFAULT_ALPHA, 1.0f);
}
private static final int[][][] SIZES = {
{ {0,0} },
{ {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1} },
{ {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1}, {-1,-1}, {1,1}, {1,-1}, {-1,1}, {-2,0}, {2,0}, {0,-2}, {0,2} },
};
int uuid = 0;
String classname;
@ -257,6 +263,8 @@ public abstract class Entity implements Animation.AnimationListener {
Overlay.Entry overlayEntry;
Animation overlay;
int size = 1;
private static final Vector2 tmpVec2 = new Vector2();
public static Entity create(Map map, Map.Zone zone, DS1 ds1, DS1.Object object) {
@ -480,10 +488,22 @@ public abstract class Entity implements Animation.AnimationListener {
public void drawDebug(PaletteIndexedBatch batch, ShapeRenderer shapes) {
drawDebugSize(shapes);
drawDebugStatus(batch, shapes);
if (DEBUG_TARGET) drawDebugTarget(shapes);
}
public void drawDebugSize(ShapeRenderer shapes) {
shapes.set(ShapeRenderer.ShapeType.Filled);
shapes.setColor(Color.GRAY);
int[][] SIZE = SIZES[size - 1];
for (int[] subtile : SIZE) {
EngineUtils.worldToScreenCoords(position.x + subtile[0], position.y + subtile[1], tmpVec2);
DebugUtils.drawDiamond(shapes, tmpVec2.x, tmpVec2.y, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT);
}
shapes.set(ShapeRenderer.ShapeType.Line);
}
public void drawDebugStatus(PaletteIndexedBatch batch, ShapeRenderer shapes) {
float x = screen.x;
float y = screen.y;
@ -767,6 +787,25 @@ public abstract class Entity implements Animation.AnimationListener {
boolean changed = sequence(newMode, getNeutralMode());
if (!changed) return false;
/*
updateCOF(); // FIXME: required because we need updated COF to bind to trigger -- should really be done on next frame
for (COF.Keyframe keyframe : COF.Keyframe.values()) {
int frame = animation.getCOF().getKeyframeFrame(keyframe);
System.out.println("keyframe[" + keyframe + "]=" + frame);
}
int frame = animation.getCOF().getKeyframeFrame(COF.Keyframe.ATTACK);
if (frame >= 0) {
animation.addAnimationListener(frame, new Animation.AnimationListener() {
@Override
public void onTrigger(Animation animation, int frame) {
System.out.println("onTrigger " + frame + " " + COF.Keyframe.ATTACK);
animation.removeAnimationListener(frame, this);
}
});
}
*/
System.out.println("cast " + type.MODE[tm] + "->" + type.MODE[mode]);
Riiablo.audio.play(skill.stsound, true);
@ -786,4 +825,14 @@ public abstract class Entity implements Animation.AnimationListener {
return true;
}
public void setSize(int size) {
if (this.size != size) {
this.size = size;
}
}
public int getSize() {
return size;
}
}

View File

@ -99,6 +99,7 @@ public class Player extends Entity implements CharData.EquippedListener {
setRunSpeed(9);
setRunning(true);
angle(-MathUtils.PI / 2);
setSize(2);
}
private void loadItems(Array<Item> items) {

View File

@ -984,7 +984,9 @@ public class MapRenderer {
int offY = py + Tile.SUBTILE_OFFSET[t][1];
shapes.setColor(Color.CORAL);
shapes.set(ShapeRenderer.ShapeType.Line);
DebugUtils.drawDiamond2(shapes, offX, offY, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT);
shapes.set(ShapeRenderer.ShapeType.Filled);
offY += Tile.SUBTILE_HEIGHT50;