Download presentation
Presentation is loading. Please wait.
Published byWhitney West Modified over 9 years ago
1
Unit 6 Motion – Air Hockey Evangel College S.2 ICT
2
Air Hockey Game Have you ever played Air Hockey in game center? Do you want to create this game?
3
Names of components Mallet Puck Goal Rail Center line
4
Puck How to make a movable puck? Paint a new sprite and rename it Puck Add the “move” block to the script area of Puck. Click on the “move” block. What do you find?
5
Puck How to make the Puck moving continuously? Add the “forever” block to wrap the “move” block What do you find?
6
Puck How to make the Puck bounce on the edge of the air hockey table? Add the “if on edge, bounce” block at the end of the stack. What do you find?
7
Puck How to change the direction of the Puck so that it does not just move left and right? Add the “point in direction” before “forever” block and adjust the direction value. What do you find?
8
Mallet How to make a mallet? Paint a new sprite and rename it Mallet
9
Mallet How to make the Mallet stick to the mouse? Add the “go to ” block to the script area of Mallet Change the position to “mouse-pointer”. Wrap it with “forever” block. What do you find?
10
Collision detection How detect collision between two sprites? The “touching” block can detect collision of the sprite with other sprites. It can be used in condition blocks such as “if” block, “if-else” block or “wait until” block.
11
Programming Concept: Condition Conditional statement: A program may perform different actions depending on the boolean condition evaluated to be true or false. It is very commonly used in programming. Key pressed? Turn back Face the mallet Yes No
12
Collision detection What should happen when the puck collides with the mallet? x Puck (Start) Mallet Puck (Bounce back)
13
Goal How to make the goals of two players? Paint two new sprites and rename them P1Goal and P2Goal respectively
14
Goal What should happen when the puck collides with the goals of players?
15
Mix together
16
Extended Activity Activity 1 (Initialization): Add script to reset the position of the puck to the center (0, 0) of the stage at the beginning of the game.
17
Programming Concept: Initialization Initialization: Initialization resets the program to a certain state.
18
Challenging Activities Activity 2 (Randomization): Add script to add a random turning angle (ranges from -10 to +10 degrees) after bouncing from the mallet.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.