-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame1.cs
85 lines (69 loc) · 2.13 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
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
#endregion
namespace Dazzer
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
StateManager level;
Player playerOne;
Grid grid;
public Game1()
: base()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Window.AllowUserResizing = true;
}
protected override void Initialize()
{
level = new StateManager();
playerOne = new Player(Content);
grid = new Grid(Content);
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
playerOne.Update();
playerOne.PCInput();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
switch(level.currentGameState)
{
case StateManager.GameState.main_Menu:
{
GraphicsDevice.Clear(Color.CornflowerBlue);
break;
}
case StateManager.GameState.game_Level:
{
GraphicsDevice.Clear(Color.White);
grid.Draw(spriteBatch);
playerOne.Draw(spriteBatch);
break;
}
}
base.Draw(gameTime);
}
}
}