Bullets and Magazines Andrew Williams

Slides:



Advertisements
Similar presentations
PRESENTED BY MATTHEW GRAF AND LEE MIROWITZ Linked Lists.
Advertisements

Getting to know Greenfoot
Asteroids! Michael Marion under Prof. Susan Rodger Duke University July2012.
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.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Copyright © 2002 Bolton Institute The AWSprite Library Andrew Williams
Lecture19 Java Game Programming II – Example Continued.
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.
Copyright © 2002 Bolton Institute Sound in SDL Andrew Williams
Chapter 3 Using Classes and Objects. 2 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used.
What is AI  An attempt to imitate human reactions by scripting reactions to happen when a certain cause is brought about.
1 Hypothesis Testing In this section I want to review a few things and then introduce hypothesis testing.
Copyright © 2002 Bolton Institute Explosions Andrew Williams
Games at Bolton Sound in SDL Andrew Williams adw1.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
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.
A Scratch tutorial. Description: You have 6 bullets to shoot at 2 targets. Every time you hit any of them you get two extra bullets but the targets get.
VIDEO GAME PROGRAMMING Video Game Programming Junior – Number Attack INSTRUCTOR TEACHER’S ASSISTANT.
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
AI & 2D Development COSC 315 Fall 2014 Bridget M. Blodgett.
GAME:IT Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Game Maker Day 2 Making a Maze Game.
How to make Space Invaders
VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT.
VIDEO GAME PROGRAMMING Video Game Programming Level One – Breakout INSTRUCTOR Big Dan Teague TEACHER’S ASSISTANT Delmar O'Donnell.
Introduction to Programming G50PRO University of Nottingham Unit 3 : Introduction To Scratch 2 Paul Tennent
February 14,  Relations: in mathematics, we refer to a group of points as a “relation” Examples: { (2, -3); (2, 5); (5,1) }
We will be creating a spaceship that simulates real movements in space. The spaceship will fire a laser beam that can destroy targets. The spaceship will.
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.
Copyright © Curt Hill Sounds, Resource Packs, JSON What more would you want?
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.
Copyright © 2002, Systems and Computer Engineering, Carleton University a-JavaReview.ppt * Object-Oriented Software Development Unit.
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.
Sample Video Game & Sound. The Plan 1.Game Theme 2.Game Structure 3.Sprites 4.Trackers 5.Collisions 6.Score 7.Levels 8.Splash Screens 9.Design 10.Implementation.
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.
CSE 380 – Computer Game Programming GUIs for Games.
Game Maker – Getting Started What is Game Maker?.
Shooters in GameMaker J Parker.
Sprites Actions/Particles/Sound Revisit the 'flying saucer' sprite: Again add it to the game Implement Chipmunk Physics collision feedback with missiles.
Guide to Programming with Python Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Guide to Programming with Python Week 15 Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
July 5 Game Workshop. Schedule 9-10:25Finish maze/platform games 10:25-10:45Game structure –Different interactions to motivate players 10:45-11:15Playtest.
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.
Final Project Proposal Space Invaders By Jordan Mahaffey.
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
Instruction Booklet.  Use the arrow keys to move your plane.  Don’t get hit by the rockets or you will die.  The level will last for 45 seconds.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
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.
Review of Previous Classes Declaring Variables - var myVar:DataType = value Data Types – Number, uint, String, Boolean Functions – parameters, return.
SixIdeas for a capstone to GCS Spring Hellavation 3 rd person survival horror game Player is equipped with two weapons generic gun and slicer WSAD.
Programming a Shooter Game Design.
StarLogoTNG 101 Treasure Hunt Game Unit Lesson 8: Hatch.
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.
2D Game Design Pitch “Invasion” By: Tom Nanke. Abstract of Game Story It is the year 2190 and planet Earth is trying to salvage the last bit of civilization.
Tank Game Part 2 of 6. Firing Shells Coming up… Players Scores Large Explosions Small Explosions Damage Health Bars Parent Shell Destructible Walls Reappear.
Coding – Week 2 Functions, Arrays, and Objects. Functions  Functions are not a new concept – you’ve been using them already.  void setup() {} and void.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot.
Index Background Costumes Making object walk smoothly Controlling an object with the keyboard Control an object with the mouse Changing costume when hit.
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Space Invaders inspired game
Tank Game Part 2 of 6.
Week 6: Time and triggers!
Flappy bird Demo: Lesson 5 Flappy bird Demo:
Presentation transcript:

Bullets and Magazines Andrew Williams

AWBullet ● Doesn't have to be a bullet as such: – Arrow – Missile – Bomb – Laser blast – Etc ● What is the distinguishing feature in the context of games development?

AWBullet ● The key thing about bullets is that they disappear – Once they've left the screen we don't really care about them – In general, in your side-scrolling shooter you don't want to accidentally destroy enemies that you've not seen yet ● Another thing to think about is that there may be a very large number of bullets – Think of shooting games where you hold the fire button down constantly

#include "AWSprite.h" // Slightly simplified for clarity.... class AWBullet : public AWSprite { public: // True if bullet has been fired but hasn't disappeared yet bool inUse; // Constructor AWBullet(char *bmpName, Uint32 hmf) : AWSprite(bmpName, hmf) { inUse = false; } void update_everything(Uint32 topLeftX, Uint32 topLeftY) { if(!inUse) return; if(is_on_screen(topLeftX, topLeftY)) { auto_move(); auto_animate(); auto_accelerate(); draw(); } else { set_auto_move(0); set_auto_animate(0); set_auto_accelerate(0); inUse = false; } };

AWBullet ● If in the course of a game, a player might fire laser blasts, we don't want to have to create AWSprites – That would be wasteful of space – And completely unnecessary ● we've already noted that we don't care about bullets once they've left the screen ● It's better to create a collection of bullets which we can re-use as appropriate

AWMagazine ● Magazine as in AK-47, not magazine as in Edge – Think of a magazine as a collection of bullets ● Each magazine can hold one type of bullet – So if your ship can fire laser blasts and missiles, you need two AWMagazines: laserblasts = new AWMagazine(10, “blast.bmp”, 1); missiles = new AWMagazine(6, “missile.bmp”, 4); ● The first parameter determines how many “bullets” there are in the magazine

AWMagazine ● The number of bullets in a magazine determines how many shots can be on screen at once ● Examples: 1 bullet 3 bullets 6 bullets10 bullets50 bullets

AWMagazine ● Some rules: – All bullets in a magazine look the same – Although they all use the same bitmap, there are n copies of the SDL_Surface for n bullets ● That is to say, AWMagazine is not space-efficient – Bullets in a magazine move, accelerate and can be animated, independently – You must use AWBullet *AWMagazine::allocate_a_bullet(); to obtain a new bullet when you want to fire

Allocating a Bullet AWBullet *blast; AWMagazine *laserblasts; laserblasts = new AWMagazine(10, "blast.bmp", 1); // NOTE 1 laserblasts->set_transparent_colour(0, 0, 0); // NOTE 2 /*... blah blah blah... * The event handler sets firing to true if * the player is trying to fire a bullet *... */ if(firing) { blast = laserblasts->allocate_a_bullet(); if(blast != NULL) { // NOTE 3 // NOTE 4 blast->set_world_position(ship->worldX+13, ship->worldY+14); blast->set_velocities(0.0f, -5.0f); blast->set_accelerations(0.0f, -0.1f); blast->set_auto_accelerate(20); blast->set_auto_move(20); }

Notes on the Example ● Note 1 – Creating an AWMagazine creates a number of AWBullets for you. ● You wouldn't normally create an AWBullet directly

Notes on the Example ● Note 2 – I have provided some convenience functions for doing something to all the AWBullets in an AWMagazine ● set_transparent_colour(..) – Because the sprite bitmap is the same, the transparent colour will normally be the same ● update_everything(..) – This goes through the list of bullets and updates the ones for which inUse is true. The others are ignored.

Notes on the Example ● Note 3 – If (blast==NULL) it means that there are no bullets available in the magazine ● In other words, all the bullets are currently inUse ● You must not attempt to use blast if it is NULL

Notes on the Example ● Note 4 – The characteristics of a (laser)blast are set on a per-bullet basis – The blast variable is not preserved, so you have to be a little careful how you use it – In general, it is best not to treat bullets as individuals after they have been fired

Collision Detection ● Remember, an AWBullet is just an AWSprite, so we can use all the collision-detection functions we have already provided: // See if we have hit anything.. for(unsigned b=0; b size(); b++) { blast = laserblasts->get(b); if(blast->inUse == false) continue; if(blast->bb_80_collision(alien)) { alien->make_invisible(); score += 10; }