Programming games Another sound example General review Homework: [finish project], look over study guide.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

IS660Z Programming Games Using Visual Basic Overview of Cannonball.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
 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.
App Inventor Barb Ericson July 3, 2013.
Introducing ActionScript 3.0 Object-oriented programming language Used to power Flash Player Similar to JavaScript Can be embedded in a Flash project.
Flash Workshop Flash Workshop :: Agenda  Introductions  Look at a few Flash Examples  Flash Web Sites  Flash Web Applications  Flash Games.
1 Flash Actionscript Adding Interactive Actions Variables.
Kapi’olani Community College Art 258 Interface Programming II In-class Presentation Week 5A.
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
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.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
BUILDING RICH MEDIA ELEMENTS. Design Decisions Based on Design Specification  Following the design specification will ensure that the application is.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
1 SEG3120 Analysis and Design for User Interfaces Flash Anis Zarrad Parallel Simulations and Distributed Systems (PARADISE) Research Laboratory SITE, University.
© 2011 Delmar, Cengage Learning Chapter 9 Introduction to ActionScript 3.0.
Visual Basic Games: Prepare for Hangman
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Programming Games Simulated ballistic motion: cannon ball. Classwork: Final day for midterm project and all projects for first part of class. Homework:
CHAPTER TEN AUTHORING.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
By the end of this session you should be able to...
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.
CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Final Review Lecture 14.
Programming games Show your version of Bo the dog. Start cannonball Preview: video, audio work session (cannonball) Homework: Cannonball with ball in a.
7-1 OBJ Copyright 2003, Paradigm Publishing Inc. Using ActionScript and Creating Templates Macromedia Flash Design & Application.
More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg.
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!
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script "The games of a people reveal.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
Creating Databases applications for the Web Basic HTML review, forms Preview: Server side vs client side Flash HW: Review HTML forms and FLASH examples.
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.
Programming games Show shaking screen, quiz show. Calculations Homework: (Finish basic Javascript Projects) Make proposal. Work on project.
Scripting and Interactivity 이병희
Introduction to Flash CSC361/661 Digital Media Spring 2007 Burg.
JavaScript, Fourth Edition
Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now.
Reading Flash. Training target: Read the following reading materials and use the reading skills mentioned in the passages above. You may also choose some.
© 2011 Delmar, Cengage Learning Chapter 10 Using ActionScript to Enhance User Experience.
Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.
Programming games Cannonball due. Drawing & printing example. Acquiring video or sound Homework: Catch up: complete projects (rps, Bo, cb). Start video.
Intermediate 2 Computing Unit 2 - Software Development.
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.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Review of Previous Classes Declaring Variables - var myVar:DataType = value Data Types – Number, uint, String, Boolean Functions – parameters, return.
Creating Web Documents: JavaScript Ftp / file management: review Introduction to JavaScript Sources Homework: start review for midterm, work on Project.
CIS 205—Web Design & Development Flash Chapter 3 Appendix on Using Buttons.
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.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
XP Tutorial 8 Adding Interactivity with ActionScript.
Creating interfaces Multi-language example Definition of computer information system VoiceXML example Project proposal presentations Homework: Post proposal,
Computer Science I More class examples. Paths. Jigsaw. Tolerance. Classwork/homework: Your class project. Post proposal for midterm project.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script "The games of a people.
Interface Programming 2 Week 1
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
Programming games Demonstrate cannonball
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on animation project. Homework: Finish.
Presentation transcript:

Programming games Another sound example General review Homework: [finish project], look over study guide

Files Giving your user a way to download a file I did this by adding on to the playing sound file example. IT CAN BE ANY FILE! Need to test this on the server, but you can look at the source code (the.fla file) I did NOT put in code to monitor the process and report back errors!!!

from the code var downloadURL:URLRequest; var fileName:String = lastplayed; var file:FileReference; downloadURL = new URLRequest(); downloadURL.url = lastplayed; file = new FileReference(); file.download(downloadURL, fileName);

Jargon There IS jargon in computing. It pays to learn it. The jargon is [mostly] English words with somewhat more specific meaning. Examples: –Event & event handling –Function –Variable –Instance

Comment Much of jargon is common to other computer languages You have seen similarities in syntax between JavaScript and ActionScript Note: ActionScript 3.0 actually is MORE like Java than JavaScript –Strong-typing –import

Building an application Planning Design Choosing technologies –This is NOT part of most college courses, but may be something you will need to do –Most projects are part of / relate to other projects Implementation Testing Refinement Distribute / deliver / install This is called the waterfall model. Real process may not be so neat. Constant iteration.

More… Most projects are team projects But…don't specialize / limit what you want to learn & practice Most of my other courses feature team work. –Last Fall, maybe Fall 2011: Creating Databases for Web Applications –Now: Robotics: Spring 2010 –Creating User Interfaces: Spring 2011 Note: Computability: Fall 2010

Creating games: general Prepare 'board' –static material –dynamic material things that move things that change Define (internal) information –variables strings, numbers, booleans. arrays objects (properties and methods) Implement player moves & other action –identify/define events and program event handlers include random (stochastic) elements –implement logic of game

Creating games: Flash Prepare board Prepare symbols –graphics –instances –buttons Prepare stage –move instances of symbols & components to stage this may be 'off-stage', to be re-positioned by code –draw directly on stage (including moving graphic symbols to stage) –text fields on stage static, dynamic, input

Creating games: Flash Define (internal) information variables –global variables: defined outside of functions, in main movie and –local variables: variables defined in functions –variables in instances programmer defined. See next. –Datatypes: strings, numbers, booleans –Composite types: arrays, objects

Creating Games: Flash Determine built-in classes (coding) to be used –For example: playback of video Determine what classes YOU have written previously can be re-used –Piece.as can be used for any jigsaw! Determine what new classes are to be defined –External.as file(s)

Instances Built-in attributes aka built-in properties ball.x, ball.y target.rotation globe.alpha block.width block.height others ActionScript 3.0. drops the underscore _ you will see in old Flash examples.

Creating games: Flash Implement player moves and other actions ActionScript in frames ActionScript for instances –onclipEvent –on(release) ActionScript may also be in frames of movie clip symbols brought into main movie –Target in cannonball had stop() –Other? "depreciated". Should use procedural/frame code to set up event handling

There will be another version of ActionScript Basic concepts the same! –Functions, naming, logic, variables. –Event handling Use Help –May need to be on-line

Creating games logic ActionScript closely resembles other languages statements –assignment –if (condition) { } –if (condition) { } else { } –for (initialization;condition; increment) { } –switch

Logic: object view (If you study OOPL, such as Java) Logic sometimes is implemented more-or-less implicitly. In objects (movie clip instances are objects), the programmer can define methods each different types (sub classes) so the 'if' is done by which method. Example: –Method to calculate power done one way for super hero, another way for mortal. –Shipping cost: free for preferred customer, a calculation for regular customer.

Random aka pseudo-random because the random values are produced by a well-defined procedure. They appear random. Math.random() produces a number (fraction) from zero up to but not including 1. Math.floor(Math.random()* 6) produces one of 0,1,2,3,4,5

Functions Functions are ways to package code to be used (and re-used) Function definitions specify name and parameters. Variables defined (var statement) within the function cannot be accessed outside the function.

Definitions Remember: questions about function, variable, array refer to technical meaning (programming jargon) NOT the English meaning of the term. A function in programming is a construct that sets up a sequence of statements, along with definition of parameters. The coding for function definition is function fn (parameter name(s)) { code} coding for a call to a function uses its name followed by ( the parameter(s)) and closing )

Definitions, continued A variable in programming is associating a name with a value. The value can change! Using the name will return the current value. An array in programming is a particular type of value, namely a set of values. The common form of array is a sequence of values. To get the individual values, you write code with arrayname[indexvalue]

Notation Programming uses a variety of symbols ( and ) are used to –control order of evaluation: a*(b+c) –hold the parameters in a function definition –hold the parameters in a function call –hold the condition in an if statement –hold the condition in a while statement or switch statement –hold the set up values for a for loop

Notation, cont. { and } are used –hold the body of the function in a function definition –hold the if true clause and the else clause –hold the clause in a while or for loop –hold the clause in a for loop [ and ] are used –setting up arrays, as in var ma = []; –indexing arrays

Timing For internal calculations and for display Use playing of frames (standard is 12 fps) Use Timer object –See bouncing ball, bouncing stuff, cannonball, shooter

Flash issues Main movie and movie clip instances each loop from frame to frame in main movie AND each movie clip instances unless there are stop(); or gotoAndPlay() statements Functions and variables (outside of functions) are accessible by name of movie instance. –suggestion: put all functions and main movie variables in first frame, actions layer. Material on stage in a frame (and in a layer) –layers are defined to layer graphical material –organize actionscript, graphics, frame labels

Flash possibilities For games, more likely to have fewer frames, more movement by program control –Remember: cel animation vs computed animation Applications may use both! Game/application can contain many movie clip instances –Use frame code or code in external.as files to create objects Need to addDisplay –movie clip symbols may be simple or complex (for example, multi-frame) –movie clip instances can have actions

3 D Instead of locating objects in/on 2 dimensional Stage, position in 3 dimensions –also may need to orient objects –position and orient camera/eye to do calculation for what you see 3D in Flash is only partial 3-D. The display list and layers overrides the 3D positioning. I expect improved 3D is coming….

Reprise for games What's on the board –static –dynamic (changing) What is the information What are the events and what should be the response (event handler)? What is the logic of the game? –capture and respond to player moves –respond to other events (for example, timed events)

Flash Publish application –Use.fla file and, possibly..as files –produces.html and.swf files One copy of AS.RunActiveContent.js needed –Need to upload both.html and.swf –If you are using any.flv files or.mpg, need to upload them and use correct reference. –Warning: the published application has smaller screen than the development application (.fla file)

Trigonometry!!! Go from angle to position and position to angle used in ballistics, robotics, driving, etc. R X Y Y = R * sin(a) X = R * cos(a) a = atan(Y/X) a

Degrees and radians How to measure an angle? Traditional way: 360 degrees is a full circle –90 degrees is a 'right angle' –180 degrees is a half circle. 'Do a 180' means to turn around. Alternative measure: a circle is PI ( …) worth of radians. This is an intrinsic measure. Conversion formula: radians = (PI/180) * degrees Flash uses both!!!! cannon.rotation takes degrees, the Math trig methods use radians.

Positions THE position of an object in Flash and other languages: x, y [and z] values. Is dragon near enough to the gold ? Say within gap both horizontally and vertically What if it can be to the right or the left and above or below? Use Math.abs() Math.abs(30)=Math.abs(- 30) if ((Math.abs(dragon.x- gold.x)<gap)&&(Math.abs(dragon.y- gold.y))

Collisions Flash provides two methods: dragon.hitTestPoint(gold.x,gold.y,true) checks if the single point gold.x, gold.y overlaps with any occupied pixel of the dragon dragon.hitTestObject(gold) checks if the bounding box containing the dragon overlaps with the bounding box containing the gold.

3D modeling Build a virtual world –approximate shapes using polyhedra (facetted objects) surface textures –special procedures (e.g., fractals) for objects in nature Move objects –articulated (jointed) motions –expression Render objects –eye (camera), focal point, lighting Products to do these things but imagination AND knowledge of mathematics & physics is helpful. Try Google SketchUP (free version)

Language built on Java for graphics, physical computing, other…. My initial attempts: processing processing

Programming Courses Math/CS (often cross-listed with New Media) CS I: programming in Processing!, every semester CS II: every Spring Creating User Interfaces: Spring 2011 Games for Change: Spring 2011 Social Software: Fall 2010 Physical Computing: Fall 2010 Robotics, Creating Databases for Web application, others probably every other year.

Homework [Finish project –Upload ] Review study guide Review lecture charts