Code Complete

  • General Game Structure:

    • Preparing the environment where the game will run
    • Running the game loop until the game ending criteria is met and then cleaning up the environment
    • Pseudo Code for the game loop:

  • The args argument on the Main function receives the command-line parameters used when calling the game. If you wish to include command-line arguments in your game—such as special cheat codes for helping you test the game—this is where you need to deal with them
  • Game Initialization:

    • The class starts by defining and creating objects that will reference the graphics device manager, most commonly referred to in the gaming world as device
    • SpriteBatch object used to draw text and 2-D images
    • The Graphics Device Manager:

      • Represents the way to manage the access to the graphic card feature
    • The Content Pipeline Manager:

      • Loads all game content so you can deal with it easily
  • The importers supports the following files formats:

    • 3-D File Format:

      • X (used by DirectX), FBX (supported by many freeware tools)
    • Material File Formats:

      • FX (effects file, describes 3-D model rendering details or add effects to the 3-D scene
    • 2-D File Formats:

      • BMP, DDS, DIB, HDR, JPG, PFM and TGA (the most commonly used)
    • Font Description:

      • SPRITEFONT (XML files that describes how to generate a texture map from specific font type size. The game use this to write text on screen)
    • Audio File Formats:

      • XAP (generated by XACT which imports most of the audio file formats)
  • The processors convert these content into objects that the game can handle easily
  • You can add new importers and processors to the content pipeline manager
  • Initialize Method:

    • Is called once the execute Run method
    • Here you can include any non-graphical initialization routines like sound
  • LoadContent Method:

    • This method iterates on each of the game objects and initialize them
  • Graphics are loaded into other method
  • Game Finalization:

    • UnloadContent:

      • Used to free any graphics the game using
  • Game Loop:

    • Here the following happens:

      • Checks if there is a player input process
      • The game AI is calculated
      • The game components movement are executed
      • The collision is considered
      • The game ending criteria is checked
      • While the controller vibration is activated, sounds played and screen drawn
    • Update method includes game calculations and Draw includes game components
    • The gameTime object decides how much time has passed since the last step on the game loop to do the right calculations
    • GameTime Class Properties:

      • ElapsedGameTime
      • ElapsedReadTime
      • TotalGameTime and TotalRealTime
      • IsRunningSlowly
  • Commonly used Gaming Terms:

    • Sprite:

      • Image that could be manipulated independently of the rest of the game scene
      • Animated Sprite: set of movements of a sprite
    • Textures:

      • This means 2-D image loaded over 3-D model
      • It helps in developing illusions of highly detailed models
    • Billboard:

      • If the game background is moving image then it called scrolling background. The parallax scrolling in which the game has many scrolling backgrounds with different scrolling speed
    • Tiles:

      • These images are used to compose a bigger image usually a level background
  • 2-D Screen Coordinate System:

    • The origin is in the left upper of the screen, while you go down Y’s increase and while you go right X’s increase
    • The screen coordinates are directly related to the screen resolution
    • 800 × 900 means that X-Axis has 800 pixels (points) and Y-Axis have 900 pixels
  • Drawing A Sprite Using XNA:

    • Texels are the smallest unit can be stored on graphics board
  • Moving The Sprite on the Screen:
  • Coding For Collision Detection:

    • We will use bounding boxes collision detection algorithm
  • Get Input:

    • KeyboardState is the responsible for this job
  • Sounds:

    • We use XACT to create sounds
    • They are compiled in XAP extension
    • To include sound in your program you should define these objects:

      • AudioEngine, WaveBank and SoundBank

Cure object is used to play pause and resume sounds