First, we are going to set the fish's starting conditions. We will be using two variables: Score and Speed.
Steps
Create new Score and Speed variables.
Set the speed at the beginning of the game to 0.
Set the score at the beginning of the game (What should the score at the beggining of the game be set to?).
Start the fish at the center of the stage.
The fish will naturally fall towards the bottom of the screen (due to gravity!) The fish will fall until he reaches the floor.
Steps
First, have the fish move down the screen by the amount stored in Speed .
Change Speed by -0.3 so that the fish accelerates (falls faster as time goes on).
The above two actions should happen until the fish touches either a pipe or the floor. Hint: What color are both the pipe and the floor?
When the fish hits a pipe or the floor, play a sound to show that the game has ended. You can choose which sound to play!
Now, we will program the fish to jump whenever the player presses the space bar.
Steps
The sprite should only jump when the space bar is pressed. Hint: Which Hat block/Event block should we use?
Make the fish's speed go up by 6.
Now, we'll move on to the pipes. Even though it seems like the fish is moving to the right, the pipes will actually start on the right of the screen, then move to the left of the screen.
Steps
Set the size of the pipes to 200%. This makes the pipes (and the opening between the pipes) bigger, so the game is a little easier to play!
Start the pipe at a random position near the right of the screen. You can do this by setting the x position to 240 and the y position to a random number between -20 and 60. Hint: What special operator do you need for choosing random numbers? Fill in the blank in the picture below.
Make the pipes move 2 steps towards the left of the stage.
If the pipes get to an x position of -230, that means the fish has passed it! When this happens, the pipe should go back to a random position on the right of the screen , and the score should increase by 1. Hint: Use a conditional statement!
Steps 3-4 should only happen until the pipe is touching the fish - if the pipe and fish are touching, the player has lost the game! Hint: How can you use the "repeat until" block to do this?
Once you have a working Flappy Fish, choose one or more additional features to add!
Create a "game over" backdrop that appears when the fish runs into a pipe or the ground and displays the player's score
Track your best runs by creating a variable for "high score"!
Make your own background! You can do this by changing the backdrop. If you want to make the fish smaller, you can do that with a block in the Looks category
Change the sprites for the player and the pipes
When you're finished, be sure to save and share your project, and then add it to the studio: