sábado, 14 de enero de 2017

Our first game: a car race!

Lets get started!

1 Start by creating the racetrack backdrop.

Click on the stage-background tap and draw the racetrack.



2 Draw the racing car

Now create your racing car: you can draw an easy one using just some coloured rectangles.




3 Set the starting position

Set the position of the car to the starting point at the beginning of the program, therefore each time the program stars, the car will be ready to run the race!
Set x and y coordinates to the desired location.



4 Move with the arrow keys

Lets make our car move with the arrow keys on the keyboard:

Press the up/down arrow key and the car will move some steps forward/backward.

Or press the right/left arrow key and the car will turn some degrees to the right/left.


5. Watch out! 

The car should not leave the race-track: each time the car touch the green area, it will be moved to the starting point.



6. Using a Variable to Keep Score

Now lets count the number of complete trips around the race track:

The next step is to create a variable which will keep score of the number of laps.

Go to the Variables blocks. Click on the Make a Variable button to display the New Variable dialog box.


Type in the name of the variable (Laps Score) and click the OK button.
Your variable will now be displayed on the stage, and some blocks will appear that you can use with it.

Each time the car reach the finish line (orange color), the Laps Score variable will be increased by 1 and the car will go to its starting point.

Don’t forget to initialize the variable to 0 at the beginning of the program, so it will be ready to start counting from cero next time you play your game.



7. Time the game

What about adding a new variable to time the game
This timer variable will start at a given number of seconds (try 60) and then reduce by 1 every second. 

When the number gets to zero, time’s up!😀😀

Game is over

6. Some ideas

  • Add a second car, so you can play with a friend
  • Decrease some points the laps score whenever the green area is touched
  • Add sound!

7. Give it a try!