1 / 9

XNA

XNA. Briana B. Morrison CSE 1302C Spring 2010. Topics. Games in XNA Structure of programs Purpose of methods Example. Games in XNA. Create a game project Shell is created for you Extensive libraries. Structure of Programs.

trisha
Télécharger la présentation

XNA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XNA Briana B. Morrison CSE 1302C Spring 2010

  2. Topics Games in XNA Structure of programs Purpose of methods Example

  3. Games in XNA • Create a game project • Shell is created for you • Extensive libraries

  4. Structure of Programs • Solution.sln - this is the solution file of the entire project. • Solution.suo - this is data file that XNA GS uses. We will not change this file. • Game1.cs - This file contains the Game1 class. This is the main file we will work with. • Game1.ico - This is the graphical icon on the title bar of the running program. • GameThumbnail.png - This is the graphical file for representing this game on the XBOX 360 console. • Program.cs - This is the container class of the Game1 class. • Solution.csproj - This is the project description file for the .slnsolution file. • bin and obj - Compile result. As the names suggests, objcontains the compile object files, while bin contains the executable binary files. • Properties/AssemblyInfo.cs - Description for the project, e.g., name to appear on the window title bar. • Content/Content.contentproj - This is the content project description file. Fonts, file texture images, and audio wave files are examples of contents. • Content/bin and obj - Build results from the content project.

  5. Methods Program.cs • container class for the Game1.cs class • Creates instance of Game1 and runs Game1.cs: this is the source code we will work with. Notice there are six functions: • Game1( ): this is the constructor. • Initialize( ): initialize the application state. • LoadContent( ): load contents (e.g., audio file, file texture images, and fonts). • UnloadContent( ): Unload contents as the application exists. • Update( ): updates the application's state • Draw( ): draws the application's state

  6. To Create Your Game Most notably, you need to handle: • Constructor - initialize and set up variables as usual • LoadContent - load SpriteFont, Texture2D, etc. • Update - handle all user input and update game state • Draw - handle drawing the images/graphics to the screen • Note that NO drawing should happen in Update, and no input/state changes should happen in Draw.

  7. Things to Remember • Draw your assets (using transparent backgrounds if desired) in your favorite paint program. GIMP and Paint.NET are both free • Add your assets to the Content folder and then add them to your project (via "Project | Add | Add Existing...") • Create attributes within the class to hold the assets • Load the assets into the attributes in the LoadContent method • Handle user input (via the GetState method of the Keyboard class) • Draw icons/sprites to the screen (via the Draw method of the SpriteBatch class) • Draw strings to the screen (via the DrawString method of the SpriteBatch class) • Be sure to place all screen manipulation inside the Begin/End methods of the SpriteBatch class • Generate random values via the Next method of the Random class • List<> is a parameterized collection class that is useful for storing dynamic collections of items; use the Add, Remove, RemoveAt, etc. methods

  8. More information • Detailed steps in 7 audio/video tutorials on course website under Announcements

  9. Questions?

More Related