AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 11 "The games of a people reveal.

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

Create a Simple Game in Scratch
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
Harry Potter Scratch Game
Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations
A Christmas Scratch game
DIGITAL GRAPHICS & ANIMATION Complete LESSON 4 ADDING TEXT TO GRAPHICS.
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.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 9 "The games of a people reveal.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Game Design Creating a game called PING Phase 3: Steps for building basic game.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
BUILDING RICH MEDIA ELEMENTS. Design Decisions Based on Design Specification  Following the design specification will ensure that the application is.
Introduction to TouchDevelop
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 3 "The games of a people reveal.
Working with iMovie: The Basics Created by MJ. Importing Video Footage attach your camera to your computer and set to VTR mode move the camera button.
Learning Game Maker Studio:
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.
Art 315 Lecture 5 Dr. J. Parker AB 606. Last time … We wrote our first program. We used a tool called GameMaker. The program we wrote causes a ball to.
Adobe Flash CS3 Revealed Chapter 1 - GETTING STARTED WITH FLASH.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 3 "The games of a.
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
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.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 2 "The games of a.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 3 "The games of a.
Adobe Flash CS3 Revealed Chapter 3 - WORKING WITH SYMBOLS AND INTERACTIVITY.
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.
1. Press the New Layer Button 3. Double click names to re-name Ball & Shadow layers 2. Click to change to 12 fps Step 1.
Microsoft PowerPoint Tutorial Created by L. George 2006.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Sound in Action Script "The games of a people reveal.
Game Maker Terminology
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 9 "The games of a.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 6 "The games of a people reveal.
Guide to Programming with Python Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 3 "The games of a people reveal.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 9 "The games of a people reveal.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
Game Maker Galactic Mail Advanced Group: Complete Galactic Mail, then start developing an independent project.
2D Platform Game Game Maker Terminology. Object  Item in a game that has behavior, such as a main character who can move.
1 Actionscript for Flash by Dr SC Li. 2 Understanding more about instances Symbolsgraphics buttons Movie clips Instances (without names) No interaction.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 6 "The games of a.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Action Script 12 "The games of a people.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
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.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 12 "The games of.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Starting Out with Games & Graphics in C++ Tony Gaddis Chapter 8 The.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
GAME:IT Junior Paddle Ball Objectives: Review skills from Introduction Create a background Add simple object control (up and down) Add how to create a.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 5 "The games of a people reveal.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
CIS 205—Web Design & Development Flash Chapter 3 Working with Symbols and Interactivity.
Computer Programming with Scratch JAOIT 8. Scratch Scratch is a programming language that makes it easy to create your own interactive stories, animations,
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.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
School of Computer Science Space School 2015 Programming a Lunar Lander Game.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 12 "The games of a people reveal.
var variableName:datatype;
Create a Halloween Computer Game in Scratch
Scratch for Interactivity
Creating a Simple Game in Scratch
Presentation transcript:

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 11 "The games of a people reveal a great deal about them.“ Marshall McLuhan

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla The player controls an object or a character that moves left-right Other object fall down The player must either catch or avoid falling objects

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla The fox moves along the bottom of the stage left –right controlled by the user through left and right arrow keys on the keyboard Fox moves as long as the arrow key is pressed Fox stops automatically before going beyond the left and right sides of the screen Apples fall down from the tree at random places and random times But not too quickly The apples start falling slowly and then fall faster and faster as the game progresses The fox has to catch apples Each successfully catch apple increments the player score shown in the score text field

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla Open applecatch.fla flash file. Pay attention to the 3 frames. 1 frame – “start”, 2 frame – play, 3 frame – “game over”

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla 1 frame – “start”

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla 2 frame – play

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla 3 frame – “game over”

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla “running fox”movie clip in the library which contains animation 1 frame “stand” 2-6 frames “run”

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla “running fox”movie clip exported for Action Script as “running fox”

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla “applemovie clip exported for Action Script as “apple”

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla attachMovie is used to make apples timeSinceLastApple counter starts with 0 for each new apple incremented once per frame then counter becomes 20, another apple is created this assures the time between the apples (20 frames) appleSpeed variable to control falling speed of apples after each new apple it is increased the apples fall faster and faster Each apple movie clip is removed then fox catches it or it hits the bottom of the stage After certain number of dropped apples the game ends and the score is displayed

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla “Actions” movie clip contains the following script that calls Function initGame() once the actions movie clip is loaded Calls functions moveFox(), dropNewApple(), moveApples() every frame. onClipEvent (load) { _root.initGame(); } onClipEvent (enterFrame) { _root.moveFox(); _root.dropNewApple(); _root.moveApples(); }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla Second frame (play frame) script. The functions are declared in the main Timeline stop(); function initGame() { // sets the variables to start the game and creates the fox movie clip // the range of falling apple clips firstApple = 1; lastApple = 0; // init the score score = 0;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla // set the number of apples to fall totalApples = 20; // init the speed and time delay timeSinceLastApple = 0; appleSpeed = 5; // create the fox so that it is on top of the apples attachMovie( "running fox", "fox", ); fox._x = 275; fox._y = 300; } Because the fox movie clip is created through script as the movie is built it appears on top of the apples the assigned level to fox movie clip is All apples start at level 1 so they are behind the fox.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla Key.isDown(Key.RIGHT)) checks if the right arrow key is down Key.isDown(Key.LEFT)) checks if the left arrow key is down dx variable set to 10 / -10 to indicate how much and in what direction fox should move _xscale negative or positive value flip fox movie clips horizontally so that fox is facing the direction of the movement Math.abs (x) computes and returns an absolute value for the number specified by the parameter x.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla function moveFox() { // check for arrow keys if (Key.isDown(Key.RIGHT)) { dx = 10; // fox faces right fox._xscale = -Math.abs(fox._xscale); } else if (Key.isDown(Key.LEFT)) { dx = -10; // fox faces left fox._xscale = Math.abs(fox._xscale); } else { // no movement dx = 0; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla // move the fox for a value of dx //and limit that movement fox._x += dx; if (fox._x < 30) fox._x = 30; if (fox._x > 520) fox._x = 520; // make the fox run or stand still if ((dx != 0) and (fox._currentFrame == 1)) { fox.gotoAndPlay("run"); } else if ((dx == 0) and (fox._currentFrame != 1)) { fox.gotoAndPlay("stand"); } If there is a movement going on and fox is standing still on the first frame then clip sent to 2 frame “run”.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla function dropNewApple() { // drop only if it has been long enough if (timeSinceLastApple > 20) { // drop only if there are more apples if (lastApple < totalApples) { // drop only 10% of the time //prevents apples to be dropped with at exact time intervals if (Math.random() <.1) {

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla // create next apple and set its locations lastApple++; attachMovie( "apple", "apple"+lastApple, lastApple ); //horizontal location of each new apple between 30 and 520 _root["apple"+lastApple]._x = Math.random()*490+30; _root["apple"+lastApple]._y = 0; // reset time delay for next apple timeSinceLastApple = 0; // increase apple speed if (appleSpeed < 10) appleSpeed +=.5; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla // even if no apple dropped, get closer to next drop timeSinceLastApple++; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla function moveApples() { // loop through all existing apple clips for (i=firstApple;i<=lastApple;i++) { // get apple location x = _root["apple"+i]._x; y = _root["apple"+i]._y + appleSpeed; // see whether apple reached ground if (y > 400) { removeApple(i);

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla // see whether apple hit basket } else if ((Math.abs(y-fox._y) < 10) and (Math.abs(x-fox._x) < 25)) { removeApple(i); score += 1; // continue to move apple } else { _root["apple"+i]._y = y; } Math.abs used to determine collision between basket and apples When an apple within 10 pixels of vertical and 25 pixels of horizontal proximity, the collision is detected

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Catch games applecatch.fla function removeApple(n) { // take away apple movie clip (delete) _root["apple"+n].removeMovieClip(); // reset range of apples to move firstApple = n+1; // see whether this was the last apple if (n == totalApples) { fox.removeMovieClip(); gotoAndPlay("game over"); }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla Catch game with selection add/remove power add/remove score add/remove objects in the game scene etc. Modified appleCatch game Each apple has a letter inside. The user has to catch vowels and avoid consonants The right apple with vowel increments user’s score The wrong apple with a consonant decrements the score the score should not go below 0

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla Catch game with selection

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla bad apple - consonants

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla good apple - vowels

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla Two apple movie clips- good (vowels) and bad (consonants) “good apple”5 frames each showing a vowel “bad apple”20 frames each showing a consonant When it is time to drop there is a chance it is good apple or bad apple The script displays a random frame from the appropriate movie clip When the player catches the apple the script determines if its good or bad one and adjusts the score

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla The “actions” movie clip contains the same script as in the applecatch game: onClipEvent (load) { _root.initGame(); } onClipEvent (enterFrame) { _root.moveFox(); _root.dropNewApple(); _root.moveApples(); }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla initGame() function is the same as in the applecatch game: stop(); function initGame() { // the range of falling apple clips firstApple = 1; lastApple = 0; // init the score score = 0; // set the number of apples to fall now 50 totalApples = 50;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla // init the speed and time delay timeSinceLastApple = 0; appleSpeed = 5; // create the fox so that it is on top of the apples attachMovie( "running fox", "fox", ); fox._x = 275; fox._y = 300; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla moveFox() function is the same as in the applecatch game: function moveFox() { // check for arrow keys if (Key.isDown(Key.RIGHT)) { dx = 10; // fox faces right fox._xscale = -Math.abs(fox._xscale); } else if (Key.isDown(Key.LEFT)) { dx = -10; // fox faces left fox._xscale = Math.abs(fox._xscale); } else { // no movement dx = 0; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla // move the fox and limit that movement fox._x += dx; if (fox._x < 30) fox._x = 30; if (fox._x > 520) fox._x = 520; // make the fox run or stand still if ((dx != 0) and (fox._currentFrame == 1)) { fox.gotoAndPlay("run"); } else if ((dx == 0) and (fox._currentFrame != 1)) { fox.gotoAndPlay("stand"); }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla dropNewApple() function decides which type of apple to drop, And then pick a random frame in the corresponding movie clip to display. function dropNewApple() { // only drop if it has been long enough if (timeSinceLastApple > 20) { // only drop if there are more apples if (lastApple < totalApples) { // only drop 10% of the time if (Math.random() <.1) { // create next apple and set its locations lastApple++; if (Math.random() <.5) {

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla // 50% chance of a bad apple attachMovie( "bad apple", "apple"+lastApple, lastApple ); _root["apple"+lastApple].type = "bad"; } else { // 50% chance of a good apple attachMovie( "good apple", "apple"+lastApple, lastApple ); _root["apple"+lastApple].type = "good"; } f = int(Math.Random()*_root["apple"+lastApple]._totalFrame s) + 1;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla _root["apple"+lastApple].gotoAndStop(f); _root["apple"+lastApple]._x = Math.random()*490+30; _root["apple"+lastApple]._y = 0; // reset time delay for next apple timeSinceLastApple = 0; // increase apple speed if (appleSpeed < 10) appleSpeed +=.5; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla // even if no apple dropped, get closer to next drop timeSinceLastApple++; } function moveApples() { // loop through all existing apple clips for (i=firstApple;i<=lastApple;i++) { // get apple location x = _root["apple"+i]._x; y = _root["apple"+i]._y + appleSpeed;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla // see whether apple reached ground if (y > 400) { removeApple(i); // see whether apple hit basket } else if ((Math.abs(y-fox._y) < 10) and (Math.abs(x-fox._x) < 25)) { if (_root["apple"+i].type == "good") { // good apple, get a point //differentiates “good” and “bad” catches score += 1; } else { // bad apple, lose a point score -= 1;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla // don't go below 0 if (score < 0) score = 0; } removeApple(i); // continue to move apple } else { _root["apple"+i]._y = y; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Avoid games applelettercatch.fla function removeApple(n) { // take away apple movie clip _root["apple"+n].removeMovieClip(); // reset range of apples to move firstApple = n+1; // see whether this was the last apple if (n == totalApples) { fox.removeMovieClip(); gotoAndPlay("game over"); }