-
Notifications
You must be signed in to change notification settings - Fork 30
/
Game1.cs
54 lines (42 loc) · 1.32 KB
/
Game1.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
49
50
51
52
53
54
namespace Challenge005;
public class Game1 : Game
{
private readonly GraphicsDeviceManager _graphics;
private GameManager _gameManager;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
Globals.WindowSize = new(512, 512);
_graphics.PreferredBackBufferWidth = Globals.WindowSize.X;
_graphics.PreferredBackBufferHeight = Globals.WindowSize.Y;
_graphics.ApplyChanges();
Globals.Content = Content;
base.Initialize();
}
protected override void LoadContent()
{
Globals.SpriteBatch = new SpriteBatch(GraphicsDevice);
Globals.GraphicsDevice = GraphicsDevice;
_gameManager = new();
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
Globals.Update(gameTime);
InputManager.Update();
_gameManager.Update();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{;
GraphicsDevice.Clear(Color.Gray);
_gameManager.Draw();
base.Draw(gameTime);
}
}