πŸ’Ž Ruby Collector

Build a simple collect-and-win game.

Learn about sprites, variables, events, collisions and game design.

Step 1: Create the Game World

🎯 Goal: Create the player, ruby, enemy and score system.
  1. Choose a background.
  2. Create a ruby sprite and set its size to 30.
  3. Create an enemy sprite and set its size to 80.
  4. Use the Sprite begins block and make the enemy wander around using the "wandering" behaviour.
  5. Create the player sprite and set its size to 50.
  6. Use the Sprite begins and "moving with arrow keys" behaviour to make the player move with the arrow keys.
  7. Show a message: β€œCollect 10 rubies to win!”.
  8. Show the score variable and set it to 0.

Variables

VariablePurpose
scoreTracks how many rubies the player has collected.
βœ… You should see a player, a ruby, an enemy and a score counter.

Step 2: Collect Rubies

🎯 Goal: Increase the score when the player touches a ruby.
  1. Create a loop that checks if the player touches the ruby.
  2. Play a collection sound.
  3. Move the ruby to a random location.
  4. Increase score by 1.
  5. If score equals 10, trigger the win event.
  6. Remove all sprites and play a victory sound.

What Does This Code Do?

Every time the player collects a ruby, the ruby jumps somewhere new and the score increases.

πŸ’‘ Random locations make the game more fun because the player must keep searching.
βœ… The score should increase every time a ruby is collected.

Step 3: Create the Game Over Event

🎯 Goal: End the game when the player touches the enemy.
  1. Create a collision event between the player and enemy.
  2. Remove all sprites.
  3. Play a game over sound.
  4. Show the score variable.

Why Are We Doing This?

The enemy creates a challenge. Players must collect rubies while avoiding danger.

βœ… Touching the enemy should immediately end the game.

Step 4: Fix the Bug

πŸ› Goal: Fix the "move with arrow keys" behavior to prevent moving outside the map.
  1. Click "edit" on the "moving with arrow keys" behaviour.
  2. Find the "edges block from moving" block.
  3. Add that block to the very top of the behaviour.
  4. Try the moving with arrow keys again.

Why Is This Important?

Right now, the player can move outside the map and avoid enemies. This makes the game unfair. By blocking movement at the edges, the player must stay within the game boundaries.

βœ… The player should not be able to move outside the map.

πŸŽ‰ Congratulations!

You built a complete game with:

  • Variables
  • Sprites
  • Events
  • Collisions
  • Score Tracking
  • Boundary Constraints
πŸ†

πŸš€ Next Challenge!

🎯 Try these fun challenges to make your game even better!
  1. Ending:Make a better ending when the player loses or collects 10 rubies
  2. Power-Ups: Add special items that make your hero faster when collected! Use a new sprite for the power-up and make it disappear after use.
  3. Extra Lives: Create a "Lives" variable and start with 3 lives. Only end the game when all lives are lost!
πŸ’‘ Tip: Use the "show variable" block to display lives on the screen, just like the score!
πŸš€