Practice and reinforce the concepts from Lesson 9
Time needed: 25-30 minutes
Create your very own bouncing ball game! You'll make colorful balls that bounce around the screen, change colors when touched, and score points. It's like having your own mini arcade game that you designed!
Watch your balls bounce off the walls, tap them to change colors, and see how many points you can score! :emoji::emoji::emoji:
:white_check_mark: Open MIT App Inventor
:white_check_mark: Create a new project called "BouncingBallGame"
:white_check_mark: Remember the Canvas coordinate system from the lesson
:white_check_mark: Think about what colors you want your balls to be!
Here's what you'll be building today:
What You'll Create | Components You'll Use |
---|---|
• A colorful game screen• Multiple bouncing balls• Score display• Speed controls | Visible components:• Canvas (your game area)• Ball components (3 balls)• Labels (for score and title)• Buttons (to control the game)Layouts:• HorizontalArrangement• VerticalArrangement |
Add a Canvas to your screen
Add 3 Ball components to your Canvas
Add a Label for your score at the top
:bulb: Design Tip! :art:
Pick colors that look good together! Try using your favorite sports team colors or rainbow colors!
Create these global variables:
When Screen1 initializes:
For each Ball (Ball1, Ball2, and Ball3):
When Ball.EdgeReached:
:bulb: Stuck?
The EdgeReached event gives you an "edge" parameter. Just pass this directly to the Bounce method - MIT App Inventor does the math for you!
For each Ball:
When Ball.Touched:
Bonus: Make the touched ball speed up a little bit!
Add these buttons in a HorizontalArrangement:
"Faster!" Button:
"Slower!" Button:
"Reset" Button:
:bulb: Positioning Tip! :emoji:
To reset a ball's position, set its X and Y properties. Try putting them in different corners!
Make each ball change to a SPECIFIC color when touched:
When Ball1 collides with Ball2 or Ball3:
Add an ImageSprite as a power-up:
Once you've created your bouncing ball game:
Remember: The most important thing is to have fun and be creative! There's no wrong way to make your game - add your own special touches! :art::sparkles:
After building your game, can you answer these questions?
Great job creating your first animated game! You're now a game developer! :video_game::trophy: