This site requires JavaScript, please enable it in your browser!
Greenfoot back
iCookieMad
iCookieMad wrote ...

2017/9/25

I'm new to Java and Greenfoot. Bugs in code. Please help!

iCookieMad iCookieMad

2017/9/25

#
Hi. I can't seem to figure out how to fix my code in the CrabsWorld tutorial scenario. I've attached an image below. Thanks! [Disallowed URL]
iCookieMad iCookieMad

2017/9/25

#
The image didn't work. I'll just copy and paste the code lol. public void moveAround() { move(4); if (Greenfoot.getRandomNumber(100) < 10) { turn(Greenfoot.getRandomNumber(90) -45); } if (getX() <= 5 getX() >=getWorld().getWidth()-5) { turn(180); } if (getY() <=5 getY() >= getwWorld().getHeight() -5) { turn(180); } }
Super_Hippo Super_Hippo

2017/9/26

#
1. To post an image, you have to upload it and then use the link directly to this image and put it into the img-tag. 2. When posting code, no image is necessary, just use the code-tag. 3. Errors in your code: - You check if x or y is less than OR greater than something. The OR (||) is missing in both. - There is an additional w in the last 'getWorld'.
You need to login to post a reply.