Hello, I am a beginner programmer and was following a flappy bird tutorial to get familiar with the language. I am trying to get flappy bird to rotate up and down according to his position. However, I keep getting an error ')' expected that I am having difficulty fixing. Here is my code:
It keeps telling me that it is expecting a end parenthesis after if (dy is between -10 and 10), can anyone help me out?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | public class FlappyBird extends Actor { double dy = 0 ; double g = 1.3 ; double BOOST_SPEED = - 15 ; public void act() { setLocation( getX(), ( int )(getY() + dy) ); //If user pressed UP arrow, launch flappy bird upward if (Greenfoot.isKeyDown( "up" ) == true ) { dy = BOOST_SPEED; } if (dy is between - 10 and 10 ) { //set angle to 30 setRotation( 30 ); } //If flappybird drops out of the world, then game over if (getY() > getWorld().getHeight()) { GameOver gameOver = new GameOver(); getWorld().addObject(gameOver, getWorld().getWidth()/ 2 , getWorld().getHeight()/ 2 ); Greenfoot.stop(); } dy = dy + g; } } |