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

2015/8/11

Help please(I cant compile. something is wrong)

spazonred1998 spazonred1998

2015/8/11

#
if(isAtEdge()) { //Turn towards the center of the world turnTowards(worldCenterX, worldCenterY); //Move to the center of the world. Must calculate the distance between the fly's current //location and the center of the world. Thank Pythagoras for the distance calculation! if (distanceToCenter==0) if (Math.sqrt(Math.pow(getX()-worldCenterX,2) + (Math.pow(getY()-worldCenterY,2)); move(distanceToCenter*2); }
Francis1004 Francis1004

2015/8/11

#
try if(____()==isAtEdge) put the actor on the blank.
danpost danpost

2015/8/11

#
The round brackets in the sqrt/pow line do not match properly. Besides that, the semicolon at the end makes the line pointless. Also, I would think that the calculated distance should be set as the value of the 'distanceToCenter' variable before moving or performing any checks on its value.
davmac davmac

2015/8/11

#
Help please(I cant compile. something is wrong)
Please always supply the error message if you have a compilation problem, and make clear which line the error is one. Please post code properly:
You need to login to post a reply.