This site requires JavaScript, please enable it in your browser!
Greenfoot_back
Wagner

wagnerf

IME - USP, Brazil

wagnerf's scenarios

play Guns vs Zombies

wagnerf's collections

This user has no collections

Recent Comments | Show All

Wagner_thumb

2011/12/4

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 !
Wagner_thumb

2011/11/6

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