Set up the game

Goal: Prepare the world, carrot sprite, and game variables.
  1. Place the "when run" block in the workspace.
  2. Set the "set background to" block to the shown background.
  3. Place the "make new sprite at" block and choose the carrot sprite at (200, 200).
  4. Set the carrot sprite size to 50 with the "set" block.
  5. Set the "collectedCarrots" variable to 0 with the "set" block.
  6. Set the "countDownToCactus" variable to 5 with the "set" block.
Set up the game blocks

Collect a carrot

Goal: Make the carrot move and keep track of collected carrots and the cactus countdown.
  1. Add the "when carrot clicked" event block.
  2. Make the carrot sprite jump to a random location with the "jump to" block.
  3. Change the "collectedCarrots" variable by 1.
  4. Change the "countDownToCactus" variable by -1.
  5. Make the carrot sprite say the "collectedCarrots" value followed by "Points" for 4 seconds.
  6. Play the "Digital: ping" sound.
  7. Add an "if" block that checks whether "countDownToCactus" = 0.
  8. Set the "countDownToCactus" variable to 5 inside the "if" block.
  9. Make a new cactus sprite at a random location inside the "if" block.
Collect a carrot blocks

Click the cactus

Goal: End the game when the cactus is clicked and show the carrot score.
  1. Add the "when cactus clicked" event block.
  2. Play the "Explosion: melodic_loss_6" sound.
  3. Remove "all sprites".
  4. Show the "collectedCarrots" variable at (200, 200).
Click the cactus blocks

🎉 Congratulations!

You built a carrot-collecting game! Every click moves the carrot and counts your points — and watch out for that cactus!
🏆

Next challenge!

  1. Make the carrot smaller after each click so it becomes harder to collect.
  2. Add a second carrot sprite and give each carrot its own click event.
  3. Increase the number of carrots needed before a cactus appears.
  4. Add a timer and end the game when the timer reaches 0.
  5. Create a high-score variable and show the player's best score.
  6. Add a winning condition, such as collecting 10 carrots without clicking a cactus.
🚀
×
Zoomed view