Skip to content

Instantly share code, notes, and snippets.

@runegri
Created June 8, 2013 22:45
Show Gist options
  • Save runegri/5736893 to your computer and use it in GitHub Desktop.
Save runegri/5736893 to your computer and use it in GitHub Desktop.
A very very simple example of a MonoGame/Xna Game class
using BallZ.Levels;
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
namespace BallZ
{
public class BallZGame : Game
{
readonly GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private PrimitiveBatch _primitiveBatch;
private Camera _camera;
private GameLevel _gameLevel;
public SpriteBatch SpriteBatch { get { return _spriteBatch; } }
public PrimitiveBatch PrimitiveBatch { get { return _primitiveBatch; } }
public BallZGame()
{
_graphics = new GraphicsDeviceManager(this)
{
IsFullScreen = true,
SupportedOrientations = DisplayOrientation.Portrait,
PreferredBackBufferWidth = 480,
PreferredBackBufferHeight = 800
};
IsFixedTimeStep = false;
Content.RootDirectory = "Content";
TouchPanel.EnabledGestures = GestureType.Pinch | GestureType.Tap | GestureType.Hold;
}
protected override void Initialize()
{
_camera = new Camera(_graphics.GraphicsDevice.Viewport)
{
Pos = new Vector2(_graphics.GraphicsDevice.Viewport.Width / 2f, _graphics.GraphicsDevice.Viewport.Height / 2f)
};
base.Initialize();
}
protected override void Update(GameTime gameTime)
{
_gameLevel.Update(gameTime, _camera);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
_gameLevel.Draw(_camera);
base.Draw(gameTime);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment