Remix the Starter Project

Goal: Open the starter project template and remix it to start building your game.

Start by making a copy of the starter template so you can add your own code.

  1. Click this link to create a remix of the template: Remix Template

Initialize Game

Goal: Set up the initial start screen and game state when the program runs.

Configure the opening screen to display the title and instruct the player to press space to begin.

  1. Place a "set background to" block under "when run" and choose the dark forest background (or any background you like from the library).
  2. Attach a "show title screen" block and set title to "Treasure hunter" and subtitle to "Press space to start".
  3. Attach a "set [game started] to" block and set the value to false.
Initialize Game

Define resetGame Function

Goal: Create a function to reset the game state when a new game starts.

This function marks the game as started, hides the title screen and score display, and sets the score to 0.

  1. In the "resetGame" function definition block, add a "set [game started] to" block and set it to true.
  2. Add a "hide variable [score]" block.
  3. Add a "hide title screen" block.
  4. Add a "set [score] to" block and set the value to 0.
Define resetGame Function

Define createMap Function

Goal: Create a function that sets up the background grid and compass sprite.

The map provides a grid background and places a compass sprite in the corner.

  1. In the "createMap" function definition block, add a "set background to" block with the grid background (or any background you like from the library).
  2. Add a "make new [compass] sprite at (32, 26)" block.
  3. Add a "set [compass] size to" block and set the size to 50.
Define createMap Function

Define createTreasure Function

Goal: Create a function to spawn the coin treasure sprite.

Spawn a treasure coin at a random location on the board and set its size.

  1. In the "createTreasure" function definition block, add a "make new [coin] sprite at random location" block.
  2. Add a "set [coin] size to" block and set the size to 1.
Define createTreasure Function

Define createHero Function

Goal: Create a function to spawn the hero character.

Spawn the purple bunny hero sprite, adjust its size, and enable arrow key movement.

  1. In the "createHero" function definition block, add a "make new [bunny] sprite at (332, 48)" block.
  2. Add a "set [bunny] size to" block and set the size to 50.
  3. Add a "sprite [bunny] begins [moving with arrow keys]" block.
Define createHero Function

Define createEnemy Function

Goal: Create a function to spawn the wandering monster enemy.

Spawn an orange one-eyed monster sprite and give it wandering behavior.

  1. In the "createEnemy" function definition block, add a "make new [monster] sprite at (64, 315)" block.
  2. Add a "sprite [monster] begins [wandering]" block.
Define createEnemy Function

Handle Space Key Press

Goal: Start the game when the space key is pressed if the game is not already running.

Listen for the space key event and call all setup functions if game started is false.

  1. Add a "when [space] pressed" event block.
  2. Inside the event, add an "if [game started] = false" conditional block.
  3. Inside the if block, call the "resetGame" function block.
  4. Call the "createMap" function block.
  5. Call the "createTreasure" function block.
  6. Call the "createHero" function block.
  7. Call the "createEnemy" function block.
Handle Space Key Press

Prevent Treasure from Spawning on Compass

Goal: Ensure the treasure does not overlap with the compass sprite.

If the coin touches the compass when spawned, relocate it to a new random location.

  1. Add a "when [coin] touches [compass]" event block.
  2. Inside the event, add a "[coin] jump to random location" block.
Prevent Treasure from Spawning on Compass

Collect Treasure Event

Goal: Handle what happens when the hero collects the treasure coin.

Play a sound, move the coin, increase the score, and make the hero say the updated score.

  1. Add a "when [coin] touches [bunny]" event block.
  2. Inside the event, add a "play sound [Digital: ping]" block (or choose any sound you like from the library).
  3. Add a "[coin] jump to random location" block.
  4. Add a "change [score] by 1" block.
  5. Add a "[bunny] say join "Collected: " [score] for 4 seconds" block.
Collect Treasure Event

Check Compass for Treasure Coordinates

Goal: Display the treasure coordinates when the hero touches the compass.

When touching the compass, the compass tells the player the X and Y positions of the hidden treasure.

  1. Add a "when [compass] touches [bunny]" event block.
  2. Inside the event, add a "[compass] say join "The treasure is at " join "X: " [coin x position] "Y: " [coin y position] for 4 seconds" block.
  3. Add a "play sound [Collect: retro_game_health_pickup_2]" block (or choose any sound you like from the library).
Check Compass for Treasure Coordinates

Define gameOver Function

Goal: Create a function to handle the game over sequence.

End the game state, play a game over sound, clear sprites, show the game over screen, and display the final score.

  1. In the "gameOver" function definition block, add a "set [game started] to" block and set it to false.
  2. Add a "play sound [Alerts: comedy_game_over_1]" block (or choose any sound you like from the library).
  3. Add a "remove [all sprites]" block.
  4. Add a "set background to" block with the rainbow landscape background (or any background you like from the library).
  5. Add a "show title screen" block and set title to "Game over" and subtitle to "Press space to restart".
  6. Add a "show variable [score] at (200, 200)" block.
Define gameOver Function

Monster Collision Event

Goal: Trigger game over when the monster touches the hero.

Detect when the monster enemy touches the bunny hero and trigger the gameOver function.

  1. Add a "when [monster] touches [bunny]" event block.
  2. Inside the event, call the "gameOver" function block.
Monster Collision Event

🎉 Congratulations!

Congratulations! You have created a complete Treasure Hunter game with hero movement, wandering enemies, clue mechanics, scoring, and game over handling!
🏆

Next challenge!

Next challenge ideas:
  1. Add multiple enemy monsters wandering at different speeds.
  2. Add a timer that counts down to increase the difficulty.
  3. Change the sprite costumes or add power-ups that give bonus points.
🚀
×
Zoomed view