Programming games Demonstrate cannonball

Slides:



Advertisements
Similar presentations
1What is the Stage. 2How do you open a panel in Flash
Advertisements

IS660Z Programming Games Using Visual Basic Overview of Cannonball.
Visual Basic: ballistics
 2004 Prentice Hall, Inc. All rights reserved. Chapter 18 – Macromedia Flash MX 2004: Building an Interactive Game Outline 18.1 Introduction 18.2 Object-Oriented.
Motion in Two Dimensions
1 Flash Actionscript Event Handling. 2 Event Handling Right now we know all about variables lets go back to our text input/output example: Suppose we.
1 Flash Actionscript Animation. 2 Introduction to Sprites We will now look at implementing Sprites in Flash. We should know enough after this to create.
1 Flash Actionscript Adding Interactive Actions. 2 ActionScript 3.0 ActionScript is the language you use to add interactivity to Flash applications, whether.
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
MovieClips & Properties Flash ActionScript Introduction to Thomas Lövgren
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Animations Flash ActionScript Introduction to Thomas Lövgren
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
Programming games Flash drawing trick(s). Rock paper scissors. Classwork: Complete rock paper scissors.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
Introduction to Flash FYS100 Creative Discovery in Digital Art Forms Spring 2007 Burg.
Lehigh University Introduction to Flash MX Sharmeen Mecklai.
Tutorial 5 Making a Document Interactive. XP Objectives Explore the different button states Add a button from the Button library Create a button Learn.
Tutorial 5 Making a Document Interactive. XP Objectives Explore the different button states Add a button from the Buttons library Edit a button instance.
Enhancing JavaScript Using Application Programming Interfaces (APIs)
Programming games Another sound example General review Homework: [finish project], look over study guide.
Publishing a Macromedia Flash Movie – Lesson 131 Publishing a Macromedia Flash Movie Lesson 13.
 2008 Pearson Education, Inc. All rights reserved Adobe ® Flash ® CS3: Building an Interactive Game.
Programming Games Simulated ballistic motion: cannon ball. Classwork: Final day for midterm project and all projects for first part of class. Homework:
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 8 "The games of a people reveal.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 8 "The games of a.
CSC 361/661 Digital Media Spring 2010 Professor Burg.
Getting a handle on ActionScript A basic primer for non-programmers.
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
Programming games Flash drawing trick(s). Past due: Your completion of rock-paper-scissors) Classwork: Bouncing ball: read tutorial. Start coding.
Programming games Reflection Bouncing things, Memory Server-side: Survey. ActionScript 2 examples. Homework: Finish Video or Audio. Post proposal for your.
Programming games Show your version of Bo the dog. Start cannonball Preview: video, audio work session (cannonball) Homework: Cannonball with ball in a.
Kinematics in 2-D Concept Map
Programming games Registration experiment. Drawing. Equations of motion. Odds and ends. First phase of cannonball due. Preview video, audio. Homework:
CSC 361/661 Digital Media Spring 2010 Professor Burg.
Programming Games Preview Video & Audio. Work on cannonball. Homework: finish cannonball!
Introduction to Flash Animation CS 318. Topics Introduction to Flash and animation The Flash development environment Creating Flash animations  Layers.
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. Homework: Finish.
Game Maker Terminology
Projectile Motion The motion of an object that is thrown and moves along a curved path through the influence of gravity, only.
Introduction to Flash CSC361/661 Digital Media Spring 2007 Burg.
Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now.
[My] Experiences building games in Visual Basic & Flash Focus on 'cannonball' Jeanine Meyer Math Senior Seminar.
Programming games Cannonball due. Drawing & printing example. Acquiring video or sound Homework: Catch up: complete projects (rps, Bo, cb). Start video.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
1 A Basic Introduction to Flash. Outline What is a flash? Macromedia Flash MX 2004 Flash concepts Flash Demos Conclusion Additional help 2.
Programming Games Show your rock-paper-scissors. Demonstrate bouncing ball. Demonstrate and examine Bo the dog. Homework: Modify Bo to make your own.
Projectiles at an Angle Hardest thing yet.. A progression: A)Freefall Review: A ball drops for 3 s. How far does it fall? How fast is it going after 3.
Programming games Flash concepts. Coin toss. Filezilla: upload your project(s) Homework: Enjoy Spring Break.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
Programming Games Reprise: radio buttons. Creating instances at runtime. Buttons. Present your sound or video. Final project assignment. Homework: [Catch.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
CDM105 Session 12 Macromedia FLASH MX 2004 Part 5 : Sounds, publishing your movies, and the ‘Get URL’ action.
FINAL EXAM REVIEW 2015 Computer Game Design. 1 A. What is a.fla file?.swf file? B. Action Script is an example of what type of programming language? C.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
The Unit Circle. Right now… Get a scissors, and one copy of each circle (blue, green, yellow, white). Sit down and take everything BUT that stuff & your.
Adding Buttons, Actions, and Sounds
Flash Interface, Commands and Functions
Projectile Motion Everyday applications Vector additions
Flash animation For beginners.
Aim: How do we solve complicated projectile motion problems?
Bellringer What is the difference between the words vertical and horizontal? What does the word projectile mean? How is one dimensional (1D), two dimensional.
Flash & ActionScript Syntax is similar to JavaScript
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
Working with Symbols and Interactivity
Aim: How do we solve complicated projectile motion problems?
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on animation project. Homework: Finish.
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
Flash Demonstration – Unit 5 – ActionScript 3.0
Presentation transcript:

Programming games Demonstrate cannonball Homework: (bouncing ball due today) Cannonball Phase 1 due next week. Complete cannonball due following week.

Text fields Static: does not change Dynamic: can be changed by code Requires an instance name Input: can be changed by code OR by the player

Event handling Setting up Flash to listen for an event and do something when it occurs. Examples: flipbtn.addEventListener (MouseEvent.CLICK,flip); rockbtn.addEventListener (MouseEvent.CLICK, function(ev) { computerturn("rock");} );

Event handling other mouse events mybtn.addEventListener (MouseEvent.MOUSE_DOWN,showpic);

Event example for timing mytimer.addEventListener (TimerEvent.TIMER,moveball); Note: you need to have var mytimer:Timer = new Timer(50); And also mytimer.start();

Event example for video cam.addEventListener (ActivityEvent.ACTIVITY,activityHandler); Note: this needed prior coding to set up cam cam = Camera.getCamera(); cam.setMotionLevel(75,3000); See tutorial, examples on my site

Event handling Requires creating something by moving to Stage and naming buttons or other instances OR By creating things (using new term) in code Registering the event listener objectname.addEventListener (name of event , function to be called)

General comments In ALL programming, 'things' need to be named in order to manipulate them. In Flash, this means For dynamic and input text fields, you need to put a name into the Var field in the Properties panel For movie clips (such as the ball for bouncing ball), you need to put a name into the instance field. Flash 8 & 9: give instance name and use .text property

Passing of time: JavaScript The passing of time was handled/signaled using the setInterval(code, interval_length) sets up repeated events setTimeout(code, timed_amount) sets up one event

Passing of time: Flash One way: use frames Default 12 frames/second Cel animation uses this. Bouncing ball used Timer object. Also use this for cannonball

Reflect on Bouncing ball Computed animation Timer object, TimerEvent.TIMER registered (using addEventListener) to moveball mytimer.addEventListener (TimerEvent.TIMER, moveball); moveball(ev) ... Moved ball in straight line

Bo the dog [Look at source file]. The movie clip symbol uses cel animation (aka frame by frame animation) to show movement of legs. first frame: Bo sitting. Later frame, starting with frame with label shows movement. This is like rock-paper-scissors! The movie clip instance on the Stage is moved around much like the bouncing ball: computed animation. Note: no walls. Bo goes off on top/bottom/either side and then reappears.

Cannonball Example of ballistics aka projectile motion Simulation of effects of gravity Make the vertical displacements change! Horizontal displacements remain the same No wind resistance Initial vertical and horizontal motion calculated from angle of cannon

Cannonball (Flash) Interface angle of cannon specified, (not separate horizontal and vertical velocities) Requires the code to use trig functions to 'resolve' the vectors. This means calculate vertical and horizontal components from the (initial) velocity out of the cannon. Possible outcomes Hit ground Hit target: target crumples: Achieved by cel animation in the movie clip symbol for the target

Cannonball: collisions Collisions must be detected by coding! There are no ball, ground, target. I use target.hitTestPoint, a method that checks if the point (x,y) occupies the same position as any material of the target There also is hitTestObject, which compares bounding boxes I use if (ball.y > ground.y) for the check for hitting (reaching…going beyond) the ground Be sure that the origin/registration point for the ground is on the ground, not way above it!

Crumbling Target Instance of movie clip defined/added to Library Frame 1 shows original target. Actions panel has stop(); When target is determined to be hit in the Actions panel of Scene 1: target.goToAndPlay(2); Target Last frame has stop();

Reflection Mixture of computed and cel (frame by frame) animation Computed animation similar to bouncing ball Cel animation (in target movie not main movie) similar to rock-paper-scissors

More on angles Your code will rotate the cannon movie instance to 'be' the angle specified. Your code determines the (initial) horizontal movement and the (initial) vertical movement. The code does not check for a bad angle, meaning one 90 degrees or more. Opportunity for improvement

Angles Standard definition of angles is 360 degrees to a circle. This is what the player is shown Initial setting is 45 degrees. Most computer packages use radians, not degrees. Radians are an intrinsic measure. Take the radius of the circle and lay it around the circumference.

Radians

Radians Wrap a radius length around the circle. This defines an angle

Conversion See tutorial for this code. Built-in Math methods for trig functions. If you 'know' R and angle A P = R * Math.sin(A) M = R * Math.cos(A) R P A M

Animation Timer object, set up similar to Bouncing Ball The moveball function (for the final phase of cannonball) makes checks for the ground and the target I stress similarities so you can make use of concepts in your own work.

Animation … done by re-positioning ball based on calculation done with ActionScript. NOT by making new drawings in each frame.

Graphics (material) Can be 'off stage' For example, cannonball is positioned at mouth of cannon when FIRE button is released.

Homework Bouncing ball due today Start of Cannonball due next week. Just get the ball going in an arc first. Then create crumbling target and put checking for hitting in the code. Complete cannonball due following week. NOTE: this division of the project is done to teach you to plan and do this with your own projects!