Programming games - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Programming games

Description:

... clips, they are all running. going from frame to frame ... lessons (help with drawing) rock-paper-scissors. You can download .fla file with partial program ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 22
Provided by: Jeanin
Category:

less

Transcript and Presenter's Notes

Title: Programming games


1
Programming games
  • Flash concepts
  • Filezilla upload your project(s)
  • Homework Prepare Flash rock paper scissors
    (build on partial implementation on-line).

2
Review
  • Flash has Scene 1 (main movie) Stage and Timeline
  • Place code in specific frame using Actions panel
  • Place on Stage at specific frame
  • Movie clip symbol instances(s)
  • Button(s)
  • Graphic symbol instance(s)
  • AND place directly on Stage
  • Text fields
  • graphics (drawings)

3
Important
  • Where code and instances go is critical!
  • Movie instances and buttons and text fields must
    be named to be used (referenced) by code!
  • Generally, it is the ATTRIBUTEs of objects that
    are changed
  • head.visible, head.rotation, headcount.text
  • Beware of things inside of things.

4
OLD Flash
  • Movie clip attributes had underscore
  • head._visible
  • Code could be put in an object, including
    buttons
  • on(Release)
  • Different names for setting up events in frame
    code
  • flipbtn.onRelease flip
  • Weakly typed, like JavaScript
  • Did not have to specify datatype for variables.
    Looser on parameters to functions.

5
This class
  • We will stick to ActionScript 3.0.
  • You need to use ActionScript 3.0 for your
    project.
  • (After class, if you need help understanding and
    converting old code, I will try to help.)

6
Demonstrate
  • 'full' rock paper scissors
  • download and show partial rps (.fla file)
  • You can complete this OR start from scratch OR
    use this, but change the graphics

7
Cel animation
  • Aka frame by frame animation
  • Animation (that look of movement) achieved by
    showing different frames
  • Each hand drawn or
  • Produced by built-in tweening facility
  • in succession
  • Computer (computed) animation achieved by coding
    that moves or modifies objects.
  • Flash applications can have both!

8
Flash
  • Control goes frame to frame (and loops back)
    UNLESS your code includes something like
  • stop() or
  • goToAndPlay(framenum)
  • Code is 'in frame' or in separate .as file as
    part of a class definition
  • NOTE a function definition is not a call to
    execute (invoke, run) the function.

9
Adding frames
  • Insert/Timeline/Keyframe if you want to copy over
    material in previous frame.
  • Insert/Timeline/Blank Keyframe if you DON'T.
  • NOTE if you insert a keyframe and then go back
    and add material to earlier frame, it will NOT be
    automatically added to the following frames.

10
Fix
  • If you need to remove a frame, select frame and
    then
  • PC right click, dropdown menu giving options
  • MAC command click, dropdown menu giving options
  • Note also Edit/Undo is helpful.

11
Instances
  • The cross-hairs denotes the origin of the object.
    It is the thing corresponding to the x and y
    positions
  • X from the left
  • Y from the top
  • Rotation is around the origin
  • Your head movie clip instance rotates around this
    origin.

12
Text fields
  • Static label parts of screen
  • Dynamic can be changed by code
  • Input player can enter values
  • Dynamic and Input fields need instance names
  • To change the text of a Text field named score
    score.text " "

13
Movie Clips
  • Symbols in Library
  • Instances (copies of) are placed in frames (in
    layers) on Stage (can be 'off stage'). Instances
    are named.
  • Can position instances (and do other things!)
  • clip.x
  • clip.y
  • clip.rotation .

14
Other movie clip properties
  • clip.alpha transparency
  • clip.height
  • clip.width
  • clip.name returns name as a string
  • clip.visible
  • more

15
Movie clip methods
  • target.stop()
  • target.goToAndPlay(fn)
  • target.hitTestPoint(ball.x,ball.y,true)
  • Returns true if the point is on material in the
    target
  • wall.hitTestObject(thing)
  • Returns true if a bounding rectangle around thing
    overlaps a bounding rectangle around wall.
  • Note there are also global functions stop() and
    goToAndPlay(). These apply to the current movie
    clip.

16
Multiple movie clips
  • If there are multiple movie clips, they are all
    running
  • going from frame to frame
  • UNLESS stop() is used.

17
Recommendation
  • Work on logic, then build up the graphics and
    interaction
  • Rock paper scissors
  • create the 3 buttons, write logic, display
    results in Dynamic Text fields
  • THEN add graphical display

18
Buttons
  • Coinflip used button from library
  • changed text
  • Rock paper scissors made our own buttons
  • Lesson make your own only when it is necessary.

19
Random effects
  • Also called pseudo-random, stochastic,
    probabilistic
  • SAME AS JAVASCRIPT
  • Math.random() is a method of the Math object that
    produces a fraction from zero to less than one.

20
Flash
  • For development, the Flash file is .fla
  • For distribution, you publish your project. This
    produces an .html file and a .swf file, both of
    which need to be uploaded.
  • Jigsaw will make user of .as files
  • Bouncing things, shooter, others, also make use
    of .as files
  • more complex projects make use of (external)
    sound, image and movie clips. None of ours will.

21
Homework
  • Finish and show coin toss with rotation and with
    counts.
  • Work on Flash
  • lessons (help with drawing)
  • rock-paper-scissors
  • You can download .fla file with partial program
Write a Comment
User Comments (0)
About PowerShow.com