-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
118 lines (81 loc) · 3.15 KB
/
Program.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
new GameLoop().Run();
// Clase Main del juego
public class GameLoop : Game
{
private GraphicsDeviceManager graphics;
private SpriteBatch spriteBatch;
private SpriteFont font;
private Scene scene = null;
private Camera camera = new Camera();
private MainMenu mainMenu;
private PauseMenu pauseMenu;
public bool isMainMenuVisible;
public bool isPauseMenuVisible;
private bool isEscapePressed = false;
public GameLoop()
{
this.graphics = new GraphicsDeviceManager(this);
this.graphics.PreferredBackBufferHeight = 855;
this.graphics.PreferredBackBufferWidth = 855;
this.graphics.GraphicsProfile = GraphicsProfile.Reach;
this.Window.AllowUserResizing = true;
this.Window.AllowAltF4 = true;
this.Content.RootDirectory = "Content";
this.IsMouseVisible = true;
}
protected override void Initialize()
{
Ground.LoadTextures(this.GraphicsDevice);
Bomb.LoadTextures(this.GraphicsDevice);
Block.LoadTextures(this.GraphicsDevice);
Player.LoadTextures(this.GraphicsDevice);
base.Initialize();
this.scene = new Scene(this.GraphicsDevice);
mainMenu = new MainMenu(GraphicsDevice);
pauseMenu = new PauseMenu(GraphicsDevice);
isMainMenuVisible = true;
isPauseMenuVisible = false;
this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
this.font = ContentUtils.LoadFont(this.GraphicsDevice, "./assets/fonts/PressStart2P.ttf");
}
protected override void Update(GameTime time)
{
if (Keyboard.GetState().IsKeyDown(Keys.Escape) && !isMainMenuVisible && !isEscapePressed)
{
isPauseMenuVisible = !isPauseMenuVisible;
isEscapePressed = true;
}
if (Keyboard.GetState().IsKeyUp(Keys.Escape) && !isMainMenuVisible && isEscapePressed)
{
isEscapePressed = false;
}
base.Update(time);
mainMenu.Update(time, this, this.spriteBatch);
pauseMenu.Update(time, this, mainMenu);
this.scene.Update(time, this);
}
protected override void Draw(GameTime time)
{
GraphicsDevice.Clear(Color.Black);
this.spriteBatch.Begin();
this.scene.Render(time, this.spriteBatch);
//this.spriteBatch.DrawString(this.font, "Bomberman", new Vector2(10, 10), Color.White, 0.0f, new Vector2(), 0.6f, SpriteEffects.None, 0);
if (isMainMenuVisible)
{
mainMenu.Draw(spriteBatch, font, this.graphics.PreferredBackBufferHeight, this.graphics.PreferredBackBufferHeight);
}
if (isPauseMenuVisible)
{
pauseMenu.Draw(spriteBatch, font, this.graphics.PreferredBackBufferHeight, this.graphics.PreferredBackBufferHeight);
}
this.spriteBatch.End();
base.Draw(time);
}
public Scene GetScene()
{
return scene;
}
}