Beruflich Dokumente
Kultur Dokumente
Title: Pong Template-YOUR NAME Platform: iPhone Landscape Resolution Independence (checked)
Step 2: Go to Scenes, double-click Initial Scene, and then click + to create 1 actor.
Step 3: Rename the actor by double-clicking on the Actor 1 name. ! ! ! ! ! ! ! ! Actor 1 to Racket Player 1
Pong Template
Step 4: Double-click on Racket Player 1, look at Attributes, and change the following: ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Size/Width: ! ! ! Size/Height: !! ! Physics/Density: ! ! Physics/Friction: ! ! Physics/Bounciness:! Physics/Fixed Rotation: ! 16 120 500 3 0 Checked
Step 5: Click Create Rule, double-click Rule, rename it Down, and set the conditions. ! ! ! ! ! ! When ALL conditions are valid: Actor receives event! key ! down ! is ! down
Step 6: Drag Move behavior into the Rule and then do the following: ! ! ! ! ! Change Direction to 270
Pong Template Step 7: Click on the Down rule you made to highlight it and copy it. ! ! ! ! How to copy: Click what you want to copy so its selected. ! ! Go to Edit. ! ! Go to Copy. ! ! Go to Paste.
**You will end up with 2 Down rules that look like this.**----------------------------------->
**You will edit the bottom Down rule in the next step.**---------------------------------->
Step 9: Change the conditions to the following so it looks like the image below:
Down to Up Step 10: Under Move, change 270 to 90 to look like the image below.
Pong Template Step 11: Drag a Constrain Attribute behavior under the Up rule and do the following: Change Attribute: Racket Player 1.Position.X To: 20
Step 12: Go to Scene Editor, then drag and drop Racket Player 1 into the scene.
Step 13: Click + to create a new actor and rename it Racket Player 2.
Pong Template Step 14: Double-click on Racket Player 2, go to Attributes, and change the following: ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Size/Width: ! ! ! Size/Height: !! ! Physics/Density: ! ! Physics/Friction: ! ! Physics/Bounciness:! Physics/Fixed Rotation: ! 16 120 500 3 0 Checked
Step 15: Drag a Constrain Attribute behavior under the Up rule and do the following: Change Attribute: Racket Player 2.Position.X To: 548 (Mac) OR 460 (Windows)
Step 16: Go to Scene Editor, click + to create a new actor, and rename it Ball.
Pong Template Step 17: Double-click on Ball, go to Attributes, and change the following: ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Size/Width: ! ! ! 16 Size/Height: !! ! 16 Color: ! ! ! Red Physics/Bounciness:! 1 Physics/Fixed Rotation: ! Checked Physics/Collision Shape:! Circle
Red---------->
Step 18: Go to Scene Editor, Attributes tab, +, Boolean, and rename as P1Serving. ! ! ! ! P1Serving! Checked ! ! !
Step 19: Go to Actors tab, double-click Ball, Create Rule, and name it Ball Direction.
Step 20: Set Ball Direction rule conditions to the following: ! ! ! ! When ALL conditions are valid: Attribute! game.P1Serving! is! true
Pong Template Step 21: Drag a Change Velocity behavior into the rule and do the following: ! ! ! ! ! ! ! ! ! ! Change the direction using the Expression Editor 1. Click the small e at the right of the direction eld. 2. Click the Insert Function down arrow. 3. Select Random--you will get random(min,max) 4. For min, type in -45 and for max, type in 45 and click check (). 5. It should look like random(-45,45).
Step 22: Open Otherwise, insert a Change Velocity behavior, and do the following: ! ! ! ! ! ! ! ! ! ! Change the direction using the Expression Editor 1. Click the small e at the right of the direction eld. 2. Click the Insert Function down arrow. 3. Select Random--you will get random(min,max) 4. For min, type in 135 and for max, type in 225 and click check (). 5. It should look like random(135,225).
Pong Template Step 23: Go to Scene Editor, open Racket Player 1, and create a rule called Serving.
Step 24: Set the conditions to the following: ! ! When ALL conditions are valid: ! ! Actor receives event! key ! space ! is ! down ! ! Attribute! game.P1Serving! is! true
Step 25: Drag a Spawn Actor behavior into the Serving rule and do the following: ! ! ! ! Actor:! ! Position:! ! ! Ball 16 ! !
Step 26: Go to Scene Editor, click + to create a new actor, and rename it Walls.
Pong Template Step 27: Double-click on Walls, go to Attributes, and change the following: ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Size/Width: ! ! ! Size/Height: !! ! Physics/Density: ! ! Physics/Bounciness:! Physics/Fixed Rotation: ! Physics/Movable:! ! 568 10 500 0 Checked Unchecked
Step 28: Go to Scene Editor and place 2 walls into the scene (1 on top, 1 on bottom).
<-------Top Wall
<------Bottom Wall
Step 29: Go to Home, then Actors, and click on + to create a New Tag.
Step 31: Click the All tag and then drag and drop all 4 actors onto the Collidable tag. All tag and Collidable tag should both have 4 actors in them.--->
Step 32: Double-click Racket Player 1, add Collide behavior, and set to: ! ! Bounce when colliding with:! actor with tag ! Collidable
Step 33: Repeat Step 32 for actors: Racket Player 2, Ball, and Walls.
***ALL 4 actors should have the Collide rule now*** Step 34: Go to Scene Editor, Attributes tab, click +, pick Integer, and rename it. Change New Attribute to P1 Score.
Step 35: Click + again to add a New Attribute, then pick Integer, and rename it. ! ! ! ! Change New Attribute to P2 Score.
10
Pong Template Step 36: Click the Actors tab, create 2 new actors, and rename them. ! ! ! ! ! ! Actor 1 to Left Winning Zone Actor 2 to Right Winning Zone
Step 37: Double-click Left Winning Zone, go to Attributes, and change the following: ! ! ! ! ! ! ! ! Size/Width: ! ! ! 10 ! ! ! ! Size/Height: !! ! 320 ! ! ! ! Physics/Density: ! ! 0 ! ! ! ! Physics/Movable:! ! Unchecked
Step 38: Create a rule, name it Ball Detection, and set the conditions. ! ! When ALL conditions are valid: Actor receives event! overlaps or collides ! with ! actor of type ! ball
Step 39: Add a Change Attribute behavior to the Ball Detection rule.
11
Pong Template Step 40: Set Change Attribute behavior to the following: ! ! ! ! Change Attribute: (click ...)!! To: (click e)!! ! ! game.P2 Score game.P2 Score +1
Step 41: Go to Scene Editor, double-click Right Winning Zone, and set Attributes. ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Size/Width: ! ! Size/Height: !! Physics/Density: ! Physics/Movable:! ! ! ! ! 10 320 0 Unchecked
Step 42: Create a rule, name it Ball Detection, and set the conditions. ! ! When ALL conditions are valid: Actor receives event! overlaps or collides ! with ! actor of type ! ball
Step 43: Add a Change Attribute behavior to the Ball Detection rule.
12
Pong Template Step 44: Set Change Attribute behavior to the following. ! ! ! ! Change Attribute: (click ...)!! To: (click e)!! ! ! game.P1 Score game.P1 Score +1
Step 45: Go to Scene Editor and add the following actors to the scene: ! ! ! ! ! ! Place the Left Winning Zone actor on the LEFT of the game screen. Place the Right Winning Zone actor on the RIGHT of the game screen. Place the Racket Player 2 actor on the RIGHT side of the screen.
Step 46: Create a new actor, name it P1 Score, double-click it, and set the Attributes. Size/Width: ! ! ! Size/Height: !! ! Physics/Moveable:! ! 50 50 Unchecked
13
Pong Template Step 47: Add a Change Attribute behavior to the code space and set to the following: **No rule this time** Change Attribute: (click ...)! P1 Score.Position.X To: 259 (Mac) OR 215 (Windows)
Step 48: Add another Change Attribute behavior and set to the following: **No rule this time** ! Change Attribute: (click ...)!! P1 Score.Position.Y! ! To:! 295
Step 49: Add Display Text behavior and set to the following: ! ! ! ! ! ! ! ! ! ! ! ! Text: (click e)! Size:! ! ! Color:!! ! game.P1 Score 20 orange
Step 50: Go to Scene Editor, make an actor, rename it P2 Score, and edit Attributes. ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Size/Width: ! ! ! Size/Height: !! ! Physics/Movable:! ! 50 50 Unchecked
14
Pong Template Step 51: Add a Change Attribute behavior to the code space and set to the following: **No rule this time** Change Attribute: (click ...)! P2 Score.Position.X To:! 309 (Mac) OR 265 (Windows)
Step 52: Add another Change Attribute behavior and set to the following: **No rule this time** ! Change Attribute: (click ...)!! P2 Score.Position.Y! ! To:! 295
Step 53: Add Display Text behavior and set to the following: ! ! ! ! ! ! ! ! ! ! ! ! Text: (click e)! Size:! ! ! Color:!! ! game.P2 Score 20 orange
Step 54: Go to Scene Editor and place actors P1 Score and P2 Score onto the scene. ! ! P1 Score on left and P2 Score on right.
15
Pong Template Step 55: Double-click on Ball actor, minimize rules, create a rule, and name it Destroy.
Step 56: Change and set the 2 conditions to the following: When ANY conditions are valid: Actor receives event overlaps or collides Actor receives event overlaps or collides with with actor of type ! actor of type ! Left Winning Zone Right Winning Zone
Step 57: Add the Destroy behavior into the Destroy rule.
Step 58: Go to Scene Editor, then Left Winning Zone, and open Ball Detection rule.
16
Pong Template Step 59: Add a Change Attribute behavior into the Ball Detection rule and set it. **There should be 2 Change Attribute behaviors total** Change Attribute: (click ...) game.P1Serving To: 0
Step 60: Go to Scene Editor, then Right Winning Zone, repeat Step 59, and edit. Change Attribute: (click ...) game.P1Serving To: 1 (**change 0 to 1**)
Step 61: Go to Scene Editor, Attributes tab, click +, pick Boolean, and rename it. Change New Attribute to ActiveBall.
17
Pong Template Step 62: Go to Actors tab, Racket Player 1, and add a 3rd condition to Serving rule. ! ! ! Attribute ! game.ActiveBall ! is! false
Step 63: Add a Change Attribute behavior to the Serving rule and set to the following: Change Attribute: (click ...) game.ActiveBall To: 1
Step 64: Go to Scene Editor, Racket Player 2, create a rule, and name it Serving.
18
Pong Template Step 65: Set the Serving rules conditions to the following: ! ! ! ! Attribute ! Attribute ! game.P1Serving ! game.ActiveBall ! is! is! false false
Step 66: Add a Change Attribute behavior to the Serving rule and set to the following: Change Attribute: (click ...) game.ActiveBall To: 1
Step 67: Drag a Spawn Actor behavior into the Serving rule and do the following: ! ! ! ! Actor:! ! Position:! ! ! Ball -16 ! !
19
Pong Template Step 68: Go to Scene Editor, Ball, and open the Destroy rule.
Step 69: Add a Change Attribute behavior above the Destroy behavior and set it. Change Attribute: (click ...) game.ActiveBall To: 0
Step 70: Go to Scene Editor, Attributes tab, click +, pick Real, and name it Predict.
20
Pong Template
Step 72: Go to Actors tab, Ball, minimize all rules, create a new rule, and rename it. Name of rule: Detecting Direction for Racket Player 2
Step 73: Set the conditions to the following: When ALL conditions are valid: ! ! Attribute ! Ball.Motion.Linear.Velocity.X ! ! ! Attribute ! Ball.Position.X ! ! ! ! ! Attribute ! Ball.Position.X ! ! ! ! ! ! ! 0 240 300
Step 74: Add a Constrain Attribute behavior to the rule and set it to the following: Constrain Attribute: (click ...) game.Predict To: (click e) ball.Position.Y
21
Pong Template
Step 75: Add a Change Attribute behavior to the rule and set it to the following: Change Attribute: (click ...) game.PositionYourself To: 1
Step 76: Add another Change Attribute behavior to the rule, but in Otherwise. Change Attribute: (click ...) game.PositionYourself To: 0
Step 77: Go to Scene Editor, Racket Player 2, create a rule, and name it Movement.
22
Pong Template Step 78: Set the conditions to the following: When ALL conditions are valid: ! ! Attribute ! game.PositionYourself ! is! true
Step 79: Drag a Constrain Attribute behavior into the Movement rule and set it. Constrain Attribute:(click ...) RacketPlayer2.Position.Y To:(click e) game.Predict
Step 80: Click File, Save As, title it Pong, Save, hit Preview and youre ready to play!
23