Programming games - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Programming games

Description:

Input text fields can be changed by the player AND by code. ... Can use Adobe Flash Media Encoder to take one type of video and produce an flv. Basic coding ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 21
Provided by: Jeanin
Category:

less

Transcript and Presenter's Notes

Title: Programming games


1
Programming games
  • Programmer vs player. Tweening
  • Review, hints cannonball
  • Preview video
  • work session (cannonball)
  • Homework Cannonball with ball in a parabolic arc
  • Next project Video

2
Programmer versus player
  • Programmer (creator/developer) users Flash to
    create (build) an application.
  • Player is the name I give to the end-user of our
    applications.
  • Programmer uses the Flash environment to build an
    application, including coding, drawing, etc.

3
Text fields
  • Text fields are created by the programmer and
    given initial values.
  • Static text fields do not change during runtime
  • Dynamic text fields can be changed by code
    (written by the programmer) during run time.
  • Input text fields can be changed by the player
    AND by code. Presumably, code (written by the
    programmer) reads/examines the input text fields
    changed by the player.

4
Animation
  • Is created by displaying sequences of pictures so
    that our eyes see movement.
  • Cel animation (aka frame by frame) is a sequence
    of distinct frames. The programmer creates the
    distinct frames.
  • Computed animation is generated by code changing
    what is on the screen. This could be moving
    things around, changing shape, color, visibility,
    alpha, etc.

5
Tweening
  • Flash provides a quick (quicker) way of producing
    the sequence of frames for cel (frame by frame)
    animation.
  • Motion tweening specifying a movie clip instance
    or a shape moving along a path
  • Shape tweening specifying a first and last shape
  • This is still called frame by frame animation.
    The computer helps out during creation time.

6
Common problems
  • Not naming things correctly (consistently)
  • You can use your own names, but most be
    consistent
  • In Bouncing Ball NOT using a button Component.
    This is different from buttons in the Common
    Library
  • In cannonball not putting stop() in the first
    and last frame of the target symbol.
  • In cannonball, mainly, but also bouncing ball
    pay attention to the origin (cross-hairs)

7
Hitting walls
  • Angle of incidence equals angle of reflection
  • Because the walls are horizontal and vertical,
    this means the change is pretty simple
  • Hitting horizontal wall causes the vertical
    component to change sign
  • Hitting vertical wall causes the horizontal
    component to change sign

8
Change walls?
  • Need to use transformation
  • Use .rotation to determine angle
  • Construct matrix
  • See me!

9
Overview cannonball
  • 1 frame
  • target symbol has several frames
  • 3 layers for organization
  • May use additional layers for graphical effects
  • 5 symbols in Library
  • ball movie clip
  • ground movie clip
  • cannon movie clip
  • target movie clip
  • fire button
  • Instances of those 5 symbols on the Stage (all
    named)
  • Two input text fields and two static text fields

10
(No Transcript)
11
ActionScript
  • Main movie, actions layer
  • Global variables, includingTimer object,
  • register listeners for Timer event and fire
    button event,
  • Function for starting the cannon ball flight
  • Function for Timer event that advances the
    cannonball
  • Later add code to check for collisions
  • target symbol initial design 1 frame
  • Later design add frames and stop() in first
    frame and last frame

12
Cannonball
  • Phase 1 get arc working
  • Phase 2 add checks, add frames to target
  • Target crumbles
  • Target movie clip has cel animation
  • After hit, goes on to frame 2 and subsequent
    frames.

13
Advice/Warnings
  • Put all the material in the board layer of the
    first frame.
  • Give everything an instance name.
  • Add layer for the interface elements text field
    and buttons
  • Input text fields need the INSTANCE name.
  • Add layer for actions
  • If you want target to sink into (behind) ground,
    you make make a new layer and move (cut and paste
    in place) ground instance to it.

14
Advice
  • The firecannon code positions the ball. If your
    cannon is different than mine, you may need to
    modify this part of the code.
  • The hitTestPoint is done material in the target
    clip versus balls x and y position.
  • Make sure this is in the center
  • The check for reaching the ground is done in
    terms of the ground's origin
  • Make sure this is on the ground!

15
CB issues
  • You need 4 text boxes!! The static text field
    label with the word speed The input text field
    holding the speedThe static text field label
    with the word angle or degrees The input text
    field holding the desired angle in degrees
  • NOTE the application starts with values in speed
    and anglein

16
CB issues
  • The default for Flash is to go frame to frame
    so.
  • For the crumbling target you need to put stop()
    in the first frame and the last frame

17
Video in Flash
  • More than one way to incorporate video into Flash
    (e.g., bring in whole video that plays along with
    the frames)
  • The way described here uses a FLVPlayback object
  • Requires an import statement
  • This allows shorthand names for built-in parts of
    ActionScript
  • Requires statement adding to Display list
  • Objects created in code (as opposed to put
    directly on the Stage) need to be added to the
    Display list to be shown.

18
Videos
  • Different types of videos (like different types
    of images)
  • Flash video playback requires videos of type .flv
  • Can use Adobe Flash Media Encoder to take one
    type of video and produce an flv

19
Basic coding
  • import fl.video.
  • var flvFLVPlayback
  • flv new FLVPlayback()
  • flv.source "dickey2.flv"
  • flv.x 10
  • flv.y 10
  • addChild(flv)

20
Homework
  • Cannonball phases. GET first phase working BEFORE
    GOING ON.
  • Note testing the program means to test when the
    ball hits the target and when it does not hit the
    target. You also should include going all the way
    over the target.
  • Video
  • read tutorials
  • acquire videos
Write a Comment
User Comments (0)
About PowerShow.com