Skip to content

Commit

Permalink
spears now go in the last moved direction
Browse files Browse the repository at this point in the history
  • Loading branch information
trystan committed Mar 15, 2012
1 parent 4bc7642 commit 2573177
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 78 deletions.
4 changes: 2 additions & 2 deletions src/iryrwarosh/Creature.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ public void moveBy(World world, int x, int y) {
Creature other = world.creature(position.x+x, position.y+y);

if (other == null) {
lastMovedDirection.x = x;
lastMovedDirection.y = y;
if (canEnter(world.tile(position.x+x, position.y+y))){
position.x += x;
position.y += y;
lastMovedDirection.x = x;
lastMovedDirection.y = y;
hasMovedThisTurn = true;
MessageBus.publish(new Moved(world, this));
} else {
Expand Down
22 changes: 19 additions & 3 deletions src/iryrwarosh/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import iryrwarosh.screens.JumpScreen;
import iryrwarosh.screens.Screen;
import iryrwarosh.screens.SneakScreen;
import iryrwarosh.screens.ThrowItemScreen;
import iryrwarosh.screens.WorldMapScreen;

import java.awt.Color;
Expand Down Expand Up @@ -172,8 +171,25 @@ public Screen use(Screen screen, World world, Creature owner){
if (owner.rupees() + owner.hearts() <= 2) {
MessageBus.publish(new Note(world, owner, "You need more than 2 rupees or hearts to throw a spear."));
return screen;
} else
return new ThrowItemScreen(screen, world, owner, this);
}

Point dir = owner.lastMovedDirection();
if (dir.x == 0 && dir.y == 0)
dir = new Point(0, 1);

char glyph = 9;
if (dir.x == -1 && dir.y == -1 || dir.x == 1 && dir.y == 1)
glyph = '\\';
else if (dir.x == 1 && dir.y == -1 || dir.x == -1 && dir.y == 1)
glyph = '/';
else if (dir.x == 0 && (dir.y == -1 || dir.y == 1))
glyph = 179;
else if ((dir.x == -1 || dir.x == 1) && dir.y == 0)
glyph = 196;

world.add(new Projectile("arrow", owner, glyph, AsciiPanel.white, 1, owner.position.copy(), owner.lastMovedDirection()));
owner.loseRupees(world, 1);
return screen;
}
};
item.addTrait(Trait.REACH_ATTACK);
Expand Down
73 changes: 0 additions & 73 deletions src/iryrwarosh/screens/ThrowItemScreen.java

This file was deleted.

0 comments on commit 2573177

Please sign in to comment.