-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cs
91 lines (68 loc) · 2.52 KB
/
Main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using CodeSummonary.Components;
using CodeSummonary.Components.Entities;
using CodeSummonary.Managers;
using CodeSummonary.Players;
using CodeSummonary.Scenes;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
namespace CodeSummonary
{
public class Main : Game
{
internal GraphicsDeviceManager _graphics;
internal SpriteBatch _spriteBatch;
public static int GameHeight => Instance._graphics.PreferredBackBufferHeight;
public static int GameWidth => Instance._graphics.PreferredBackBufferWidth;
internal static string GamePath => Environment.CurrentDirectory;
public static Main Instance;
public static TextureManager TextureManager;
public static FontManager FontManager;
public static Scene CurrentScene;
public static MouseMenu MouseMenu;
public static Random Random;
public static Player LocalPlayer;
public static SummaryEntity MouseEntity;
public Main()
{
_graphics = new GraphicsDeviceManager(this);
_graphics.PreferredBackBufferWidth = 1500;
_graphics.PreferredBackBufferHeight = 1200;
Content.RootDirectory = "Content";
IsMouseVisible = true;
Instance = this;
Random = new Random();
TextureManager = new TextureManager();
FontManager = new FontManager();
}
protected override void Initialize()
{
TextureManager.Load();
FontManager.Load();
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
CurrentScene = new MenuScene();
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
CurrentScene.Update(gameTime);
MouseMenu?.Update(gameTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
_spriteBatch.Begin(samplerState: SamplerState.PointClamp);
CurrentScene.Draw(_spriteBatch, gameTime);
MouseMenu?.Draw(_spriteBatch, gameTime);
_spriteBatch.End();
base.Draw(gameTime);
}
}
}