26
CIS 487 - Game Design I Chapter 4 and 5 Blake Farrugia 10/24/2011

CIS 487 - Game Design I Chapter 4 and 5

  • Upload
    lane

  • View
    48

  • Download
    0

Embed Size (px)

DESCRIPTION

CIS 487 - Game Design I Chapter 4 and 5. Blake Farrugia 10/24/2011. Ch 4 – Flak Cannon Design. Flak Cannon is a Missile Command type game where ships must be defended from incoming kamikaze fighters. Chapter 4 deals much with the concept, design, and planning of Flak Cannon. - PowerPoint PPT Presentation

Citation preview

Page 1: CIS 487 - Game Design I Chapter 4 and 5

CIS 487 - Game Design IChapter 4 and 5

Blake Farrugia10/24/2011

Page 2: CIS 487 - Game Design I Chapter 4 and 5

Ch 4 – Flak Cannon Design

• Flak Cannon is a Missile Command type game where ships must be defended from incoming kamikaze fighters.

• Chapter 4 deals much with the concept, design, and planning of Flak Cannon.– Always a good thing to do before coding.

• Chapter 5 deals with implementation.

Page 3: CIS 487 - Game Design I Chapter 4 and 5

What’s New?

• Sound Management– Adding and triggering sounds

• More Sprite Sheet Animation– Another way of accomplishing it

• Settings Implementation• Vector-based Sprite Movement– Important and awesome!

Page 4: CIS 487 - Game Design I Chapter 4 and 5

Game Basics – Flak Cannon

• Defense shooter– Limited ammo; get more from destroying bonus

planes. Extra live when 10,000 points are met.– Shells explode where clicked; area of effect

• Levels have a set number of planes as waves• Difficulty is raised each level with speed,

appearance rate, and number of planes increasing.

Page 5: CIS 487 - Game Design I Chapter 4 and 5

Sound and Graphics Assets

• You will not need to create assets for Flak Cannon; the author already has.

• For future reference, if you are not able to make graphics, look online for free sound or graphics libraries. http://www.villagegeek.com/HTML/wavfiles1.htm

• These can be used for commercial and personal projects alike.– Make sure you read their licenses!!

Page 6: CIS 487 - Game Design I Chapter 4 and 5

SFXR

• There is an open source sound editor available http://www.drpetter.se/project_sfxr.html

Page 7: CIS 487 - Game Design I Chapter 4 and 5

Using Sound

//custom sounds declared in Main.aspublic static const SOUND_EXPLODE_FLAK:String

= "sound explode flak";

[Embed(source = 'assets/flakassets.swf', symbol = "SoundExplodeFlak")]

private var SoundExplodeFlak:Class;

Page 8: CIS 487 - Game Design I Chapter 4 and 5

SoundManager.as

• New Support class to the Game Framework• Supports multiple channels and as many

sounds as needed• Sounds are called via the CustomEventSound

event sent back to Main.as• Sounds tracks and regular sounds are treated

differently for looping purposes

Page 9: CIS 487 - Game Design I Chapter 4 and 5

SoundManager.as

public class SoundManager {

private var sounds:Array;private var soundTrackChannel:SoundChannel=new SoundChannel();private var soundChannels:Array = []; private var soundMute:Boolean = false; private var tempSoundTransform:SoundTransform = new SoundTransform(); private var muteSoundTransform:SoundTransform = new SoundTransform(); private var tempSound:Sound;

public function SoundManager() {sounds = new Array();

}}

Page 10: CIS 487 - Game Design I Chapter 4 and 5

Important Items for SoundManager

• SoundTransform – modifies certain sound’s volume or offset

• SoundChannel – actually plays a sound.– soundChannels:Array – holds individual sound

items– soundTrackChannel:SoundChannel – single sound

track channel; only one channel for soundtracks

Page 11: CIS 487 - Game Design I Chapter 4 and 5

Settings

• Different variables which control certain aspects of the game

• These settings shift difficulty and control balance within the game– The trick is to balance how many settings you

implement with code complexity/bugs• The player cannot change settings, they are

controlled by simple if:else clauses• numEnemies = (numEnemies > 100) ? 100 : level

* 10 + (level * 5);

Page 12: CIS 487 - Game Design I Chapter 4 and 5

Vector Movement

• Given a sprite, move via a vector from point A to point B. This is accomplished with vectors.

• Shot’s fire from bottom center of the screen to the center of the crosshairs.

• Using these two points, we can draw a line. We apply direction and speed and we can create movement along it.

Page 13: CIS 487 - Game Design I Chapter 4 and 5

Shot.as//**Flex Framework Only[Embed(source = "assets/flakassets.swf", symbol="ShotGif")]private var ShotGif:Class;

public function Shot (startX:Number, startY:Number, endX:Number, endY:Number) {

startLocation = new Point(startX,startY);endLocation = new Point(endX,endY);nextLocation = new Point(0,0);init();

}

Page 14: CIS 487 - Game Design I Chapter 4 and 5

Vector Implementation

• Within the Shot.as class, speed, start and end points, and image data are stored.

• Find the distance between the two points.• moves – frames the animation takes

(Euclidean distance function is used)– moves = distance/speed;

• Finally, get units to move on x and y axis for each frame:– xUnits = (endLocation.x – startLocation.x)/moves;

Page 15: CIS 487 - Game Design I Chapter 4 and 5

Sprite Animation• This method assumes each sprite of a given

animation has been embedded within the object which will play it.

• As we saw in the previous sprite sheet animation lecture these sprite images are then assigned to an array.

• A new sprite from the array is displayed for each new animation after so much time passes (in milliseconds)

• This heavily relies on MovieClips and allows Flash to redraw regions as it needs

Page 16: CIS 487 - Game Design I Chapter 4 and 5

Ch 5 – Flak Cannon Implementation

• The implementation of Flak Cannon adds all the assets that were created in Chapter 4.

• Along with new classes, Chapter 5 tells key variables to work with certain functions and includes changes to existing framework classes.

Page 17: CIS 487 - Game Design I Chapter 4 and 5

Incorporating SoundManager

• A reference must be added in GameFramework’s properties section

• A CustomSoundEvent must be added to event functions in GameManager.as

• The sound event will use the new function soundEventListener() to manage sound files and play what is needed through the use of static sound variable strings in Main.as

Page 18: CIS 487 - Game Design I Chapter 4 and 5

Sounds

• New sounds are added via SoundManager.addSound()

• The first parameter is the string value that ties to the second value, which is the sound class.

Page 19: CIS 487 - Game Design I Chapter 4 and 5

Implementing Flak Cannon

• FlakCannon.as holds update loop code, settings, and tracking of each game object

• FlakCannon.as follows the standard implementation as the last few games, but the complexity has grown with new collision detection and vector-based movement

Page 20: CIS 487 - Game Design I Chapter 4 and 5

Settings

• Just a few new difficulty settings• Level updatecode modifiesmost of thesesettings.

Page 21: CIS 487 - Game Design I Chapter 4 and 5

newGame()

• One of the places that the Flakcannon class interfaces with the Main calls

• This allows Main to be in control and still allows Flakcannon to take care of game logic

• Similar to SuperClick but the Scoreboard class is sent information about the number of ships the player has left in the fleet using the event CustomEventScoreBoard

Page 22: CIS 487 - Game Design I Chapter 4 and 5

newGame()override public function newGame():void {

level = 0 ;score = 0;ships = 3;shots = 0;extraShipCount=0;isGameOver = false;

dispatchEvent(new CustomEventScoreBoardUpdate(CustomEventScoreBoardUpdate.UPDATE_TEXT,Main.SCORE_BOARD_SCORE,"0"));

dispatchEvent(new CustomEventScoreBoardUpdate(CustomEventScoreBoardUpdate.UPDATE_TEXT,Main.SCORE_BOARD_SHOTS,String(shots)));

}

Page 23: CIS 487 - Game Design I Chapter 4 and 5

newLevel()

• Not to be confused with newGame()• Function that creates an entire level, or

recreates it if player beats a given wave of enemy ships

• Difficulty is recalculated on each new level based on given settings (alterable at run time)

• There are also some new level event that need to be handled in NewLevel()

Page 24: CIS 487 - Game Design I Chapter 4 and 5

Difficulty Calculation

• Using single line if/else syntax, changes can be made to each individual variable

Page 25: CIS 487 - Game Design I Chapter 4 and 5

Additional Items

• Helper functions are added to help with sprite animation, new flak shots, and bonus enemy appearance

• These new functions are either explicitly called in the update loop, or are secondary and act only when they meet certain conditions

Page 26: CIS 487 - Game Design I Chapter 4 and 5

runGame()//runGame() is repeatedly called by Main in game loop//1. We make sure to call render() only if DISPLAY_UPDATE_NORMAL //is passed in override public function runGame():void {

checkEnemies();checkBonusPlane();update();checkCollisions();render();checkforEndLevel();checkforEndGame();

}