@09blackn
What I did it's not the best thing, but it was:
I call the method setPosition of the Actors if: the booleans are like: trying to move up and wallTop == false, trying to move down and wallBottom == false, trying to move left and wallLeft == false, trying to move right and wallRight== false.
To set this booleans, i used the method getOneObjectAtOffset(actor.getX() + dx, actor.getY() + dy, Wall.class), where dx and dy depend on the position of the wall you want to compare.
That's the idea of how I did when I made this game! :)
hey @gusbus123, thanks for your comments xD
For the blood, i created a class named "ZombieBlood" that just puts an image in the position that the zombie died. I create 150 objects of blood every level. When i don't have 150 bloods yet, i create; when i do have, i only call setPosition of the first ones. At the moment the bullet hits the zombie, both are removed.
When i made this game, i had a version before "Greenfoot 2.1.0 (8. June 2011)", so the turn methods in Actor weren't built yet. (http://www.greenfoot.org/version_history). That's why i didn't use the turnTowards().
This were a one month project of Computer Science 101. Also, i didn't know anything about programming before. Sorry if my English is not great, and I hope you understand I was "a pretty bad programmer", because I was just learning at that time :D
Thank you all for the feedback!
[]'s
Actually I should write: beta = (int) (0.5 + (Math.toDegr.... )
Because it would decrease the chance of bad rounding.
But anyway, it's always good to know other ways of doing the same thing, thanks, @newacct !
In this game:
-The zombie class has access to the position x and y of the player.
-So I did this in the act method of Zombie class:
if(manIsLive)
move();
In the move() method, we have:
deltaX=XPlayer-getX();
deltaY=YPlayer-getY();
if(deltaY<0)
moveY=-1;
else
moveY=1;
if(deltaX==0)
moveX=0;
else
{
beta = (int) (Math.toDegrees(Math.atan(deltaY/deltaX)));
if(deltaX<0)
{
moveX=-1;
setRotation(beta+180);
}
else
{
moveX=1;
setRotation(beta);
}
}
setLocation(getX()+moveX , getY()+moveY);
Enjoy and good luck, thanks for playing! xD
Wow, you are better than me!! hahahaha
I'm going to change the Zombie Rate in the survival, because its not so dynamic yet.
I'm glad you have liked it, thanks!! xD
I found a bug in the second level: if you stay in the initial position of the button "reset", you cannot be fired... And it's possible keep playing by pressing "run" and moving to escape the bullet.
Whatever, it's a nice game!
2012/8/15
Guns vs Zombies
2012/8/9
Guns vs Zombies
2011/12/4
Guns vs Zombies
2011/11/6
Guns vs Zombies
2011/11/5
Guns vs Zombies
2011/7/9
Guns vs Zombies
2011/7/5
GettingBigger
2011/7/5
JASSG
2011/7/4
Guns vs Zombies