-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
98 lines (68 loc) · 2.5 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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
new GameLoop().Run();
/**
* Main game class.
*
* Handles all the main logic cycles.
*/
public class GameLoop : Game
{
private GraphicsDeviceManager graphics;
private SpriteBatch spriteBatch;
private SpriteFont font;
private Scene scene = null;
private Camera camera = new Camera();
public GameLoop()
{
this.graphics = new GraphicsDeviceManager(this);
this.graphics.PreferredBackBufferHeight = 900;
this.graphics.PreferredBackBufferWidth = 900;
this.graphics.GraphicsProfile = GraphicsProfile.Reach;
this.Window.AllowUserResizing = true;
this.Window.AllowAltF4 = true;
this.Content.RootDirectory = "Content";
this.IsMouseVisible = true;
}
protected override void Initialize()
{
Fire.LoadTextures(this.GraphicsDevice);
Bomb.LoadTextures(this.GraphicsDevice);
Ground.LoadTextures(this.GraphicsDevice);
Block.LoadTextures(this.GraphicsDevice);
Player.LoadTextures(this.GraphicsDevice);
Powerup.LoadTextures(this.GraphicsDevice);
base.Initialize();
this.scene = new Scene(this.GraphicsDevice);
FieldGenerator.Generate(this.scene);
Player a = new Player(new PlayerKeyboardControls(PlayerKeyboardControls.KeysP1));
a.Position.X = 60.0f;
a.Position.Y = 60.0f;
this.scene.Add(a);
Player b = new Player(new PlayerKeyboardControls(PlayerKeyboardControls.KeysP2));
b.Position.X = 840.0f;
b.Position.Y = 840.0f;
this.scene.Add(b);
this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
this.font = ContentUtils.LoadFont(this.GraphicsDevice, "./assets/fonts/PressStart2P.ttf");
}
protected override void Update(GameTime time)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
{
this.Exit();
}
base.Update(time);
this.scene.Update(time);
}
protected override void Draw(GameTime time)
{
GraphicsDevice.Clear(Color.Black);
this.spriteBatch.Begin();
this.scene.Render(time, this.spriteBatch);
this.spriteBatch.DrawString(this.font, "BomberGuy", new Vector2(10, 10), Color.White, 0.0f, new Vector2(), 0.6f, SpriteEffects.None, 0);
this.spriteBatch.End();
base.Draw(time);
}
}