290 likes | 398 Views
What is this XNA thing anyway?. Chris Williams Technology Evangelist. Who Am I? What Is Magenic ? XNA What is it? What do I need? / Where do I get it? How do I use it?, Sprites, Sounds XNA Demos Community Games Suggestions / Tips Resources Q&A. Who am I?. Chris Williams is a…
E N D
What is this XNA thing anyway? Chris WilliamsTechnology Evangelist
Who Am I? • What Is Magenic? • XNA • What is it? • What do I need? / Where do I get it? • How do I use it?, Sprites, Sounds • XNA Demos • Community Games • Suggestions / Tips • Resources • Q&A
Who am I? Chris Williams is a… • Microsoft MVP • Technology Evangelist • Freelance Game Developer • User Group Leader: http://www.twincitiesxnausergroup.com • Blog: http://www.blogusmaximus.net You can reach me at chrisgwilliams@gmail.com Twitter: chrisgwilliams
What is Magenic? Magenic is… • a consulting company. • Microsoft Gold Partner of the Year. • home to a lot of MVPs and book authors. • a really awesome place to work. • currently hiring.
XNA is… • a free game development framework that sits on top of the .NET framework. • A development environment (XNA Game Studio 3.0) • Windows game development. • Xbox 360 game development. • Zune game development. • A tool for hobbyists and professional developers alike. • Suitable for 2D and 3D games.
What do I need? / Where do I get it? XNA 2.0 • Microsoft Visual C# 2005 Express and SP1.http://creators.xna.com/Resources/Essentials.aspx (You can pull SP1 down from Windows Update.) • XNA Game Studio 2.0http://creators.xna.com/Resources/Essentials.aspxXNA Game Studio 2.0 actually works in ALL versions of Microsoft Visual Studio 2005 (but not 2008.)
What do I need? / Where do I get it? XNA 3.0 • Microsoft Visual C# 2008 Expresshttp://www.microsoft.com/express/download/ • XNA Game Studio 3.0 CTPhttp://creators.xna.com/Resources/Essentials.aspxXNA Game Studio 3.0 CTP works in all versions of Microsoft Visual Studio 2008 (but not Visual Studio 2005.)
What do I need? / Where do I get it? • XBOX 360 Controller Driver for Windows XP SP1http://tinyurl.com/63amfo • Samples, Starter Kits and Tutorialshttp://creators.xna.com/Education/Samples.aspx • No official VB.NET support from Microsoft. However, converted VB.NET samples are available at:http://ILoveVB.net/web/blogs/vbxna/
How do I use it? • XNA Game Studio provides you with a game loop and a handful of key methods: • LoadGraphicsContent()Use this to load your sprites (textures) and set initial values (position, scale, origin, etc.) • Update()Use this to update game object data (position, rotation, collision detection, etc…)This is also where we process any player input. • Draw()Use this when it’s time for your game to actually update the screen, calling the draw() method of your game objects (which should, in turn, use the spriteBatch object.)
How do I use it? • Important Game Objects: • SpriteBatchEnables a group of sprites to be drawn using the same settings. • ContentManagerLoads managed objects from the binary files and manages the lifespan of the loaded objects. • GameTimeA snapshot of the game timing step. Gives us information such as time elapsed since last update (ElapsedGameTime) and amount of time since the start of the game (TotalGameTime.)
How do I use it? (cont…) • Content Pipeline • Processes your art assets (images, sound, etc.) at Build Time! • Automatically creates asset names you can use in your code. • Uses “Content” subproject in your game. • Sprites (stay tuned…) • Shaders (.x file) • Uses HLSL (High Level Shader Language) • No built-in Intellisense support in Visual Studio
Sprites? • If it moves in a 2D game, it’s probably a sprite. • If you’re making a 2D game in XNA, you are definitely using sprites.
In XNA, pretty much anything that is displayed on the screen in a 2D XNA game, including a background image, is a sprite. Also a sprite! Pretty cool, huh?
Ok cool, so where’s the Sprite class? • Well… there isn’t one. Instead we use the Texture2D class.Ball.BallTexture = content.Load<Texture2D>("soccer_ball"); • XNA doesn’t give you a sprite class since it can’t possibly predict all the things you might want to do with it. So… • We write custom classes for our game objects.
For example: class Ball { public Vector2 Position; public Vector2 Scale = Vector2.One; public float Rotation; public static Texture2D BallTexture; public static Vector2 Origin = Vector2.Zero; public void Draw(SpriteBatchspriteBatch) { spriteBatch.Draw(BallTexture, Position, null, Color.White, Rotation, Origin, Scale, SpriteEffects.None, 0); } } • This allows us to store the properties we need for our sprite where they belong, in the relevant class.
Now let’s do something with it: protected override void Update(GameTimegameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); //spin them ball1.Rotation += (float)(gameTime.ElapsedGameTime.TotalSeconds * 3); //move them if (ball1.Position.X < 500) ball1.Position.X += 1; base.Update(gameTime); }
Responding to input: // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // check for button press and shrink/expand ball if (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed) ball1.Scale = new Vector2(ball1.Scale.X - 1, ball1.Scale.Y - 1); if (GamePad.GetState(PlayerIndex.One).Buttons.X == ButtonState.Pressed) ball1.Scale = new Vector2(ball1.Scale.X + 1, ball1.Scale.Y + 1);
Sounds • XNA 2.0 • XACT Tool • XNA 3.0 • XACT Tool (no changes)Audio API (Zune doesn’t support XACT, so they added this in 3.0)
XBOX 360 Gaming • Dev process is “mostly” like Windows • Includes step through debugging on XBOX 360!! • XBOX 360 uses modified Compact Framework • Support for most controllers • Wireless and Wired Control Pad • No Support (currently) for SceneIt and GuitarHero controllers • Creators Club Membership Required • $99 /year • $50 /3 months • Deploy from Visual Studio
Zune Gaming • 320x240 Screen Resolution • No Shader Support • No XACT Support • Two Control Schemas • Zune30 (Dpad) • Zune80 (Left Stick) • WiFi Support (Zune ad hoc networking) • Deploy from Visual Studio (NOT the Zune Software)
XNA Community Games • Make Your Game • Submit Your Game • Peer Review Process • Xbox Live • Deposit Your Checks • Retire! • Creators Club Membership Required • $99 / year • $50 / 3 months
Current State of XNA • XNA Game Studio 2.0 (FINAL) • Visual Studio 2005 • Windows and Xbox 360 Games (NO ZUNE) • XNA Game Studio 3.0 (CTP) • Visual Studio 2008 • Windows and Zune Games (NO XBOX 360) • Xbox Live Community Games • XNA Game Studio 4.0 • Nobody knows yet.
How NOT to make a game… • Try something really huge, like a MMORPG, for your first game.(MMORPG = Massively Multiplayer Online Role-Playing Game = World of Warcraft) • Agonize endlessly over the best way to code foo. • Trying to rewrite existing, provided XNA functionality. • Obsess over every minute detail of your game before you even have a sprite on the screen.
The point… • Start small and shoot for something achievable. • Get something on the screen. • Figure out how to move it around. • Put something else on the screen. • Make them bounce off each other • You should be able to do ALL of the above before you start killing yourself over the internal game mechanics. • If “World of Stevecraft” is your first game project, you’re going to get frustrated and never finish. Start small!
Resources • www.xnadevelopment.com Excellent Beginner Tutorials • www.ziggyware.com XNA community site with forums and contests • http://creators.xna.com/ XNA Creators Club & Forums XNA Blogs • www.thezbuffer.com Andy “The Z-Man” Dunn • http://blogs.msdn.com/shawnhar Shawn Hargreaves (XNA Team) • http://blogs.msdn.com/xna/ XNA Team blog • http://www.ILoveVB.net/web/blogs/vbxna VB XNA Project Local (to me) Community Groups • www.twincitiesxnausergroup.com Local XNA User Group • http://igda.org/wiki/index.php/IGDA_Twin_Cities Local IGDA Group