Session 1 XNA

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

XNA Programming for Games Development:

XNA Programming for Games Development Session One

Creating a Project:

Creating a Project

Adding to the Content Pipeline:

Adding to the Content Pipeline

Built in Methods in Game1.cs:

Initialize LoadContent Game1 constructor Update Draw UnloadContent Built in Methods in Game1.cs

Structures:

// Structure for static 2D graphics struct graphic2d { public Texture2D image; // Texture which holds the 2D graphic public Rectangle rect ; // Rectangle to hold size and position } graphic2d background; background.rect.X = 50; background.rect.Y = 150; background.rect.Height = 100; Background.rect.Width = 200; background.image = Content.Load <Texture2D>(“ fullmoon ”); spriteBatch.Draw ( background.image , background.rect , Color.White ); Structures

Moving a graphic:

Position Rectangle, Vector2 or Vector3? Origin (Vector2) Rotation (float) Degrees or Radians? Direction (Vector2 or Vector3) Velocity (Vector2 or Vector3) Moving a graphic

Drawing Text:

The main thing to keep in mind when drawing text on the screen is that the game window size can vary. So you if want to draw the word “Score” in the top right of the screen. You should not fix its position as say X=600, you should set it to something like X=displaywidth-100. spriteBatch.DrawString ( mainfont , "Score " + score.ToString (), new Vector2(displaywidth/2 - 50, 25), Color.White ); Drawing Text

Practical Exercises:

Pages 3 to 11 Exercise 1 Exercise 2 Practical Exercises

authorStream Live Help