XNA
description
Transcript of XNA
![Page 1: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/1.jpg)
XNA
An Introduction
![Page 2: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/2.jpg)
You will need 2 projects for your solution for your game
• A class library• And a Game project
![Page 3: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/3.jpg)
File > New Project > Windows Game Library
![Page 4: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/4.jpg)
Why are there 2 types of libraries?
![Page 5: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/5.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/6.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/7.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/8.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/9.jpg)
File > Add > Existing Project
![Page 10: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/10.jpg)
This what your project game solution looks like.
![Page 11: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/11.jpg)
Lets add a new image
![Page 12: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/12.jpg)
Browse and pick the png
![Page 13: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/13.jpg)
Add the declaration
![Page 14: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/14.jpg)
Initialize it
![Page 15: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/15.jpg)
Add a position for the dot
![Page 16: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/16.jpg)
Add the draw
![Page 17: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/17.jpg)
Run it to test
![Page 18: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/18.jpg)
Now add a class to the library – call it Collision
![Page 19: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/19.jpg)
Add this method and build
![Page 20: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/20.jpg)
Add the reference to the library in the game
![Page 21: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/21.jpg)
Import the namespace
![Page 22: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/22.jpg)
Add 2 bounding boxes for the 2 sprites in the Update method
![Page 23: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/23.jpg)
Add the call to the class library and change the texture of the dot
![Page 24: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/24.jpg)
Run it to test
![Page 25: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/25.jpg)
Does the dot turn into a butterfly?
![Page 26: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/26.jpg)
Now let’s add soundRight click on content > Add Existing Item
![Page 27: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/27.jpg)
Add the declarations
![Page 28: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/28.jpg)
Initialize it
![Page 29: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/29.jpg)
Add it to the collision
![Page 30: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/30.jpg)
Now test
![Page 31: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/31.jpg)
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](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/32.jpg)
That’s all sweet but I wanna blow things up.
• Ok – follow me.
![Page 33: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/33.jpg)
Add a sprite sheet for the animation
![Page 34: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/34.jpg)
Add a new sound
![Page 35: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/35.jpg)
Change the sound name to the explosion asset name
![Page 36: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/36.jpg)
Add the declarations for the animated sprite
![Page 37: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/37.jpg)
Change the collision
![Page 38: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/38.jpg)
Add an if statement for the timer in update
![Page 39: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/39.jpg)
Change the draw method
![Page 40: XNA](https://reader035.fdocuments.us/reader035/viewer/2022062521/56816933550346895de0880c/html5/thumbnails/40.jpg)
Run it and see what happens