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

2017/6/24

Help

jeff jeff

2017/6/24

#
While trying to write a new program for astronauts, spaceships and rocks to fly around in my world, I cannot get my spaceship to turn. Here is the code I am using /** * Act - do whatever the astronaut wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void move() { move(10); if (isAtEdge()) {turn (45); } if (Greenfoot.getRandomNumber(100) < 10) {turn(Greenfoot.getRandomNumber(90)-45); } if (Greenfoot.isKeyDown("space") ) {turn(-45); } if (Greenfoot.isKeyDown("up") ) {turn(45); } } }
Super_Hippo Super_Hippo

2017/6/24

#
Do you mean it doesn't turn at all? Does it move? Is the method called from the act method? You probably should use lower values than 45, because it would turn far too quickly at normal speed.
jeff jeff

2017/6/24

#
It moves but it doesn't turn at all.
Super_Hippo Super_Hippo

2017/6/24

#
Show the act method of the class.
You need to login to post a reply.