02 – Expanding Your Game

02 | Expanding Your Game
James Quick | Technical Evangelist
Shahed Chowdhuri | Senior Technical Evangelist
DEMO
Golden Ball
Module Overview
• Hands on Demo (Golden Ball)
– More Behaviors
– Functions
– Adding Additional Layouts
– Permanent Storage
– Image Frames/ Animations
– Adding a Mute Button
So…What’s the Game?
• Platform Game with Turrets
– Collect as many Golden Balls in 30 seconds as possible
• Objects,
– Player, platform, tiled backgrounds, turret, bullet, text, touch
More Behaviors
More Behaviors
• Player
– Platform, wrap
• Platform
– Jumpthru, Physics, Sine
• Turret
– Turret
• Ball
– Physics
Functions
Functions
• “Using functions can help you organize events and
avoid having to duplicate groups of actions or
events.”
• Reusable logic
– Are you repeating the same events->actions?
– Ex. Multiple ways to lose
• For you programmers out there…
– Has parameters and return values
– Can do nesting and recursion
Additional Layouts
Additional Layouts
• Want a home screen? An about
Page? Want extra levels?
– Add a new layout
• Basic Idea
– 4 layouts
• Home, game, end, and about
• 2 options with Event Sheets
– Add a new one
– Reuse an existing one
Additional Layouts (cont.)
• Home
– Button to Game and About
• Game
– Lose game and go to End
• End
– Button to Home or Game (restart)
• About
– Button to Home and links to website, feedback, social media, etc.
Permanent Storage
Permanent Storage
• WebStorage Object
– “The WebStorage object can store data locally on the user's computer
between sessions.”
– “The WebStorage object allows data to be stored in two
places: Local storage and Session storage”
• Local storage is permanent (until the user clears their cache). If the user comes
back the next day, local storage still has the saved data
• Session storage only lasts with the current browser session. If the user comes
back the next day, session storage is empty again
Permanent Storage (cont.)
• Usage
– High scores, achievements, current level, etc.
• How does it work?
– Key/value pairs similar to dictionary
• Basic Idea
– Check to see if a given key exists
– If not… create it
– If so…use it
Image Frames/Animations
Image Frames/Animations
• No 3D… but animation is
possible!
– Think of a flipbook
– Animation frames
• Cycle through frames or
choose individual frames
• Simple example
– Flip the player depending
on the direction he is
facing
Adding a Mute Button
Adding a Mute Button
• Music/ Sound Effects are nice…most of the time
– Give the user an option to mute the game
• Basic Idea
– Add Mute text/button to start page
– Created global variable “Muted”
• 0 = not muted
• 1 = muted
Finished Example
• Golden Ball
– Windows 8 - http://bit.ly/W8GoldenBall
– Windows Phone - http://bit.ly/WP8GoldenBall