Skip navigation

This is what I use

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

public class Game1 : Microsoft.Xna.Framework.Game
{
  GraphicsDeviceManager graphics;
  SpriteBatch spriteBatch;

  public Game1()
  {
    graphics = new GraphicsDeviceManager( this );
    Content.RootDirectory = "Content";

    this.IsMouseVisible = true ;
  }

  protected override void LoadContent()
  {
    spriteBatch = new SpriteBatch( GraphicsDevice );

  }

  protected override void Update( GameTime gameTime )
  {
    // Allows the game to exit
    if( Keyboard.GetState().IsKeyDown( Keys.Escape ) )
      this.Exit();

    base.Update( gameTime );
  }

  protected override void Draw( GameTime gameTime )
  {
    GraphicsDevice.Clear( Color.CornflowerBlue );

    base.Draw( gameTime );
  }
}

ALSO, I wrap BasicEffect in something I call SimpleEffect. Its also less annoying when you’re just trying to get prims on the screen quick.


public class SimpleEffect : BasicEffect
{
  public SimpleEffect( GraphicsDevice gpu, EffectPool ep )
    : base( gpu, ep )
  {

  }

  public new void Begin()
  {
    base.Begin();

    this.CurrentTechnique.Passes[ 0 ].Begin();
  }

  public new void End()
  {
    this.CurrentTechnique.Passes[ 0 ].End();

    base.End();
  }

}

Leave a comment