1 / 16

Extending the Pong Example

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.

reid
Download Presentation

Extending the Pong Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Extending the Pong Example Barb Ericson Georgia Tech June 2011

  2. 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

  3. 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.

  4. 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

  5. Open the Pong game • Click on File then Open • Select Examples and games and open 4 Pong

  6. Create a variable • Click on "Variables" and then on "Make a variable" • Name the variable score • Click "OK"

  7. 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

  8. Start Score at 0 • Drag "set score to 0" from "Variables" category after the "go to x: 13 y:157"

  9. Increment Score • When the paddle hits the ball • Drag "change score by 1" from "Variables" • Drop before "move 5 steps"

  10. 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

  11. Hide text sprites • Select sprite under stage view • Select Scripts tab • Drag out "when green flag clicked" from "Control" • Drag out "hide" from "Looks"

  12. 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

  13. Show text sprite • When the "You Lost!" text sprite receives the message "lost" • Show the sprite

  14. 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

  15. 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

  16. 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

More Related