Tuesday, September 26, 2017

Driving Game Report Barrera and Poletilo


Difficulty: Low



We had to create a report for the first deadline from the third Term of a driving game which we did in scratch. In this blog we are going to inform you how we did this work and how to create or complete certain scratch problems. When we started the project we had a list of the blocks we could use. If we weren’t using them it meant we were doing something wrong.
The scratch game consisted on making a car race game.
Ours is a multyplayer game, and one player uses the car 1 and the other the car 2. You have 2 levels. To switch level you just have to click the space key. 
Controls: 
Player for car 1:
 - up arrow key to increase the speed
 - down arrow key to decrease the speed
 - left arrow key to turn left
 - right arrow key to turn right 
Player car 2:
 - w key to increase speed
 - s key to decrease speed
 - a key to turn left
 - d key to turn right 
The background is a race track, with green grass all around it. When you touch the grass, the car will slow down. The goal is to make as much laps around the track as you can. For the laps to count, you must go faster than speed 2. But if you touch the grass for more than 3 seconds, one lap will be subtracted. We made a speedometer to show how fast you are going. You have 60 seconds until you have to load gas. The game ends once one cars timer reaches 0. The car with more laps will win. If both cars made 0 laps, both will win. 

usefull blocks.PNG

When we started the activity the car just turned right if you pressed the right arrow key, but it didn’t go anywhere.

first.PNG

This is how we made the car move and turn around:

We had to add the option so that the car moves forward and turnes left. To start the script we used the “when green flag pressedevent, and made the car always return to one specific position when the game beginns. We had to set the cars speed to 0, because otherwise it would move forward on it’s own. We used a “forever” control so that the following things happen as long as the game lasts. In the program was already the option to turn right, so we just added the option to turn left when the left arrow key was pressed. For this, we used the control “If...Then”, inserted the sensorif key left arrow pressed” and put the motion “turn 5 degrees left” below.  Because the car also should have different speeds, we made the car not only go forward by pressing the up arrow key, but also to increase the speed by 0.2. For the speed option we created a variable. With the down arrow key we did the opposite but in order to don’t go too slow, we set a minimum of 0.4 by using a control block.




This is how a variable is made:

1. Go to the option Data  
2. Press "make a variable"
3. Name the variable

This is how a variable looks like:
Because we made this a multyplayer game, we had to make one variable for each car.


This is how we made the car go slower on the grass:
Still inside the “forever”, we made the car go slowly on the gras, so that the player doesn’t cheat. We used the “If... Then. Else...” control and inserted the sensor “touching color (green)”. Below we used a variable for speed, so that we could change the speed. In this case, we set the speed to 1, so that it goes slower when the car touches green. Else, the car should move the speed it already had, because otherwise the car wouldn’t move.

This is how we made the timer:

Because we wanted the player to have a limit to play, we added the option to get more gas for the car. For this we created a variable for seconds, so that the player had only 60 seconds before he has to load fuel. Again, we used the “If... Then” control and inserted an operator “...and…” with the sensor “touching color Yellow” and another operator inside with the variable seconds: “seconds car 1 (smaller than) 60”. This way, every time you touch the yellow gas station, your timer is resetted.



This is our timer:

We used the same event as on the others so that it works parallely. When the game starts, the seconds are set to 60 by using the variable seconds. Inside a "forever", we made the seconds decrease one by one. When the timer reaches 0, all the scripts must end and the game is over. We used an operator and inserted more operators and the seconds variable.




Once we finished, our game looked like this:

We had the gas station, two cars working parallely, the timer and the speedometer. We also changed the background to an irregular trace, so that it is more difficult.


Here are some images of the game in action

If you want to play the game we created click here: https://scratch.mit.edu/projects/174231505/#player
If you want to try this challenge out, click here:
https://scratch.mit.edu/projects/30428680/

Thanks for reading and we hope it helped you!


No comments:

Post a Comment