MULT 110 Basic Game Programming I - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

MULT 110 Basic Game Programming I

Description:

trace ('POW!'); case 3: trace ('BOOM!'); default: trace ('Default message' ... trace ('POW!'); break; case 3: trace ('BOOM!'); Use break; to jump out of ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 12
Provided by: ess7
Category:
Tags: mult | basic | boom | game | pow | programming

less

Transcript and Presenter's Notes

Title: MULT 110 Basic Game Programming I


1
MULT 110Basic Game Programming I
  • Conditionals

2
Last Class
  • Variables
  • Expressions
  • Operators
  • Kinds?
  • Increment and decrement?
  • Assignment vs. equivalence?
  • Comments
  • Why?
  • Single line vs. multi-line?

3
Branching
  • The very nature of interaction is branching from
    the straight and narrow path the timeline.
  • Under one condition you may take one path and
    under another condition you may take another
    path.
  • Branching and conditional execution are the same
    thing.

4
If Statement
  • if (expression)
  • statement 1
  • statement 2
  • The expression must be something that can be
    judged true or false.
  • If the expression is true, then all the
    statements between and are executed.
  • If the expression is false, the statements inside
    the curly braces are not executed.

Statements lt Conditions / Loops lt If
5
Expressions
  • Each of these is an expression
  • 7 gt 10
  • 6 2 3
  • GameOver
  • true is a keyword in ActionScript
  • Its value is 1
  • false is a keyword in ActionScript
  • Its value is 0

6
Examples of Conditionals
  • if (playerNum computerNum)
  • playerWins
  • output Hooray!! Player wins!
  • The above statement provides for only one
    condition the numbers match

7
Examples of Conditionals
  • if (playerNum computerNum)
  • playerWins
  • output Hooray!! Player wins!
  • else
  • output Sorry. The computer wins.
  • This statement provides for two conditions
    numbers match and numbers do not match.

8
Switch Statement
  • switch (expression)
  • case (value)
  • actions
  • case (value)
  • more actions
  • default
  • actions executed if none of above
  • Here you can have many values for the expression.

9
Switch Statement
  • on (release)
  • audioClip Math.floor(Math.random() 4)
  • switch (audioClip)
  • case 0
  • trace ("BIFF!")
  • case 1
  • trace ("BAM!")
  • case 2
  • trace ("POW!")
  • case 3
  • trace ("BOOM!")
  • default
  • trace (Default message)
  • Test this statement on a button.

10
Switch Statement
  • on (release)
  • audioClip Math.floor(Math.random() 4)
  • switch (audioClip)
  • case 0
  • trace ("BIFF!")
  • break
  • case 1
  • trace ("BAM!")
  • break
  • case 2
  • trace ("POW!")
  • break
  • case 3
  • trace ("BOOM!")

Use break to jump out of cascade through the
switch statement.
11
Lab Assignment
  • Create a commented Flash movie that provides
    buttons for the user to
  • Move an object left, right, up, down and to the
    center of the screen and have the object wrap
    when it reaches the edge of the screen
  • Scale an object larger / smaller
  • Rotate an object clockwise in 45 degree
    increments
  • Name the movie buttonanimation.fla publish it
    and post the .htm and .swf to your UNIX account.
Write a Comment
User Comments (0)
About PowerShow.com