-
Notifications
You must be signed in to change notification settings - Fork 1
/
Drawing.cs
48 lines (40 loc) · 1.53 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
46
47
48
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Mono3D
{
public static class Drawing
{
// Size of grid
public const int Grid = 4;
// Width and height of grid
public const int GridWidth = 128;
public const int GridHeight = 128;
// Width and height of screen
public const int Width = Grid * GridWidth;
public const int Height = Grid * GridHeight;
private static Texture2D blankTexture;
private static SpriteFont arialFont;
public static void InitializeGraphics(Game1 game)
{
// Initialize screen size
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 });
// Import arial font
arialFont = game.Content.Load<SpriteFont>("Arial");
}
// Draws given rect with given color to sprite batch
public static void DrawRect(Rectangle rect, Color color, Game1 game)
{
game.SpriteBatch.Draw(blankTexture, rect, null, color);
}
// Draws given text at given position
public static void DrawText(string text, Vector2 position, Color color, Game1 game)
{
game.SpriteBatch.DrawString(arialFont, text, position, color);
}
}
}