im trying to make a code where the player can eat humans, and once it does, it gets a tail of those humans (just like in snake where if the player eats an apple, the snake gets a longer tail). i dont know how to determine the position of the tail so that it follows the player. urgent!! i need help please!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public class PlayerZombie extends BaseClass { private int humanCounter = 1 ; public void eatHuman() { if (canSee(Human. class )) { removeObject(Human. class ); Level level = (Level) getWorld(); level.addScore(); humanCounter++; getWorld().addObject( new Tail(humanCounter),getX(),getY()); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public class Tail extends Actor { public int count = 0 ; public int life; public Tail( int l) { setImage( "playerfront.png" ); life = 1 ; } public void act() { if (count == life) { getWorld().removeObject( this ); } count++; } } |