Catch It Live - Interactive Game

by ranjucupcake in Circuits > Computers

252 Views, 4 Favorites, 0 Comments

Catch It Live - Interactive Game

Supplies.jpg
Catch in Live.jpg

Catch it Live is an interactive and fun game built using Scratch programming. You can catch the ball using a real spoon, which makes it more exciting. For every catch, you get 10 points. To make it more thrilling, if you miss three chances...you will lose and game will be OVER!!!

Supplies

1. Personal Computer

2. Scratch Program

3. Web Cam (preferably external web cam)

4. Spoon (Plastic white)

5. Dark board (for dark background)

Code - Initialization

Scratch code 1.jpg

The video-sensing add-in in the newest version of scratch (Scratch 3.0) is the key component in this game that allows players to use real world objects to interact with scratch program and play the game.

A quick run down of our initialization:

  • Turning the Camera ON - Allows to use the video sensing module (so remember to add in to gain access to the video-sensing blocks)
  • Add Wait 1 sec to make sure the camera has turned on before rest of the code executes (since noticed that there is a small delay for the webcam to actually turn on)
  • Initialized Score as a variable to count the score and is set/reset to 0
  • Initialized Misses as a variable and Number of misses is set/reset to 3 (this can be changed to give more chances to the user)
  • Go to a random X position between -216px and 207px, while retaining the same Y position of 165px

Main Game Loop

Scratch code 2.jpg

Here's a rundown of the main game loop:

  1. Change Y by -10 - this moves the ball down 10px down the screen every iteration
  2. First IF statement: checks if the ball reached the bottom edge of the screen, if so then:
    1. Go to a new X position but back at the top Y position (the Y position that was defined at the beginning of the game and is the top of the screen)
    2. Reduce one count in Misses variable since missed by the player
    3. Play a "Whizz" sound to every misses to make it interesting
  3. Second IF statement: checks whether Misses variable had reached 0, if so then:
    1. Turn video (webcam) OFF
    2. Switch to backdrop 2 (Game over backdrop)
    3. Play a "dun dun dun" to notify the player as game ended
    4. Stop all - stops the entire program completely
  4. Final IF statement: checks if the ball has hit White colored object (real time object - here we used the white colored plastic spoon), if so then:
    1. Play "basketball bounce" sound to show a successful catch
    2. Add 10 points to Score for every successful catch
    3. Go to a new X position but back at the top Y position (the Y position that was defined at the beginning of the game and is the top of the screen)

Catch It Live - Demo

Catch It Live

Watch the demo of Catch It Live interacting game using a White spoon!