Thursday, May 12, 2011

5/12/11 - Random Success

Today I came to class, but Safath was not here because he was sick.  I decided to look at his blog and see what he was able to do yesterday because I was not there.  He posted about not having success with the movement class despite various efforts and codes.  But, some person that we do not know commented on his blog post giving us exactly what we needed!!  This was so exciting because the link the person gave had so many methods that will all be helpful in the future.  I decided to go back to the source codes of the games from tuesday, and see if this code was present, and there it was!  The code for the movement is this simple void class:
public void act()
{
   
if (Greenfoot.isKeyDown("left")) {
        turn(-7);
    }
   
if (Greenfoot.isKeyDown("right")) {
        turn(7);
    }
    move();
   
if (canSee(Worm.class)) {
        eat(Worm.
class);
    }
}

I decided to implement this with Safath because his code for the wombat was more advanced and sophisticated...Stay Tuned!

No comments:

Post a Comment