Created
March 12, 2016 21:12
-
-
Save FaronBracy/1b367e8fe66a45df2c5f to your computer and use it in GitHub Desktop.
Example of drawing interface elements with MonoGame that do not transform
This file contains 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
// Draw everything that will be transformed with the camera like the player, cells, etc. | |
_spriteBatch.Begin( SpriteSortMode.BackToFront, null, SamplerState.PointClamp, null, null, null, Camera.TranslationMatrix ); | |
for ( int x = minX; x < maxX; x++ ) | |
{ | |
for ( int y = minY; y < maxY; y++ ) | |
{ | |
bool isVisible = Global.GameModel.Map.Properties[x + y * Global.GameModel.Map.Width] == CellProperties.Visible; | |
Tiles[x, y].Draw( _spriteBatch, SpriteSheet, new Vector2( x * Global.CellWidth, y * Global.CellHeight ), isVisible ); | |
} | |
} | |
_spriteBatch.End(); | |
// End draw transformed elements | |
// Draw interface elements that do not scale or transform | |
_spriteBatch.Begin( SpriteSortMode.Immediate, null ); | |
string figureStatus = string.Format( "{0}{1}AP: {2}{1}HP: {3}/{4}{1}", Global.GameModel.ActiveFigure.Name, Environment.NewLine, | |
Global.GameModel.ActiveFigure.ActionPoints, Global.GameModel.ActiveFigure.CurrentHealth, | |
Global.GameModel.ActiveFigure.MaxHealth ); | |
_spriteBatch.DrawString( MainFont, figureStatus, Vector2.Zero, Color.White, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f ); | |
_spriteBatch.End(); | |
// End draw interface elements |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment