DOC PREVIEW
GT ECE 4893 - Lecture 10: A Walkthrough of an XNA 2D game
School name Georgia Tech
Pages 22

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lecture 10: A Walkthrough of an XNA 2D game Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology2D Games • Using “Sprites” – All textures – Simple to make or obtain • Early games before 3D revolution – Space Invaders, Lode Runner, Donkey Kong, Pac-Man • Do not require high performance accelerators • Simple enough for your grandparents to enjoy • Easy to do using XNA framework • No “effect” (.fx) usedMy Game: GoogleShower • Shoot the bad dawgs! • Consist of four main objects – The shooter (ship.cs) – The bad dawgs (meteros.cs) – The missile (missile.cs) – Music (AudioComponent.cs) • The moving objects are all made of sprites Adapted from Chapter 3 of XNA 2.0 Game ProgrammingScreen ShotDemo GoogleShower Game ExampleDrawing Sprite Using XNA • Use “texture” • Store with XNA’s texture2D class • Include new texture images into the Content Pipeline • Use “Content.Load” to associate texture variablesAdding Game Component (C# source file) • Adding new DrawableGameComponent class of objects in the game • Project  Add ComponentsFull Screen ModeGame Services • Game services maintain loose coupling between objects that need to interact with each other • Register a “global” SpriteBatch for drawing all sprites • Draw() method will look for an active SpriteBatch in GameServices • All GameComponents will use this SpriteBatch Registering a Game Service In LoadContent() Use GetService to acquire serviceDrawing Background in One Pass Draw other spritesDrawString (Scoreboard) • Draw using SpriteBatch • Create a font sprite • Based on available Fonts in the system • Add font in LoadContent()Manage Components • Components: member of GameComponentCollection (i.e., Microsoft.XNA.Framework.Game) • Use Components.Add() to add a new component to the list • Components.RemoveAt(j) removes jth componentGame Logic • Embedded inside Update() function • Logistics check • Check collision • Check if a missile is fired • Check if should advance levelsPause the Game • Poll the keyboard state • Simply do not perform any update inside the Update()Built-in Test for Collision Detection • Test bounding boxes of given rectangular sprites • Return a boolean result • BoundingSphere also provides similar methodXNA Game Audio Component • Use “Content pipeline” again • Use Microsoft Cross-Platform Audio Creation Tool (or XACT) in XNA Game Studio 2.0XNA Game Audio Component Cont’d • Create wave banks and sound banks • Compile them into XAP file used by the content manager “checked” for looping background musicXNA Game Audio Component Cont’d • Create a new GameComponent for audio • Initialize WaveBank and SoundBank in the C# code This “Content” directory is located in <Proj>/bin/x86/<Sln Config>/Content AudioEngine object is the program reference to the audio services in your machine provided by XNABackground Looping Music • Add in Initialize code of the Game • PlayCue is a method of SoundBankPlay Sound On Event • Shoot.wav in SoundBank was not set to “infinite”, thus will only be played onceGame Over • Remove all components • Replace background canvas • Pause the musicOrganized Game Structure SoundBank Play Again?Class GameScene : DrawableGameComponent PlayScene Play


View Full Document

GT ECE 4893 - Lecture 10: A Walkthrough of an XNA 2D game

Documents in this Course
Load more
Download Lecture 10: A Walkthrough of an XNA 2D game
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 10: A Walkthrough of an XNA 2D game and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 10: A Walkthrough of an XNA 2D game 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?