Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CIS 487 - Game Design I Chapter 4 and 5 Blake Farrugia 10/24/2011."— Presentation transcript:

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

2 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.

3 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!

4 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.

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 http://www.villagegeek.com/HTML/wavfiles1.htm These can be used for commercial and personal projects alike. – Make sure you read their licenses!!

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

7 Using Sound //custom sounds declared in Main.as public static const SOUND_EXPLODE_FLAK:String = "sound explode flak"; [Embed(source = 'assets/flakassets.swf', symbol = "SoundExplodeFlak")] private var SoundExplodeFlak:Class;

8 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

9 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(); }

10 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

11 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);

12 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.

13 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(); }

14 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;

15 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

16 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.

17 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

18 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.

19 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

20 Settings Just a few new difficulty settings Level update code modifies most of these settings.

21 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

22 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,Ma in.SCORE_BOARD_SHOTS,String(shots))); }

23 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()

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

25 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

26 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(); }


Download ppt "CIS 487 - Game Design I Chapter 4 and 5 Blake Farrugia 10/24/2011."

Similar presentations


Ads by Google