m (Bolded.)
(Removed second person and more.)
 
Line 1: Line 1:
 
[[File:Racing track.png|right|thumb|200px|An example backdrop]]
 
[[File:Racing track.png|right|thumb|200px|An example backdrop]]
[[File:Racing track finished.png|right|thumb|200px|You should add in cars and edit the track as shown here when it is finished.]]
+
[[File:Racing track finished.png|right|thumb|200px|Add in cars and edit the track as shown here when it is finished.]]
A '''two player racing game''' is a [[project]] that lets one compete in racing against their friends.
+
A '''two player racing game''' is a [[project]] that lets one compete in racing against another person.
  
 +
{{note|This tutorial does not connect to other users so they can compete together. Instead, two players on the same computer will be playing together.}}
 
==Preparation==
 
==Preparation==
 
Create three sprites:
 
Create three sprites:
Line 16: Line 17:
 
end
 
end
 
</scratchblocks>
 
</scratchblocks>
Continue to do this with the left arrow, down arrow, and so on.  Then, place the scripts in a forever block, and under a when green flag clicked block.  It should look like this once you are finished:
+
Continue to do this with the left arrow, down arrow, and so on.  Then, place the scripts in a forever block, and under a when green flag clicked block.  It should look like this once finished:
 
<scratchblocks>
 
<scratchblocks>
 
when gf clicked
 
when gf clicked
Line 41: Line 42:
  
 
== Player 2 ==
 
== Player 2 ==
For the second player, get another car from the sprites library.  Do the same thing as you did with player one, only using the W (up), A (left), S (down), and D (right) keys.  Once finished, it will look like this:
+
For the second player, get another car from the sprites library.  Do the same thing as done with player one, only using the W (up), A (left), S (down), and D (right) keys.  Once finished, it will look like this:
 
<scratchblocks>
 
<scratchblocks>
 
when gf clicked
 
when gf clicked

Latest revision as of 12:54, 28 April 2021

An example backdrop
Add in cars and edit the track as shown here when it is finished.

A two player racing game is a project that lets one compete in racing against another person.

Note Note: This tutorial does not connect to other users so they can compete together. Instead, two players on the same computer will be playing together.

Preparation

Create three sprites:

  • Player 1
  • Player 2
  • Finish Line

Player 1

First create a new sprite, then change the costume to a car in the Sprites Library where there are sprites, add a if <> then block, then a Point in Direction block, then add a Move () Steps block. It should look like this:

 
if <key (right arrow v) pressed> then
point in direction (0)
move (10) steps
end

Continue to do this with the left arrow, down arrow, and so on. Then, place the scripts in a forever block, and under a when green flag clicked block. It should look like this once finished:

when gf clicked
go to x: (. . .::grey) y: (. . .::grey)
forever
if <key (right arrow v) pressed> then
point in direction (0)
move (10) steps
end
if <key (left arrow v) pressed> then
point in direction (-90)
move (10) steps
end
 if <key (down arrow v) pressed> then
point in direction (180)
move (10) steps
end
if <key (up arrow v) pressed> then
point in direction (0)
move (10) steps
end
end

Player 2

For the second player, get another car from the sprites library. Do the same thing as done with player one, only using the W (up), A (left), S (down), and D (right) keys. Once finished, it will look like this:

when gf clicked
go to x: (. . .::grey) y: (. . .::grey)
forever
if <key (w v) pressed> then
point in direction (0)
move (10) steps
end
if <key (s v) pressed> then
point in direction (180)
move (10) steps
end
if <key (a v) pressed> then
point in direction (-90)
move (10) steps
end
if <key (d v) pressed >then
point in direction (90)
move (10) steps
end
end

Backdrop

Go into Paint Editor and paint a backdrop.

Players

Once the backdrop is finished, add the following code to both players:

when gf clicked
forever
if <touching (Finish Line v)?> then
say [I win!] for (.5) seconds
stop [all v]
end
end

Instructions

Player 1 will move with the up, down, left and right keys, and Player 2 will move with the W, A, S and D keys.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.