2011-10-31 05:36:24 +00:00
#region Using Statements
using System ;
using System.Collections.Generic ;
using System.Linq ;
using ANX.Framework ;
using ANX.Framework.Graphics ;
using ANX.Framework.Input ;
#endregion // Using Statements
2012-08-09 09:45:04 +00:00
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
2011-10-31 05:36:24 +00:00
namespace TextRendering
{
public class Game1 : ANX . Framework . Game
{
GraphicsDeviceManager graphics ;
SpriteBatch spriteBatch ;
SpriteFont debugFont ;
2012-09-11 13:51:20 +00:00
int fps = 60 ;
int fpsCount = 0 ;
float fpsTimer = 0f ;
2011-10-31 05:36:24 +00:00
public Game1 ( )
{
graphics = new GraphicsDeviceManager ( this ) ;
2011-12-05 13:43:15 +00:00
graphics . PreparingDeviceSettings + = new EventHandler < PreparingDeviceSettingsEventArgs > ( graphics_PreparingDeviceSettings ) ;
2011-10-31 05:36:24 +00:00
Content . RootDirectory = "SampleContent" ;
2012-09-11 13:51:20 +00:00
IsFixedTimeStep = false ;
graphics . SynchronizeWithVerticalRetrace = false ;
2011-10-31 05:36:24 +00:00
}
2011-12-05 13:43:15 +00:00
void graphics_PreparingDeviceSettings ( object sender , PreparingDeviceSettingsEventArgs e )
{
e . GraphicsDeviceInformation . PresentationParameters . BackBufferWidth = 1280 ;
e . GraphicsDeviceInformation . PresentationParameters . BackBufferHeight = 720 ;
}
2011-10-31 05:36:24 +00:00
protected override void Initialize ( )
{
2011-12-05 10:00:33 +00:00
//GraphicsDevice.PresentationParameters.BackBufferWidth = 1280;
//GraphicsDevice.PresentationParameters.BackBufferHeight = 720;
//GraphicsDevice.Reset();
2011-11-09 19:39:21 +00:00
2011-10-31 05:36:24 +00:00
base . Initialize ( ) ;
}
protected override void LoadContent ( )
{
spriteBatch = new SpriteBatch ( GraphicsDevice ) ;
this . debugFont = Content . Load < SpriteFont > ( @"Fonts/Debug" ) ;
}
protected override void Update ( GameTime gameTime )
{
if ( GamePad . GetState ( PlayerIndex . One ) . Buttons . Back = = ButtonState . Pressed )
this . Exit ( ) ;
2012-09-11 13:51:20 +00:00
fpsCount + + ;
fpsTimer + = ( float ) gameTime . ElapsedGameTime . TotalSeconds ;
if ( fpsTimer > = 1f )
{
fpsTimer - = 1f ;
fps = fpsCount ;
fpsCount = 0 ;
}
2011-10-31 05:36:24 +00:00
base . Update ( gameTime ) ;
}
protected override void Draw ( GameTime gameTime )
{
GraphicsDevice . Clear ( Color . CornflowerBlue ) ;
spriteBatch . Begin ( SpriteSortMode . FrontToBack , null ) ;
2012-09-11 13:51:20 +00:00
spriteBatch . DrawString ( this . debugFont , "Hello World! FPS: " + fps , new Vector2 ( 100 , 100 ) , Color . White ) ;
2011-10-31 05:36:24 +00:00
2011-11-02 16:01:05 +00:00
spriteBatch . DrawString ( this . debugFont , "This screen is powered by the ANX.Framework!\r\nsecond line" , new Vector2 ( 100 , 100 + this . debugFont . LineSpacing ) , Color . Black , 0.0f , new Vector2 ( 1 , - 1 ) , Vector2 . One , SpriteEffects . None , 0.0f ) ;
spriteBatch . DrawString ( this . debugFont , "This screen is powered by the ANX.Framework!\r\nsecond line" , new Vector2 ( 100 , 100 + this . debugFont . LineSpacing ) , Color . Red , 0.0f , Vector2 . Zero , Vector2 . One , SpriteEffects . None , 1.0f ) ;
2011-11-21 06:22:29 +00:00
spriteBatch . DrawString ( this . debugFont , "Mouse X: " + Mouse . GetState ( ) . X , new Vector2 ( 100 , 100 + this . debugFont . LineSpacing * 3 ) , Color . DarkOrange ) ;
2012-03-10 11:52:21 +00:00
spriteBatch . DrawString ( this . debugFont , "Mouse Y: " + Mouse . GetState ( ) . Y , new Vector2 ( 100 , 100 + this . debugFont . LineSpacing * 4 ) , Color . DarkOrange ) ;
2011-11-02 16:01:05 +00:00
spriteBatch . DrawString ( this . debugFont , "rotated Text" , new Vector2 ( 100 , 150 ) , Color . Green , MathHelper . ToRadians ( 90 ) , Vector2 . Zero , 1.0f , SpriteEffects . None , 1.0f ) ;
2011-11-21 06:22:29 +00:00
GamePadState state = GamePad . GetState ( PlayerIndex . One ) ;
spriteBatch . DrawString ( this . debugFont , String . Format ( "GamePad Left: {0} Right: {1}" , state . ThumbSticks . Left , state . ThumbSticks . Right ) , new Vector2 ( 100 , 100 + this . debugFont . LineSpacing * 5 ) , Color . Red , 0.0f , Vector2 . Zero , Vector2 . One , SpriteEffects . None , 1.0f ) ;
2011-10-31 05:36:24 +00:00
spriteBatch . End ( ) ;
base . Draw ( gameTime ) ;
}
}
}