CODE CREATIVE
TRUCK MASTER
Drive all day and night
TASK #1
The "Truck Masters" program will ask the user create a racing game in which you take the role of a truck driver shipping their load all day and night to reach their destination.

The first task is to watch the introduction video below
to get an idea of what the project entails.
After watching the video, be sure to
open up the "Starter Pack"
. Make sure you click on the remix button after Scratch opens up so that it saves on your account.
TASK #2
TASK:
Add a starting screen, play a sound effect, and make all the sprites disappear.

HINT #1:
You will need to use the
"Green Flag"
,
"Change Backdrop"
,
"Play sound"
, and
"Hide"
, blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #3
TASK:
Create a pixelate effect that will blur out the starting screen, change the backdrop, and cause the starting screen to become clear again.

HINT #1:
You will need to use the
"Repeat"
,
"Change effect"
,
"Switch Backdrop"
, and
"Wait"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #4
TASK:
Make the truck appear at his starting location and glide to the left lane when the 'a' key is pressed.

HINT #1:
You will need to use the
"Broadcast"
,
"When I Receive Broadcast"
,
"Go To"
,
"When Key Pressed"
, and
"Glide"
, blocks.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGES EXERCISES
  1. Cause the truck to glide back to the right lane when the 'd' key is pressed.
  2. Remember to keep the y positions the same when gliding from lane to lane.
TASK #5
TASK:
Create a Lane variable that will store the lane that the truck is in as it moves around the freeway.

HINT #1:
You will need to create a new varialbe and use the
"Change Variable By"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #6
TASK:
Use the Lane variable to make the truck glide from the 2 lane to the 1 lane when the 'a' key is pressed. Also, make the truck glide from the 1 lane to the 0 lane when the 'a' key is pressed again.

HINT #1:
You will need to use the
"New Sprite"
,
"Green Flag"
,
"Green Flag"
,
"Green Flag"
,
"Green Flag"
, and
"Say"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGES EXERCISES
  1. Program the truck to move from the 3 lane to the 2 lane when the 'a' key is pressed.
  2. Use the same technique to cause the truck to move to the right when the 'd' key is pressed.
  3. Remember that the order of the if statements matter!
TASK #7
TASK:
Fix the bug that happens when you pressed 'a' quickly after pressing 'd', or 'd' quickly after pressing 'a'.

HINT #1:
You will need to consider the order that you placed your coding blocks to make the truck move from left to right.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #8
TASK:
Make the Red Car appear in the 0 lane at random times and have it glide to the front of the screen. Be sure to also increase the car's size as it is moving towards the front of the screen.

HINT #1:
You will need to use the
"Forever"
,
"Wait"
,
"Create Clone"
,
"When I Start As Clone"
,
"Set Size"
, and
"Glide"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #9
TASK:
Make the car appear to come to the front of the screen at a slower rate the farther away it is and faster the closer it is.

HINT #1:
You will need to use the
"Glide"
,
"Repeat Until"
,
"Touching Edge"
,
"If/Else"
,
"Greater Than"
, and
"Wait"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGES EXERCISES
  1. Program the other cars to appear in lane 0 at random times.
  2. Also make sure to increase their size at different rates depending on their y positions.
TASK #10
TASK:
Create a block of code that will cause the Red Car to glide down lane 1.

HINT #1:
You will need to use the same blocks as found in Task #9.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISES
  1. Create blocks of code that cause the Red Car to glide down lanes number 2 and 3 as well.
  2. Do the same for the Black Truck, Black Car and Blue Car.
TASK #11
TASK:
Create two variables: Which Car and Which Lane. We will be using these variables to determine what kind of car to clone and which lane to send the car down.

HINT #1:
You will need to create a couple of variables and initialize them, which means to set them equal to their first value when the Green Flag is clicked.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #12
TASK:
Cause the Red Car to be cloned when Which Lane and Which Car are both equal to 0.

HINT #1:
You will need to use the
"When Backdrop Switches"
,
"Forever"
,
"Set Variable"
,
"Pick Random"
,
"If"
, and
"Broadcast"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #13
TASK:
Add code to cause the Red Car to randomly appear in lane 1.

HINT #1:
You will use the same technique as used in Task #12.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISES
  1. Make the Red Car appear in lanes 2 and 3 as well.
  2. Do the same for the Black Truck, Black Car and Blue Car.
TASK #14
TASK:
Make the incoming cars appear behind one another and cause the cars to appear at random times.

HINT #1:
You will need to use the
"Go to Front"
,
"Go Back Layer"
,
"Wait"
, and
"Pick Random"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #15
TASK:
Make the game end when the clone of the Red Car touches the Truck and the clone is at the bottom of the screen.

HINT #1:
You will need to use the
"If"
,
"Touching"
,
"Y Position"
,
"Less Than"
,
"Green Flag"
, and
"Switch Backdrop"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISES
  1. Program the background to switch when the Truck hits the the Black Truck, Black Car and Blue Car.
TASK #16
TASK:
Test all of your crashes with the 4 different cars. If there are any that don't crash, then watch the video below to see how to debug the problem.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #17
TASK:
Program the game to stop the game when the background switches to the lose screen.

HINT #1:
You will need to use the
"When I Receive"
,
"Stop All"
, and
"Hide"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #18
TASK:
Play Background Music when the truck is driving around and play Crash when the truck crashes into a car.

HINT #1:
You will need to use the
"Play Sound Until Done"
and
"Stop Other Scripts in this Sprite"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #19
TASK:
Change the order of the levels to start with Day. Also, use the timer to change the level from Day to Desert after a certain amount of time has past.

HINT #1:
You will need to use the
"If"
,
"Greater Than"
, and
"Timer"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
TASK #20
TASK:
Fix the fact that the cars still spawn while the level is switching by creating a variable and adding a conditional statement.

HINT #1:
You will need to use the
"Set Variable To"
,
"If"
,
"Greater Than"
,
"And"
, and
"Less Than"
blocks.

CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISES
  1. Make the game change levels from Desert to Night after some more time has past.
  2. After some more time has past, change the backdrop from Night to Win Screen.


Congratulations, you have created Truck Masters!
ADDITIONAL CHALLENGE EXERCISES
  1. Make the game clone cars more often everytime the level switches.
  2. Give the different clones random glide speeds.
  3. Create an animation when the win condition is met.
  4. Allow the cars to switch lanes.
  5. Allow the Truck Master to have 3 lives.