programming games reflection bouncing things, memory server-side: survey. actionscript 2 examples....

22
Programming games Reflection Bouncing things, Memory Server-side: Survey. ActionScript 2 examples. Homework: Finish Video or Audio. Post proposal for your game.

Upload: amy-gibson

Post on 02-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Programming games

Reflection

Bouncing things, Memory

Server-side: Survey. ActionScript 2 examples.

Homework: Finish Video or Audio.

Post proposal for your game.

Sound volume and pan

• SoundTransform object– property of SoundChannel object that is

assigned playing of a Sound object.

• Demonstrate

• NOTE: what is done here in functions that respond to button events could be done anywhere!

ReflectionCheck out if you can think about the applications

and summarize what you/your code does (events, instances on Stage,etc.)

• coin flip: button (from Common Libraries), set up CLICK event, function uses Math.random(), makes only one of two movie clip instances visible

• rock-paper-scissors ?• Bo ?• cannonball ?• video or audio ?

Demonstrate

• Bouncing things

• Memory

• Survey– Ballot showed previously saved data on client

computer. This survey accumulates all 'votes' in one place: on the server

• Video clips in database

Bouncing Things

• .fla file has import morestuff.*• The morestuff package is a folder that contains

files for each of these classes:– Canvass– Stuff– Ball– Star– Rect

Note: Star, Ball and Rect each are subClasses of Stuff

General idea

• Creating and moving stars, circles, rectangles around involves– Code in common– Code distinct for the 3 things (types of stuff…)

• How to do this?– ANSWER: Inheritance

Ball, Star, Rect are each subclasses of the Stuff class

Common coding

• Creation– Getting information from the mouse actions to

determine width, height, direction of motion– Choosing random color

• Movement– Setting up Timer for moving

• Checking on collision with walls

Distinct coding

• Details of creation

• Note: Star and Rect rotate random amount

Ball.aspackage morestuff{

import flash.geom.*;import flash.events.*;import flash.display.*;import flash.utils.*;public class Ball extends Stuff {

//subclass has no propertiespublic function Ball(size:int, pt1:Point, pt2:Point

) {this.width = size;this.height = size;super(size,pt1,pt2);

}}

}

Memory/Concentration

• memorygame.fla

• Memory package: contains Card class

• In .fla file, card (back of card) in Library, is linked to Card class

Memory/Concentration

• Requires a pause

• Use Timer object

Server-side

• Html files and swf files are downloaded from server to client (your) computer and executed

• How to store information that lasts?• Answer: user server-side programs and

files or databases• AKA middleware• Example: php• Database: MySql

Presidential Survey

• Flash to php to file back to php back to Flash

• Uses URLRequest and URLLoader objects

ActionScript 2.0 examples• Project for this course must be ActionScript 3.0!!• But…you may get ideas from the old examples

– Origami and/or instructions in general• demonstrate

– other

• ActionScript 2.0 had code in buttons and movieclips. Must change to code in frames with use of addEventListener.

• ActionScript 2.0 had Var name for text fields. Must change to instance name with use of result.text

Coding for advance button

advbtn.addEventListener(MouseEvent.CLICK, advance);

function advance(ev) { goToAndPlay(nextframe); }

In the last frame of each animated sequence, reset nextframe variable to be the start of the next sequence:

nextframe = "Turnover";

Jigsaw

If you do this application, initial version has explicit check button. What needs to be changed to make checking automatic?

• remove check button• Remove code addEventListener setting up

event handling for the button• DO NOT remove the checkit method• Do add call to checkit to stopdragging method• Also need to make a change to mixup. Didn't

need this when checkit called from .fla file

Saving work

• Save often!!!!

• Also, need to coordinate saving – the .fla file and – publishing to produce .html and .swf file

• Flash does not do this for you!!!!!!

Location of files when creating packages

• In Publish/Settings, browse to identify folder CONTAINING the package folder

• This appears to need to be at top of drive

• The .fla file needs to be in the same drive– ????

Publish/Settings

• Create a folder at top of drive as3

• In Publish/Settings, browse to this folder– C:\as3

• In as3, create a folder called jigsaw or whatever the package name is.

• In C:\as3\jigsaw– Put the file Piece.as– General case: put files for each class.

Class names

• The convention is that class names start with a capital letter

• Consistency is required– In ActionScript and in Publish/Settings

• In this (and other things) find and replace is your friend…

Notice in Jigsaw

• Piece(s) rotate around transformation point

• The transformation point is (should be) midway horizontally and vertically even if this is not on/in the piece

Homework

Projects• Past due

– Complete your versions of rps, Bo– Complete first stage and rest of cannonball

• due next class: Video or Audio• Due 2 weeks: Original project

– (can be enhancement of sample projects. Need to change & add to programming.)

– Can be jigsaw or bouncing stuff– Can be more elaborate video or audio project

• ????

– MAKE PROPOSAL to Flash proposal moodle forum.