Remix the Template

Goal: Create a copy of the template project to start building your game.
  1. Click this link to remix the template: Remix Template

Initialize the Game

Goal: Set up the initial background, title screen, and game state.
  1. Find the "set background to" block in the World category and connect it under the "when run" block.
  2. Click the dropdown in the "set background to" block and choose the night forest background.
  3. Add the "show title screen" block from the World category under the background block.
  4. Set the title of the title screen to "Treasure hunter" and the subtitle to "Press space to start".
  5. Add a "set to" variable block from the Variables category at the bottom of the "when run" block.
  6. Create a new variable named "game started", select it in the dropdown, and set it to false.
Initialize the game

Start the Game Event

Goal: Trigger the game setup when the space key is pressed.
  1. Add a "when space pressed" event block from the Events category.
  2. Place an "if" block from the Logic category inside the event block.
  3. Connect an equality comparison block to the "if" block and check if the "game started" variable equals false.
  4. Inside the "do" section of the "if" block, call the "resetGame", "createMap", "createTreasure", "createHero", and "createEnemy" functions in that order.
Start the game event

Keep the Treasure Unstuck

Goal: Ensure the treasure does not get stuck on the compass.
  1. Add a "when touches" event block from the Events category.
  2. Set the first sprite dropdown to the coin image and the second sprite dropdown to the compass image.
  3. Inside the event block, add a "jump to" block from the Sprites category and set the coin sprite to jump to a random location.
Keep treasure unstuck

Collect the Treasure

Goal: Score points and update the player score when collecting a coin.
  1. Add a "when touches" event block from the Events category.
  2. Set the first sprite dropdown to the coin image and the second sprite dropdown to the purple rabbit image.
  3. Connect a "play sound" block from the World category and choose "Digital: ping" as the sound.
  4. Add a "jump to" block from the Sprites category and set the coin sprite to jump to a random location.
  5. Add a "change by" variable block from the Variables category and increase the "score" variable by 1.
  6. Add a "say" block from the Sprites category and make the purple rabbit say a joined string of "Collected: " and the "score" variable for 4 seconds.
Collect treasure

Use the Compass

Goal: Display the treasure coordinates when the player touches the compass.
  1. Add a "when touches" event block from the Events category.
  2. Set the first sprite dropdown to the compass image and the second sprite dropdown to the purple rabbit image.
  3. Add a "say" block from the Sprites category and make the compass say "The treasure is at ".
  4. Use the text join blocks to combine the label "X: " with the coin's "x position" block and the label "Y: " with the coin's "y position" block, showing the coordinates for 4 seconds.
  5. Add a "play sound" block at the bottom of the event block and select "Collect: retro_game_health_pickup_2".
Use the compass

Game Over Logic

Goal: End the game when the monster catches the player.
  1. Add a "when touches" event block from the Events category.
  2. Set the first sprite dropdown to the orange monster image and the second sprite dropdown to the purple rabbit image.
  3. Inside the event block, call the "gameOver" function block from the Functions category.
Game over logic

🎉 Congratulations!

Congratulations! You have completed the Treasure Hunter game. Now you can find the hidden treasure while dodging the monster!
🏆

Next challenge!

Next challenge ideas:
  1. Add a timer to see how many coins you can collect before time runs out.
  2. Make the monster move faster over time.
  3. Add obstacles that the player must avoid.
🚀
×
Zoomed view