Xna … let’s play !
Agenda
• programming concepts .
•about Xna .
• General game concepts .
• installing Xna .
•First Xna game .
•Explore the code .
•Let’s make a game .
programming concepts
•
•
•
•
•
•

What is programming .
C# language .
Data types .
conditions & loops .
Data structure .
OOP .
about Xna
• Framework developed by Microsoft .
• No more support from Microsoft by 2014  .
• So we will code 2D games with Xna and to go
deeper(3D) we will turn to OpenGL .
General game concepts
• Game initialization .
• Load content .
• Game loop :
1- update () .
2- draw () .
installing Xna
• Microsoft .Net Framework 4.0
• Visual studio 2010 c# .
• XNA Game Studio 4.0 .
First Xna game
Let’s build our first Xna Game ! 
Explore the code
•
•
•
•
•
•
•

Declaration area .
Constructor .
Initialization .
Load content .
Unload content .
Update .
Draw .
Let’s make a game
• Load sprites .
• Move sprites .
• Collision detection .
References
• Coursera Xna course .
• XNA 4.0 Game Development by Example Beginner's Guide book .
• A Simple Introduction to Game Programming With
C# and XNA 3.1 book .
Thank You

introduction to Xna

Editor's Notes

  • #5 1- This method only runs once, The Initialize() method is the ideal place to set up things like the screen resolution, toggle full screen mode, and enable the mouse in a Windows project. Other game objects that do not rely on external content such as graphics and sound resources can also be initialized here.2- Part of the responsibility of the base Initialize() method is to call LoadContent() when the normal initialization has completed. The method is used to read in any graphical and audio resources your game will need. The default LoadContent() method is also where the spriteBatch object gets initialized. You will use the spriteBatch instance to draw objects to the screen during execution of the Draw() method.3.1- Once LoadContent() has finished doing its job, an XNA game enters an endless loop in which it attempts to call the Update() method 60 times per second. if your Update() logic starts to take too long to run, your game will begin skipping calls to the Draw() method in favour of multiple calls to Update() in an attempt to catch up with the current game time. ? All of your game logic gets built into the Update() method. It is here that you check for player input, move sprites, spawn enemies, track scores, and everything else except draw to the display. Update() receives a single parameter called gameTime, which can be used to determine how much time has elapsed since the previous call to Update() or to determine if your game is skipping Draw() calls by checking its IsRunningSlowly property.3.1- The final method in the default Game1.cs file is responsible, not surprisingly, for drawing the current game state to the display. Draw() is normally called once after each call to Update() unless something is happening to slow down the execution of your game. In that case, Draw() calls may be skipped in order to call Update() more frequently. There will always be at least one call to Update() between calls to Draw(), however, as sequential Draw() calls would provide no benefit—nothing in the game state will have changed.
  • #7 Build a windows game in VS 2010 .
  • #8 Declare objects and variables .Create game object .- Initialize game world + external content .- Load graphics / sound effects .- Update game world + exit from game .- Draw all visible entities in the game .
  • #9 resize resolution >> constructor Declare objects >> Declaration area Load content >> load contentDraw >> draw sprites