programming games problems. schedule various examples. homework: rps, bo (don't go back to do...
TRANSCRIPT
![Page 1: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/1.jpg)
Programming games
Problems. ScheduleVarious examples.
Homework: rps, bo (don't go back to do this), cannonball, Video or Audio
should be complete. Now propose and plan your own project.
![Page 2: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/2.jpg)
Recent problems: Names• Need to give instance name to instance of movie
clip symbol on the stage– The name of the symbol in the Library is NOT relevant.
ActionScript refers to objects on the Stage using the instance name.
– This also applies to buttons • From Common Library• Components• Programmer-made
– This also applies to text fields• Selectable (dynamic)• Editable (input)
![Page 3: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/3.jpg)
Recent problems: frame to frame
• Remember to put stop(); in the Actions panel for a frame whenever you do want to stop on that frame!
• NOTE: if there are any syntactic errors, you will see the frames being re-displayed.
• Remember to check syntactic errors using the check icon. Also, use the format icon to examine the functions, if clauses, etc.
![Page 4: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/4.jpg)
Know where your file is
Don't
• Edit a .fla file in one place (say the Desktop) and
• Have another copy in another place (say, your Documents) and have a video or audio file in that place.
![Page 5: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/5.jpg)
Schedule• (Completed) rps, bo, cannonball
– Cannonball: just hitting target or ground. Target crumbles.
• Video or Audio: one of examples OR modify rps or bouncing ball or cannonball OR ?
• Propose and then work on your own game– can be variant of 'my' games. Variant must have
enhanced coding as well as graphics• Can be enhanced version of Bo. Do something new with the
coding.
– can be something completely different…
– can ask for help
![Page 6: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/6.jpg)
Event handling
• Need to identify event• Multiple steps
– Declare object using var statement OR– Place instance on Stage, such as Button, and give
name– Define a function that will do something in response to
the event– Use addEventListener(event, functionname) OR
have definition of a function as second parameterRecall: rock paper scissors
![Page 7: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/7.jpg)
Examples• mytimer.addEventListener(TimerEvent.TIMER,moveball)• rockbtn.addEventListener(MouseEvent.CLICK, function (ev)
{ computermove("rock");} );
May need to use HELP to figure out what the event is. For example,
• playback.addEventListener(VideoEvent.COMPLETE,playagain);
![Page 8: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/8.jpg)
Run, Bo, Run
• You can download the source file
• Combination of cel animation (dog moving its legs) and computed animation (positioning bo instance like bouncing ball)
• Built up gradually, but the posted version does rotate the instance in 3D (around Y axis) to allow dog to run from right to left!
• Also a version with Sound– sound imported to frame in the symbol in the Library
where Bo starts to run.
![Page 9: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/9.jpg)
Interface
Look at examples, source code and tutorials: • coffee shop example
– Created all by code:• radio button • pull down menu
– text field (could have created this also by code but chose not to)
• Presidential preference – radio button
![Page 10: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/10.jpg)
SharedObject
• Flash's version of cookies:– small files kept on client's (player's) computer
to be used by restricted set of programs.
– Also used for behavioral marketing!!!
• One way to get persistent data: data that stays around after program finishes.
![Page 11: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/11.jpg)
navigateToURL
See examples, source
• Go to URL (probably an html file) from Flash.– options to make new window or not.
![Page 12: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/12.jpg)
Pre-loader
• Show something while the rest of a large Flash project loads– NOTE: Flash compresses content efficiently
so it really has to be big AND/OR slow communications.
• Tutorial assumes that you have created the project and 'after the fact' decided to do a pre-loader.
![Page 13: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/13.jpg)
Logic
• First frame: create a message
• Frame 5: label it "loading"• Next frame, say frame 6: check if the
whole file is loaded, if no, go back to "loading", else go to "main"
• Frame 10: label it "main", copy in original frames
![Page 14: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/14.jpg)
timeline
![Page 15: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/15.jpg)
Frame 1import jigsaw.*;
import flash.text.*;
var loadMsg:TextField = new TextField();loadMsg.text = "Loading...";loadMsg.autoSize = TextFieldAutoSize.LEFT;loadMsg.border = true;loadMsg.background = true;loadMsg.selectable = false;addChild(loadMsg);
![Page 16: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/16.jpg)
Frame after "loading" frame
if (framesLoaded == totalFrames) {
gotoAndStop("main");
} else {
gotoAndPlay("loading");
}
![Page 17: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/17.jpg)
Frame "main"
• This is the first frame of the original program, with one new line:
removeChild(loadMsg);var p1:Piece = new Piece(41.6,48.1,piece1);var p2:Piece = new Piece(101.5,48.5,piece2);…Piece.buildit();
![Page 18: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/18.jpg)
Suggestions
• You can do additional actions and/or have more graphics in frames 1 through "loading"
• Don't put in so much that that requires a loader
http://kinderspiel.us/
![Page 19: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/19.jpg)
Cannonball
Much of this is taste…
• Create a new layer, above the board, and put the ground instance in it.
• Place the target below the top of the ground.– Target will sink into ground– Ball will sink (slightly) into ground
![Page 20: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/20.jpg)
Positioning
• You can move instances with the mouse
• You can change the x and y values– In Property Panel or in Info Panel
• You can write code to change positions during run time
• Same goes for width and height
![Page 21: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/21.jpg)
Bouncing heads
• The code refers to a movie clip instance named ball.
• When you create the ball symbol in the Library (or when you edit it), you can change this to be…whatever you want– Some people like heads.
• You also can make the ball symbol a movie clip with multiple frames so it changes as it bounces in the ‘box’.
![Page 22: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/22.jpg)
Comment
• Flash provides facilities for setting up symbols, instances of which, operate more or less independently….
![Page 23: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/23.jpg)
Shooter
• demonstration
• shooter.fla file plus .as files defining a class for each of– Aa– Gun– Bar– Ground– Bomb
![Page 24: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/24.jpg)
Note
• There are multiple aa's and bomb's.
• All these are defined as MovieClips in the usual way.
• Use Linkage to associate with an external file.
• The external .as file has coding.
![Page 25: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/25.jpg)
Find places game
• Inspired by Lufthansa virtual pilot AND
• request for a game about NY CD 19
• My game has additional feature of regions as well as points
• Demonstrate– note progression of features
![Page 26: Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now](https://reader035.vdocuments.net/reader035/viewer/2022070412/5697bf711a28abf838c7e417/html5/thumbnails/26.jpg)
Classwork/homework
• Work session
• Last project is totally your choice. You can build on sample projects.