-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoomEngine.cs
More file actions
88 lines (68 loc) · 2.28 KB
/
DoomEngine.cs
File metadata and controls
88 lines (68 loc) · 2.28 KB
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
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Doom;
public class DoomEngine : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
public DoomEngine(string wadPath = "content/doom1.wad")
{
_graphics = new GraphicsDeviceManager(this);
_graphics.PreferredBackBufferWidth = Settings.Width;
_graphics.PreferredBackBufferHeight = Settings.Height;
_graphics.IsFullScreen = false;
Content.RootDirectory = "Content";
IsFixedTimeStep = true;
TargetElapsedTime = TimeSpan.FromSeconds(1d / Settings.TargetFps);
IsMouseVisible = true;
_graphics.ApplyChanges();
WADPath = wadPath;
}
public string WADPath { get; init; }
public WADData WADData { get; private set; }
public MapRenderer MapRenderer { get; private set; }
public Player Player { get; private set; }
public BSP BSP { get; private set; }
public ViewRenderer ViewRenderer { get; private set; }
public SegHandler SegHandler { get; private set; }
protected override void Initialize()
{
WADData = new WADData(this, Settings.StartMap);
Player = new Player(this);
ViewRenderer = new ViewRenderer(this);
SegHandler = new SegHandler(this);
BSP = new BSP(this);
MapRenderer = new MapRenderer(this);
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
Player.Update(gameTime);
SegHandler.Update(gameTime);
BSP.Update(gameTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
_spriteBatch.Begin();
if (Settings.UseMapRenderer)
{
MapRenderer.Draw(_spriteBatch);
}
else
{
ViewRenderer.Draw(_spriteBatch);
}
_spriteBatch.End();
base.Draw(gameTime);
}
}