XNA

40
XNA An Introduction

description

XNA. An Introduction. You will need 2 projects for your solution for your game. A class library And a Game project. File > New Project > Windows Game Library. Why are there 2 types of libraries?. Because. A windows game library uses the full .NET Framework - PowerPoint PPT Presentation

Transcript of XNA

Page 1: XNA

XNA

An Introduction

Page 2: XNA

You will need 2 projects for your solution for your game

• A class library• And a Game project

Page 3: XNA

File > New Project > Windows Game Library

Page 4: XNA

Why are there 2 types of libraries?

Page 5: XNA

Because

• A windows game library uses the full .NET Framework

• A Xbox 360 game library uses the compact framework

• http://msdn.microsoft.com/en-us/library/2weec7k5.aspx

Page 6: XNA

What that means to us…

• The compact framework has about 30% of the functionality of the .NET framework

• You can do less with Xbox games than you can with Windows games

• So as you decide which platform to use you have to take this into consideration.

Page 7: XNA

Also…

• An Xbox game can be released through community games (have to be a premier member with a gold Xbox live membership)

• An Xbox game released through community games cannot be pirated

• A Windows game can be released through STEAM or you can sell it on your own website as a download, etc– http://store.steampowered.com/

• A Windows game can be pirated

Page 8: XNA

So you have 2 decisions to make

• Before you start coding and developing– What technology do I use?– How do I want to release my game?

• These questions are related.

Page 9: XNA

File > Add > Existing Project

Page 10: XNA

This what your project game solution looks like.

Page 11: XNA

Lets add a new image

Page 12: XNA

Browse and pick the png

Page 13: XNA

Add the declaration

Page 14: XNA

Initialize it

Page 15: XNA

Add a position for the dot

Page 16: XNA

Add the draw

Page 17: XNA

Run it to test

Page 18: XNA

Now add a class to the library – call it Collision

Page 19: XNA

Add this method and build

Page 20: XNA

Add the reference to the library in the game

Page 21: XNA

Import the namespace

Page 22: XNA

Add 2 bounding boxes for the 2 sprites in the Update method

Page 23: XNA

Add the call to the class library and change the texture of the dot

Page 24: XNA

Run it to test

Page 25: XNA

Does the dot turn into a butterfly?

Page 26: XNA

Now let’s add soundRight click on content > Add Existing Item

Page 27: XNA

Add the declarations

Page 28: XNA

Initialize it

Page 29: XNA

Add it to the collision

Page 30: XNA

Now test

Page 31: XNA

More links about sound

• http://msdn.microsoft.com/en-us/library/bb195053.aspx

• http://msdn.microsoft.com/en-us/library/dd231915.aspx

Page 32: XNA

That’s all sweet but I wanna blow things up.

• Ok – follow me.

Page 33: XNA

Add a sprite sheet for the animation

Page 34: XNA

Add a new sound

Page 35: XNA

Change the sound name to the explosion asset name

Page 36: XNA

Add the declarations for the animated sprite

Page 37: XNA

Change the collision

Page 38: XNA

Add an if statement for the timer in update

Page 39: XNA

Change the draw method

Page 40: XNA

Run it and see what happens