Sprites Actions/Particles/Sound Revisit the 'flying saucer' sprite: Again add it to the game Implement Chipmunk Physics collision feedback with missiles.

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Linked Lists Contents 1.LinkedList implements the Interface List 2.Doubly Linked List implementation of common methods a.boolean add( Object x) -- append.
PRESENTED BY MATTHEW GRAF AND LEE MIROWITZ Linked Lists.
CLASS INHERITANCE Class inheritance is about inheriting/deriving properties from another class. When inheriting a class you are inheriting the attributes.
Haskell Chapter 7. Topics  Defining data types  Exporting types  Type parameters  Derived instances  Type synonyms  Either  Type classes  Not.
Chapter 14 Graph class design John Keyser’s Modifications of Slides by Bjarne Stroustrup
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Week 4 Recap CSE 115 Spring Formal Parameter Lists Comma-separated list of formal parameters Formal parameters are listed giving the type of the.
IAT 800 Lecture Oct, Fall 2006IAT 8002 Outline  Programming concepts –Super and this –Java SDK classes Lists Reading the Java docs –Programming.
Guide to Programming with Python
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
(…A FEW OF THEM) C++ DESIGN PATTERNS. WHAT ARE THEY? Commonly occurring constructs Could be part of good software engineering Not universally agreed Good.
1 Copyright (C) 2008 by Dennis A. Fairclough all rights reserved.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Introduction to Objective-C and Xcode (Part 2) FA 175 Intro to Mobile App Development.
VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT.
Module 10: Simple Inheritance #1 2000/01Scientific Computing in OOCourse code 3C59 Module 10: Simple Inheritance In this module we will cover Inheritance.
Developing the Game User Interface (UI) Lesson 5.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
Objective-C1 CS151 Presentation: Objective C Kai Tai Pang William Sze.
1 VR assignment#2 WTK SDK Introduction By Jin-Bey Yu 2001/11/12.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Learning Unity. Getting Unity
Code reading skills LEVEL GAME.  Skeleton has error messages.  Notice the red lines on right slider. Click… you’ll go to an error.  pieces = levels.getPieces();
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Lists II. List ADT When using an array-based implementation of the List ADT we encounter two problems; 1. Overflow 2. Wasted Space These limitations are.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
Game Maker – Getting Started What is Game Maker?.
Course Summary Xcode & iPhone Simulator
Guide to Programming with Python Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
Guide to Programming with Python Week 15 Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Scratch pong challenge Pong is a classic 1970s video game  Open the pongv1.sb2 file in Scratch  Click the.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department.
Chipmunk Physics Remember that we talked about this a bit when we did collision handlers for the space ship integration task (SpritesActionsPhysicsSound).
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
OOP with Objective-C Categories, Protocols and Declared Properties.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Sound Effects The library Cocosdenshion subproject of cocos2d-iphone targeted at game audio needs Sound effects can be loaded at application startup, so.
Simple Scene Management a layer has the size of the device screen it defines appearance and behavior a scene is composed of one or more layers app transitions.
LINKED LISTS Midwestern State University CMPS 1053 Dr. Ranette Halverson 1.
OBJECTIVE C Kurt Ladendorf. General Knowledge  Super set of C  Smalltalk  Mainly used for iOS and other Apple development.
LCC 6310 Computation as an Expressive Medium Lecture 6.
SE Team 9 GlobalFlyer Cole Hoosier Ryan Hannebaum Leanne Gray Alex Stampbach.
Game Maker Evil Clutches.
Get Going On ….. Load the word file ‘Glossary’ and complete it. You will have homework today.
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
CS12230 Introduction to Programming Extra example– More on responsibilities 1.
1 CSC 211 Data Structures Lecture 11 Dr. Iftikhar Azim Niaz 1.
Creating an Object that can draw itself The paint method can ‘draw’ because it is passed a graphics environment as a parameter. If a class method is passed.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Review Scene Management (Scene, Layer, Director) Sounds Menus Sprites & Actions.
Course Summary Xcode & iPhone Simulator
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Dynamic Memory Allocation
Review Scene Management (Scene, Layer, Director) Sounds Menus
Lecture No.02 Data Structures Dr. Sohail Aslam
Symbian Basics Lecture Slides Timers Tampere Polytechnic,
Tree A tree is a data structure in which each node is comprised of some data as well as node pointers to child nodes
Pointers, Dynamic Data, and Reference Types
Object-Oriented Programming and class Design
Presentation transcript:

Sprites Actions/Particles/Sound Revisit the 'flying saucer' sprite: Again add it to the game Implement Chipmunk Physics collision feedback with missiles and asteroids Use the particle system to give the impression that it has blown up, and play a 'boom' sound as well

Tie in with physics engine By subclassing CCSprite so that: init method will create the collision body and collision shape setPosition method will also tell the physics engine the position of the sprite dealloc method will also remove the physics body and shape when the sprite is deallocated

Tie in with physics engine In addition: create a flag in the in the object to mark it as “blown up' put a pointer to the object in the collision shape so we can get to the flag in the physics engine Collision Handler actually remove the flying saucer in the step: method of the AsteroidLayer

Define the interface #define FlyingSaucerSprite : CCSprite { cpShape *shape; bool blowItUp; cpShape bool blowItUp; -(id) initWithFile:(NSString*)filename; -(void)setPosition:(CGPoint)pos;

Define the blowItUp; -(id)initWithFile:(NSString*)filename { if ((self=[super initWithFile:filename])) { float radius = 35.0f; cpBody *body = cpBodyNew(FLYINGSAUCERMASS, cpMomentForCircle(FLYINGSAUCERMASS, 0.0f, radius, cpvzero)); cpSpaceAddBody(space, body); shape = cpCircleShapeNew(body, radius, cpvzero); shape->collision_type = kColl_FlyingSaucer; shape->data = self; // So we can get a pointer to this instance from within a Chipmunk Physics collision callback cpSpaceAddShape(space, shape); blowItUp = NO; } return self; }

Define the implementation -(void)setPosition:(CGPoint)pos { [super setPosition:pos]; shape->body->p = pos; } -(void)dealloc { removeFromSpace(space, shape); [super dealloc];

Integrating it into the game Create a global to hold the once instance that we will have: FlyingSaucerSprite *flyingSaucer = NULL; In the step method in the AsteroidsLayer: Create a space ship every so often Remove it when it goes off of the screen Only allow one at a time

Create one every so often if there isn't one if (flyingSaucer == NULL && rand()%100 == 0) { flyingSaucer= [FlyingSaucerSprite [self addChild:flyingSaucer]; CGSize s = [[CCDirector sharedDirector] winSize]; cpFloat yPos = rand()%((int)s.height); CGPoint pos = ccp(s.width, yPos); [flyingSaucer setPosition:pos]; CCAction *overAction = [CCMoveBy actionWithDuration:5 position:ccp(- s.width,0)]; [flyingSaucer runAction:overAction]; }

Remove it if it's off of the screen if (flyingSaucer != NULL && flyingSaucer.position.x <= 0.0f) { [self removeChild:flyingSaucer cleanup:YES]; flyingSaucer = NULL; }

Define the flag for the collision type In the enum of 'CollisionTypes' add: kColl_FlyingSaucer

Define the collision handlers In the init method of AsteroidLayer add: cpSpaceAddCollisionHandler(space, kColl_FlyingSaucer, kColl_Asteroid, &beginFlyingSaucerHitAsteroid, NULL, NULL, NULL, NULL); cpSpaceAddCollisionHandler(space, kColl_Missile, kColl_FlyingSaucer, &beginMissileHitFlyingSaucer, NULL, NULL, NULL, NULL);

Define the collision handlers themselves int beginFlyingSaucerHitAsteroid(cpArbiter *arb, cpSpace *space __attribute__ ((unused)), void *data __attribute__ ((unused))) { return 1; } int beginMissileHitFlyingSaucer(cpArbiter *arb, cpSpace *space __attribute__ ((unused)), void *data __attribute__ ((unused))) { return 1; }

So give it a try! Next we will: add code in the collision handlers and step: method to remove the flying saucer use the particle system to show a display when we remove it play some sound as well

Mark the flying saucer as blown up & leave the asteroid alone int beginFlyingSaucerHitAsteroid(cpArbiter *arb, cpSpace *space __attribute__ ((unused)), void *data __attribute__ ((unused))) { cpShape *flyingSaucerShape, *asteroidShape; cpArbiterGetShapes(arb, &flyingSaucerShape, &asteroidShape); FlyingSaucerSprite *flyingSaucer = flyingSaucerShape->data; flyingSaucer.blowItUp = YES; return 0; }

Mark the flying saucer as blown up & distroy the missile int beginMissileHitFlyingSaucer(cpArbiter *arb, cpSpace *space __attribute__ ((unused)), void *data __attribute__ ((unused))) { cpShape *missileShape, *flyingSaucerShape; cpArbiterGetShapes(arb, &missileShape, &flyingSaucerShape); cpSpaceAddPostStepCallback(space, (cpPostStepFunc)postStepDistroyMissile, missileShape, NULL); FlyingSaucerSprite *flyingSaucer = flyingSaucerShape->data; flyingSaucer.blowItUp = YES; return 0; }

Add code in the step: method to do the actual work // If the flying Saucer exists and has just left the screen, then remove it... if (flyingSaucer != NULL && (flyingSaucer.position.x <= 0.0f || flyingSaucer.blowItUp == YES)) { if (flyingSaucer.blowItUp == YES) { blowup FlyingSaucer!!!\n"); // we should do something interesting graphically here.... } // if it's off of the screen remove it... [self removeChild:flyingSaucer cleanup:YES]; flyingSaucer = NULL; }

Add the particles and sound blowup FlyingSaucer!!!\n"); // we should do something interesting graphically here.... [[SimpleAudioEngine sharedEngine] playEffect:EXPLOSION_WAV]; CCParticleSystem *emitter = [CCParticleExplosion node]; [self addChild: emitter z:1]; emitter.texture = [[CCTextureCache sharedTextureCache] emitter.autoRemoveOnFinish = YES; // This will cause the object to be garbage collected cpShape *shape = flyingSaucer.shape; emitter.position = shape->body->p;

Don't forget To define the wav file and symbols for the audio engine: #import "SimpleAudioEngine.h" #define Preload the wav file in the applicationDidFinishLaunching: [[SimpleAudioEngine sharedEngine] preloadEffect: EXPLOSION_WAV];