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

2016/6/21

Turning

MrPancakes MrPancakes

2016/6/21

#
Im making a asteroid game, but im stuck with the shooting. If the ball is shot, it should turn around and go back to the other side. But the ball is glitched in the wall. Can you please help me? Here is the code of the ball being shot.
 public void act() 
    {
        setLocation(getX()+speed, getY());
        if (isTouching(BBar.class));
            turn(180);
        
    }
danpost danpost

2016/6/21

#
Try replacing line 5 with:
speed = -speed;
You need to login to post a reply.