Post on 25-Feb-2016
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
• A Xbox 360 game library uses the compact framework
• http://msdn.microsoft.com/en-us/library/2weec7k5.aspx
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.
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
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.
File > Add > Existing Project
This what your project game solution looks like.
Lets add a new image
Browse and pick the png
Add the declaration
Initialize it
Add a position for the dot
Add the draw
Run it to test
Now add a class to the library – call it Collision
Add this method and build
Add the reference to the library in the game
Import the namespace
Add 2 bounding boxes for the 2 sprites in the Update method
Add the call to the class library and change the texture of the dot
Run it to test
Does the dot turn into a butterfly?
Now let’s add soundRight click on content > Add Existing Item
Add the declarations
Initialize it
Add it to the collision
Now test
More links about sound
• http://msdn.microsoft.com/en-us/library/bb195053.aspx
• http://msdn.microsoft.com/en-us/library/dd231915.aspx
That’s all sweet but I wanna blow things up.
• Ok – follow me.
Add a sprite sheet for the animation
Add a new sound
Change the sound name to the explosion asset name
Add the declarations for the animated sprite
Change the collision
Add an if statement for the timer in update
Change the draw method
Run it and see what happens