-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drawing.cs
45 lines (37 loc) · 1.38 KB
/
Drawing.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Mono2D
{
public static class Drawing
{
// Size of grid
public const int Grid = 1;
// Width and height of grid
public const int GridWidth = 512;
public const int GridHeight = 512;
// Width and height of screen
public const int Width = GridWidth * Grid;
public const int Height = GridHeight * Grid;
private static Texture2D blankTexture;
private static SpriteFont arialFont;
public static void InitializeGraphics(Game1 game)
{
// Initialize graphics
game.Graphics.PreferredBackBufferWidth = Width;
game.Graphics.PreferredBackBufferHeight = Height;
game.Graphics.ApplyChanges();
// Initialize blank texture
blankTexture = new Texture2D(game.GraphicsDevice, 1, 1);
blankTexture.SetData(new[] { Color.White });
arialFont = game.Content.Load<SpriteFont>("Arial");
}
public static void DrawRect(Rectangle rect, Color color, Game1 game)
{
game.SpriteBatch.Draw(blankTexture, rect, color);
}
public static void DrawText(string text, Vector2 position, Color color, Game1 game)
{
game.SpriteBatch.DrawString(arialFont, text, position, color);
}
}
}