Created
June 8, 2013 22:45
-
-
Save runegri/5736893 to your computer and use it in GitHub Desktop.
A very very simple example of a MonoGame/Xna Game class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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