-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dungeontest.cs
94 lines (76 loc) · 2.78 KB
/
Dungeontest.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
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Dungeontest
{
public class Dungeontest : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Screen currentScreen;
public Dungeontest()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Window.AllowUserResizing = true;
// Fixes the weird update issues and allows the game run at higher frame rates
IsFixedTimeStep = false;
}
protected override void Initialize()
{
// load content first
Console.WriteLine("\n[dungeontest] loading game content\n");
base.Initialize();
Console.WriteLine("\n[dungeontest] game content loaded\n");
// create main menu
Console.WriteLine("\n[dungeontest] main menu loading\n");
currentScreen = new Start();
Console.WriteLine("\n[dungeontest] main menu loaded\n");
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
Tool.CreateBackground(GraphicsDevice);
Tool.Font = Content.Load<SpriteFont>("Fonts/default");
CoreGame.roofTextureData = new TextureData("Content/Sprites/roof.png");
// Load mods
ModHandler.LoadMods();
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
protected override void Update(GameTime gameTime)
{
// Exiting game
if (currentScreen.RequestExit)
Exit();
if (IsActive)
{// Window has focus
// Update input
Input.Update(Window.ClientBounds);
// Hide the mouse if it is locked to the center
IsMouseVisible = !Input.lockMouse;
}
if (Input.Tapped(Keys.F11))
{// Pressed F11
// Fullscreen game
graphics.IsFullScreen = !graphics.IsFullScreen;
graphics.ApplyChanges();
}
// Get the deltaTime
Dungeon.deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
// Update the screen
currentScreen = currentScreen.Update(Dungeon.deltaTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
// Draw the current screen
currentScreen.Draw(GraphicsDevice, spriteBatch);
base.Draw(gameTime);
}
}
}