Flash Session 3: Events Shiny Yang special thanks to Alex

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

Create a Simple Game in Scratch
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Intro to Game Development An introduction to Swing, Java2D, JOGL, and game design Created by: Dennis Lawter and Dustin Scott.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
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.
SM1205 Interactivity Topic 06: Iteration and Multiple Objects Spring 2010SCM-CityU1.
Events (Listeners/Handlers: Mouse, keyboard, timer) Flash ActionScript 3.0 Introduction to Thomas Lövgren, Flash developer
INTRODUCTION TO SCRATCH. About Me Resources Scratch Website Learn Scratch Washington-Lee Computer.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
GAME:IT Junior Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Fish Chomp. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
Lua & Love2D Game Engine GALAGUH
GAME:IT Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Game Maker Day 2 Making a Maze Game.
VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT.
 2008 Pearson Education, Inc. All rights reserved Adobe ® Flash ® CS3: Building an Interactive Game.
KeyListener and Keyboard Events Just as we can implement listeners to handle mouse events, we can do the same for keyboard events (keypresses) –to implement.
Programming games Show your version of Bo the dog. Start cannonball Preview: video, audio work session (cannonball) Homework: Cannonball with ball in a.
Programming Video Games
Game Maker Terminology
Game Maker – Getting Started What is Game Maker?.
Roy McElmurry. More:
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
Marble Racer. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
CISC 110 Day 7 “The Outliers, Part1” hitTest(), Text Input, Frame and Timer Loops, Publishing Flash Content.
Lives and Scoring Games Programming in Scratch. Games Programming in Scratch L2 Lives and Scoring Learning Objectives Define a variable Understand the.
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.
Index Background Costumes Making object walk smoothly Controlling an object with the keyboard Control an object with the mouse Changing costume when hit.
Flash Session 4: Importing Assets
Scratch Programming Cards
MORE Genre Specific Physics
Scratch Helicopter Game
Create a Halloween Computer Game in Scratch
Click through this presentation at your own pace.
Games Programming in Scratch
Scratch for Interactivity
WITH PYGAME ON THE RASPBERRY PI
Let’s Learn 2. Installing Pygame
8. Installing Pygame
Building with Numbers Module 4: Investigation 3
Keyboard Input.
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Events in Action script
Let's Race! Typing on the Home Row
Introduction to Events
Actionscript Session 2 Roy McElmurry.
Scratch for Interactivity
Event Driven Programming
The One Where You Scratch
© Akhilesh Bajaj, All rights reserved.
LESSON 14 - Building an App: Image Scroller
Introduction to TouchDevelop
Chapter 10 Algorithms.
8. Starting Pygame Let's Learn Python and Pygame
More programming with "Processing"
Flash & ActionScript Syntax is similar to JavaScript
Tank Game Part 2 of 6.
Game Over Module 4 Lesson 2.
Programming games Demonstrate cannonball
Creating a Simple Game in Scratch
CSC 221: Introduction to Programming Fall 2018
CoE Software Lab II 1. Pygame Intro , Semester 2,
05 | Capturing User Input Michael “Mickey” MacDonald | Indie Game Developer Bryan Griffiths | Software Engineer/Game Developer.
Presentation transcript:

Flash Session 3: Events Shiny Yang special thanks to Alex

Flash Homework Recreate this game (in flash) Playable online at:

Flash Homework What do we need to know? How to draw player + enemies on screen? How to handle keyboard input? How to make an update cycle? Add sprites to the display tree. (We already know this) Set up event listeners for keyboard events. Set up a timer event. How to detect collision? Use the sprite's hittestobject() method.

Syntax Review Sprite.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){}); Syntax for creating “click” event listener. Works with almost every DisplayObject (and more importantly, every sprite) Compared with javascript (Note: NOT the prototype.observe() method): The function will have local scope based on where the function is defined. (Compared to non object-oriented model for js) this keyword in the event function will NOT refer to the “called” object (unlike in javascript) optional event parameter will need to be of type of the event (see e:MouseEvent)

ActionScript Syntax Keyboard Events stage.addEventListener(KeyboardEvent.KEY_DOWN, keyTest); stage.addEventListener(KeyboardEvent.KEY_UP, keyTest); function keyTest(e:KeyboardEvent) { trace(e.keyCode); } KEY_DOWN is called semi-continously when a key is pressed KEY_UP is called when a key is released To find out which key was pressed, access the event parameter's.keyCode parameter, then compare to: Keyboard.SPACE Keyboard.UP Keyboard.DOWN Keyboard.Q (And so on..or just remember the keycodes themselves)

ActionScript Syntax Notes About Keyboard Events Keyboard events should technically always be added to the stage. (If they are added to a child, they will not register unless the child is focused) KEY_DOWN does not fire in a consistent manner after the inital call KEY_DOWN stops firing for a first key after a second key is pressed, and does not re-fire if the second key is released but the first remains pressed down (ex. hold down 1, then hold down 2, then release 2, does not fire 1 events) A problem for many games/applications where precision control is required. Fixable through a combination of KEY_DOWN and KEY_UP (see Vidya.as keypress methods for my “input stack”)

ActionScript Syntax Timer Events //first param is MS delay, second is repeat count (none is infinite) var timer = new Timer(30); timer.addEventListener(TimerEvent.TIMER, function(){}); timer.start(); timer.stop(); Once started, the timer calls the event function once every delay ms for repeat times. The Timer variable should be accessible as a variable/field if you want to stop/edit the actions.

ActionScript Example BlocDodger Flash 1. Have a player (green ball) that is movable left and right. 2. Have an update cycle that spawns red boxes and makes them fall 1px down. (HINT: have a enemyarray array, also a method for creating boxes at random place) also syntax note: for each(var enemy:Enemy in...) {

ActionScript Syntax Hit Detection Sprite.hitTestObject(obj:DisplayObject); //returns boolean Pixel based collision detection that comes as default functionality for every Sprite. (Sure beats implementing your own hitboxes) Checks if the Sprite's graphics (or any of its children's graphics) intersect the graphics of another DisplayObject (or any of its children).

ActionScript Example BlocDodger Flash 3. Have the game stop whenever an “Enemy” intersects the “Player” 4. This program is leaking memory. Can you figure out why and how to fix it? syntax note: array.splice(indexOf(pointer),1);

Flash Homework Recreate Marty's Pretty Cool Adventure! (without the marty) Playable online athttp://

Flash Homework Enemies should be able to spawn from any of the 4 edges. Enemies should always be moving towards Marty. (Hint: they should all be in an array that is looped through every update cycle)

Flash Homework The tracking algorithm: Every update cycle, figure out which quadrant you are (in respect to the player). Move one of the two possible directions given your quadrant. (Can you improve it?)

Flash Homework Game Behavior: If one of the enemies touch the player, the game should be “over” (some sort of state change should happen) Bullets should be fired FROM the player's location, based on the LAST direction the player moved. (Bullets should be in an array of their own, also probably NOT a child of the player) If a bullet touches an enemy, the enemy should be removed.

Flash Homework Finally, add in at least one feature of your own. Some ideas: Another type of enemy? Lives/points/menu? Powerups? Multiplayer? And above all HAVE FUN