-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameRoot.cs
69 lines (53 loc) · 1.65 KB
/
GameRoot.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using NeonVectorShooter.Entities;
namespace NeonVectorShooter;
public class GameRoot : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
public static GameRoot Instance { get; private set; }
public static Viewport Viewport => Instance.GraphicsDevice.Viewport;
public static Vector2 ScreenSize => new Vector2(Viewport.Width, Viewport.Height);
public GameRoot()
{
Instance = this;
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
EntityManager.Add(PlayerShip.Instance);
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
Art.Load(Content);
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
Input.Update();
// TODO: Add your update logic here
base.Update(gameTime);
EntityManager.Update();
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
GraphicsDevice.Clear(Color.Black);
_spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive);
EntityManager.Draw(_spriteBatch);
_spriteBatch.Draw(Art.Pointer, Input.MousePosition, Color.White);
_spriteBatch.End();
}
}