Build a Fun 2-Player Flower-Picking Game in Scratch: A Step-by-Step Guide


Let’s Build a Fun 2-Player Flower Picking Game in Scratch!

Hey there, young coder! Today, we’re going to create a 2-player flower-picking game in Scratch 3.0. Imagine you and your friend are in a big, colorful garden, racing to pick as many flowers as possible before time runs out. The player with the most flowers wins! Sounds fun, right?

I’ll walk you through each step using simple explanations—just like building a house. Ready? Let’s go!


How the Game Works

🌼 Two players control characters who run around a garden.
🌼 Flowers appear randomly, and players try to collect them.
🌼 A countdown timer keeps track of time.
🌼 The player with the highest score when time runs out wins!


Step 1: Adding Sprites (Characters and Flowers)

Every game needs characters!

1️⃣ Open Scratch and delete the cat sprite (we won’t need it).
2️⃣ Click "Choose a Sprite" and pick two characters for the players (e.g., a bunny and a squirrel).
3️⃣ Click "Choose a Sprite" again and add a flower.
4️⃣ Go to Backdrops and select a garden or meadow.


Step 2: Making the Players Move

Think of this like controlling a remote-controlled car! Each player will have different controls:

  • Player 1 uses the arrow keys.
  • Player 2 uses the W, A, S, D keys.

Code for Player 1 (Arrow Keys)

1️⃣ Click on Player 1’s sprite.
2️⃣ Add this code:

when green flag clicked
Go to x:-191 to y:-131
forever
  if <key (up arrow) pressed?> then
    change y by 5
  end
  if <key (down arrow) pressed?> then
    change y by -5
  end
  if <key (right arrow) pressed?> then
    change x by 5
  end
  if <key (left arrow) pressed?> then
    change x by -5
  end
end

💡 What’s happening?

  • The sprite will start at a given position
  • If you press the up arrow, the player moves up.
  • If you press the down arrow, the player moves down.
  • Left and right move the player sideways.

Code for Player 2 (W, A, S, D Keys)

Now, do the same for Player 2, but change the keys!

when green flag clicked
Go to x:179 y:-136
forever
  if <key (w) pressed?> then
    change y by 5
  end
  if <key (s) pressed?> then
    change y by -5
  end
  if <key (d) pressed?> then
    change x by 5
  end
  if <key (a) pressed?> then
    change x by -5
  end
end

Step 3: Making Flowers Appear Randomly

Flowers should pop up at different places like a surprise! Here’s how:

1️⃣ Click on the Flower sprite.
2️⃣ Add this code:

when green flag clicked
Hide
forever
  wait (1) second
  Create clone of myself
  Go to (random position)
end

💡 What’s happening?


  • The flower hides
  • Makes a copy of itself every 1 second
  • The flower moves to a random spot every 1 seconds.
  • This makes the game exciting since players must race to pick the flower before the other player does!

Step 4: Collecting Flowers & Keeping Score

Each time a player touches a flower, they should earn points. Let’s track that using variables!

Creating Score Variables

1️⃣ Go to the Variables section.
2️⃣ Click "Make a Variable" and name it Player 1 Score.
3️⃣ Make another variable called Player 2 Score.

Code for Player 1 (Collecting Flowers)

1️⃣ Click on Player 1’s sprite and add this code:

when green flag clicked
set [Player 1 Score] to (0)
forever
  if <touching (Flower)?> then
   Wait (1) second
    change [Player 1 Score] by (1)
  end
end

Code for Player 2 (Collecting Flowers)

1️⃣ Click on Player 2’s sprite and add this code (just change "Player 1 Score" to "Player 2 Score"):

when green flag clicked
set [Player 2 Score] to (0)
forever
  if <touching (Flower)?> then
   wait (1) second
   change [Player 2 Score] by (1)
    
  end
end

💡 What’s happening?

  • If a player touches the flower, their score increases by 1

Step 5: Adding a Countdown Timer

A game is more exciting with a countdown timer! Here’s how to add one:

1️⃣ Go to the Variables section and create a new variable called Time Left.
2️⃣ Click on the Stage and add this code:

when green flag clicked
set [Time Left] to (30) // Game lasts 30 seconds
repeat until <(Time Left) = (0)>
  wait (1) second
  change [Time Left] by (-1)
end
broadcast (Game Over)

💡 What’s happening?

  • The timer starts at 30 seconds and counts down.
  • When time reaches zero, the game stops!

Step 6: Announcing the Winner!

When time is up, the game should tell us who won!

1️⃣ Click on the Stage and add this code:

when I receive (Game Over)
if <(Player 1 Score) > (Player 2 Score)> then
  say [Player 1 Wins!] for (3) seconds
else
  if <(Player 2 Score) > (Player 1 Score)> then
    say [Player 2 Wins!] for (3) seconds
  else
    say [It's a Tie!] for (3) seconds
  end
end
stop all

💡 What’s happening?

  • The game compares the scores and announces the winner.
  • If both scores are the same, it says "It's a Tie!"

Make Your Game Even More Fun!

Now that your game works, here are cool features you can add:
Sound Effects: Play a fun sound when a flower is picked.
Power-ups: Add a golden flower that gives 3 points instead of 1!
Obstacles: Add a butterfly that slows down players if they touch it.


Final Challenge: Can You Add More Flowers?

Try adding multiple flowers that appear at different times. Can you do it? Give it a shot and make your game even more exciting!


Great Job, Young Coder! 🎉

You just built a 2-player game all by yourself! Scratch is all about experimenting, so keep tweaking and improving your game.

Did you enjoy this tutorial? Let me know what extra features you added! Happy coding! 🚀

Comments