Set Up the Title Screen

Goal: Create the initial game start screen with a title and instructions.

Welcome players to Delivery Hero by displaying an opening title screen when the project runs.

  1. Snap a set background to block under the when run block.
  2. Snap a show title screen block below the background block.
  3. Set the title to "Delivery hero".
  4. Set the subtitle to "Press space to continue".
Set Up the Title Screen

Start the Game on Space Key

Goal: Initialize game variables, reset the timer, and call setup functions when space is pressed.

When the player presses space, start the gameplay if the game is not already running.

  1. Add a when space pressed event block.
  2. Add an if condition block checking if gameStarted ≠ true.
  3. Place a reset timer block inside the if block.
  4. Add a hide title screen block.
  5. Add a hide variable cash block.
  6. Add a hide variable orders block.
  7. Add a set background to block.
  8. Add the createRider function block.
  9. Add the createMap function block.
  10. Add the createHaze function block.
  11. Set countdown to 12.
  12. Add a show variable countdown at (23, 396) block.
  13. Set gameStarted to true.
  14. Set cash to 0.
Start the Game on Space Key

Create Haze Effect

Goal: Define the createHaze function to spawn animated fog or haze sprites.

Set up background haze sprites that flutter and wander across the screen.

  1. Open or define the createHaze function block.
  2. Draw your own haze sprite
  3. Add a make 10 new haze sprites block inside createHaze.
  4. Add a sprite begins fluttering behavior block for the haze sprite.
  5. Add a sprite begins wandering behavior block for the haze sprite.
Create Haze Effect

Create the Map and First Cash

Goal: Define the createMap function to place city buildings in a grid and spawn the initial cash item.

Generate the city layout with building obstacles and place the first cash pickup.

  1. Open or define the createMap function block.
  2. Add a make sprites using grid block inside createMap and place the buildings into your map.
  3. Add a make new cash sprite at (362, 347) block.
  4. Add a set cash size to 30 block.
Create the Map and First Cash

Driving with Arrow Keys Behavior

Goal: Define the driving with arrow keys behavior to control sprite acceleration, braking, turning, and wall collision.

Customize the driving behavior that lets the rider steer, speed up, reverse, and bounce off the edges.

  1. Open the driving with arrow keys with: this sprite behavior.
  2. Add an if up is pressed block with an inner if this sprite speed ≤ 6 block.
  3. Add a change this sprite speed by 0.25 block inside the inner if block.
  4. Add a move this sprite this sprite speed pixels forward block inside the up is pressed block.
  5. Add an else branch checking if this sprite speed > 0 and add a change this sprite speed by -1 block.
  6. Add an if down is pressed block.
  7. Set this sprite speed to 1 inside the down is pressed block.
  8. Add a move this sprite this sprite speed pixels backward block.
  9. Add an if left is pressed block.
  10. Add a change this sprite movement direction by -5 block.
  11. Add a change this sprite rotation by -5 block.
  12. Add an if right is pressed block.
  13. Add a change this sprite movement direction by 5 block.
  14. Add a change this sprite rotation by 5 block.
  15. Add an if this sprite is touching edges block.
  16. Add an edges block this sprite from moving block inside the condition.
Driving with Arrow Keys Behavior

Create Rider Sprite

Goal: Define the createRider function to spawn the delivery vehicle and set its size, speed, and behavior.

Set up the player's delivery car with its starting position, size, and driving behavior.

  1. Open or define the createRider function block.
  2. Add a make new rider sprite at (58, 32) block inside createRider.
  3. Add a set rider size to 30 block.
  4. Add a set rider speed to 0 block.
  5. Add a rider begins driving with arrow keys behavior block.
Create Rider Sprite

Count Down Timer

Goal: Decrease the countdown every second and trigger the game over screen when time runs out.

Manage the game countdown clock each second while the game is active.

  1. Add an at 1 seconds recurring event block.
  2. Add an if condition checking if gameStarted = true.
  3. Add a reset timer block inside the condition.
  4. Add a change countdown by -1 block.
  5. Add an if condition checking if countdown = 0.
  6. Add a play completed game sound'.
  7. Add a remove all sprites block.
  8. Add a set background to block.
  9. Add a show title screen block with title 'Delivery completed' and subtitle 'Press space to try again.'.
  10. Call the showEndingCash function block.
  11. Set gameStarted to false.
Count Down Timer

Handle Cash Collection

Goal: Collect cash when the rider touches the cash sprite and update score and time.

Reward the player with cash, orders, extra time, and speech feedback when picking up cash.

  1. Add a while rider touches cash event block.
  2. Add a play sound block with 'Bell: vibrant_cash_register_open_positive_game_open'.
  3. Add an object cash jump to random location block.
  4. Add a change countdown by random integer from 2 to 6 block.
  5. Add a change cash by random integer from 10 to 100 block.
  6. Add a change orders by 1 block.
  7. Add a subject rider say 'cash: ' cash for 4 seconds block.
Handle Cash Collection

Handle Rider Crash

Goal: End the game when the rider collides with a building obstacle.

Detect crashes against buildings and display the game over screen.

  1. Add a when rider touches building event block.
  2. Add a play sound block with 'Alerts: playful_quirky_negative_game_cue_2'.
  3. Add a remove all sprites block.
  4. Add a set background to block.
  5. Add a show title screen block with title 'RIP' and subtitle 'Press space to try again.'.
  6. Call the showEndingCash function block.
  7. Set gameStarted to false.
Handle Rider Crash

Show Ending Cash and Orders

Goal: Define the showEndingCash function to display final cash and order counts on game over.

Display the player's final performance statistics on screen after the game ends.

  1. Open or define the showEndingCash function block.
  2. Add a show variable orders at location x: 120 y: 200 block inside showEndingCash.
  3. Add a show variable cash at location x: 260 y: 200 block.
Show Ending Cash and Orders

Respawn Cash Away from Buildings

Goal: Prevent cash from getting stuck inside buildings.

Ensure cash jumps to a new location if it spawns on top of a building.

  1. Add a while cash touches building event block.
  2. Add a subject cash jump to random location block inside the event.
Respawn Cash Away from Buildings

🎉 Congratulations!

Congratulations! You built Delivery Hero with obstacles, cash pickups, timer countdowns, and game over conditions!
🏆

Next challenge!

  1. Add a high score system that tracks the most cash and orders collected.
  2. Add different types of obstacles or moving traffic vehicles for the rider to dodge.
  3. Create power-ups that temporarily freeze the timer or double the cash earned.
🚀
×
Zoomed view