-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame1.cs
93 lines (72 loc) · 2.44 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
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
92
93
namespace SummonersTale
{
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using SummonersTale.Components;
using SummonersTale.GameStates;
using SummonersTale.StateManager;
public class Game1 : Game
{
static Rectangle screenRectangle;
protected GraphicsDeviceManager graphics;
private SpriteBatch spriteBatch;
GameStateManager gameStateManager;
ITitleIntroState titleIntroState;
IMainMenuState mainMenuState;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
// Defining the game window size
screenRectangle = new Rectangle(0, 0, 1280, 720);
graphics.PreferredBackBufferWidth = ScreenRectangle.Width;
graphics.PreferredBackBufferHeight = ScreenRectangle.Height;
gameStateManager = new GameStateManager(this);
Components.Add(gameStateManager);
this.IsMouseVisible = true;
titleIntroState = new TitleIntroState(this);
mainMenuState = new MainMenuState(this);
gameStateManager.ChangeState((TitleIntroState)titleIntroState, PlayerIndex.One);
}
public static Rectangle ScreenRectangle
{
get { return screenRectangle; }
}
public SpriteBatch SpriteBatch
{
get { return spriteBatch; }
}
public ITitleIntroState TitleIntroState
{
get { return titleIntroState; }
}
public IMainMenuState MainMenuState
{
get { return mainMenuState; }
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void Initialize()
{
Components.Add(new InputState(this));
base.Initialize();
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
Keyboard.GetState().IsKeyDown(Keys.Escape))
{
Exit();
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
base.Draw(gameTime);
}
}
}