16
Extending the Pong Extending the Pong Example Example Barb Ericson Barb Ericson Georgia Tech Georgia Tech June 2011 June 2011

Extending the Pong Example

  • Upload
    reid

  • View
    27

  • Download
    3

Embed Size (px)

DESCRIPTION

Extending the Pong Example. Barb Ericson Georgia Tech June 2011. Goals. Learn about Creating a variable to keep score Displaying text to let the user know if s/he won or lost Using broadcast and receive to allow sprites to communicate. Project Description. - PowerPoint PPT Presentation

Citation preview

Page 1: Extending the Pong Example

Extending the Pong Extending the Pong ExampleExample

Extending the Pong Extending the Pong ExampleExample

Barb EricsonBarb EricsonGeorgia TechGeorgia Tech

June 2011June 2011

Page 2: Extending the Pong Example

Goals• Learn about

– Creating a variable to keep score – Displaying text to let the user know if s/he

won or lost– Using broadcast and receive to allow

sprites to communicate

Page 3: Extending the Pong Example

Project Description• We will add to the example in Games – 4 Pong to

add a score that is displayed and tell you if you won or lost.

Page 4: Extending the Pong Example

Big Picture• Open the pong

game example• Create a variable

to keep score• Create new text

sprites to tell you if you won or lost

• Use broadcast and receive to allow sprites to communicate

Page 5: Extending the Pong Example

Open the Pong game • Click on File

then Open • Select

Examples and games and open 4 Pong

Page 6: Extending the Pong Example

Create a variable• Click on

"Variables" and then on "Make a variable"

• Name the variable score– Click "OK"

Page 7: Extending the Pong Example

Variable Tiles• When you create a new

variable a set of 5 tiles are created– First controls the display of

the variable• Uncheck to not display

– Second sets the value of the variable

– Third changes the value – Fourth shows the value– Fifth hides the value

Page 8: Extending the Pong Example

Start Score at 0• Drag "set score

to 0" from "Variables" category after the "go to x: 13 y:157"

Page 9: Extending the Pong Example

Increment Score• When the paddle

hits the ball– Drag "change

score by 1" from "Variables"

– Drop before "move 5 steps"

Page 10: Extending the Pong Example

Draw text sprites• Use the paint

editor to paint text sprites

• Select T for text– Select font type

and size– Select color– Type the text

Page 11: Extending the Pong Example

Hide text sprites • Select sprite

under stage view – Select Scripts tab– Drag out "when

green flag clicked" from "Control"

– Drag out "hide" from "Looks"

Page 12: Extending the Pong Example

Broadcast when lost• Two sprites can

communicate using broadcast and receive– Have the ball

broadcast the message "lost"

– Click the down arrow to create a new message

Page 13: Extending the Pong Example

Show text sprite• When the "You

Lost!" text sprite receives the message "lost"– Show the sprite

Page 14: Extending the Pong Example

Add a way to win• When the score

equals 5 tell the user s/he won– And show "You

Won!" sprite– Stop execution

of all scripts

Page 15: Extending the Pong Example

Challenges• Make the ball speed up over time

– Add another variable named speed – Move by speed each time you hit the

ball with the paddle

• Play a sound when you lose or win• Try to create two player game with

two paddles

Page 16: Extending the Pong Example

Concept Summary• Variables

– Can be displayed– Can be set to a value– The value can be changed

• Incremented or decremented

• You can create text sprites– That you hide when the game starts

• Two sprites can communicate using broadcast and receive