Skip to content

Commit

Permalink
Fix stupid recursion bug in one SquidPanel method
Browse files Browse the repository at this point in the history
SquidPanel.animateActor(int, int, boolean, char, Color) was calling
itself infinitely without intending to. This previously caused a
StackOverflowError, and is now fixed to have correct behavior.
ThinWallDemo showed this bug right away, and it has also been updated,
but just to try a different font and correct an offset issue.
  • Loading branch information
tommyettinger committed May 21, 2017
1 parent 9f6f8e9 commit 1d85a81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Expand Up @@ -761,7 +761,13 @@ public AnimatedEntity animateActor(int x, int y, char c, Color color)
*/
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, char c, Color color)
{
return animateActor(x, y, doubleWidth, c, color);
Actor a = textFactory.makeActor(c, color);
a.setName(String.valueOf(c));
a.setPosition(adjustX(x, doubleWidth), adjustY(y));
AnimatedEntity ae = new AnimatedEntity(a, x, y, doubleWidth);
animatedEntities.add(ae);
return ae;

/*
Actor a = textFactory.makeActor("" + c, color);
a.setName("" + c);
Expand Down
6 changes: 3 additions & 3 deletions squidlib/src/test/java/squidpony/gdx/tests/ThinWallDemo.java
Expand Up @@ -143,7 +143,7 @@ public void create() {
// about 1/2f for zoom 3. If you have more zooms as options for some reason, this formula should hold for many
// cases but probably not all. We also add a swap here to replace '#', which is used for boulders and pillars,
// with a small Unicode box shape that looks better when it lies on the corner between walkable cells.
textFactory = DefaultResources.getStretchableFont().setSmoothingMultiplier(2f / (INTERNAL_ZOOM + 1f))
textFactory = DefaultResources.getStretchableSlabFont().setSmoothingMultiplier(2f / (INTERNAL_ZOOM + 1f))
.width(cellWidth).height(cellHeight).initBySize().addSwap('#', '▫'); //.setDirectionGlyph('ˆ')
// Creates a layered series of text grids in a SquidLayers object, using the previously set-up textFactory and
// SquidColorCenters. We use the bitwise right shift operator instead of division by 2 because I want more
Expand All @@ -160,7 +160,7 @@ public void create() {
// a bit of a hack to increase the text height slightly without changing the size of the cells they're in.
// this causes a tiny bit of overlap between cells, which gets rid of an annoying gap between vertical lines.
// if you use '#' for walls instead of box drawing chars, you don't need this.
messages.setTextSize(cellWidth + INTERNAL_ZOOM, cellHeight + INTERNAL_ZOOM);
messages.setTextSize(cellWidth + INTERNAL_ZOOM * 2, cellHeight + INTERNAL_ZOOM * 3);
display.setTextSize(cellWidth + INTERNAL_ZOOM, cellHeight + INTERNAL_ZOOM);
//The subCell SquidPanel uses a smaller size here; the numbers 8 and 16 should change if cellWidth or cellHeight
//change, and the INTERNAL_ZOOM multiplier keeps things sharp, the same as it does all over here.
Expand Down Expand Up @@ -533,7 +533,7 @@ private void postMove() {
}
tmp = path.first();
if (tmp == player.pos) {
display.tint(player.entity.gridX, player.entity.gridY-1, SColor.PURE_CRIMSON, 0, 0.415f);
display.tint(player.entity.gridX, player.entity.gridY, SColor.PURE_CRIMSON, 0, 0.415f);
health--;
//player.setText("" + health);
mon.change(1);
Expand Down

0 comments on commit 1d85a81

Please sign in to comment.