-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUndertaleEngine.cpp
More file actions
113 lines (76 loc) · 2.25 KB
/
UndertaleEngine.cpp
File metadata and controls
113 lines (76 loc) · 2.25 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
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
// UndertaleEngine.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <SFML/Graphics.hpp>
#include "UTText.h"
#include "GlobalResources.h"
#include "GameStateManager.h"
#include "GameStateFight.h"
#ifdef UT_EDITOR
#include <imgui/imgui.h>
#include <imgui/imgui-sfml-master/imgui-SFML.h>
#endif
void update(sf::Time delta);
void draw(sf::RenderWindow& window);
unsigned int debug_FPS;
//Declared in GlobalResources.h
sf::Font dtm_mono;
sf::Font dtm_sans;
sf::Font eightbit_wonder;
sf::Font mars_need_cunnilingus;
sf::Clock globalTimer;
bool editing = false;
GameStateManager manager;
int main() {
dtm_sans.loadFromFile("assets/menu/fonts/DTM-Sans.otf");
dtm_mono.loadFromFile("assets/menu/fonts/DTM-Mono.otf");
eightbit_wonder.loadFromFile("assets/menu/fonts/8-BIT WONDER.TTF");
mars_need_cunnilingus.loadFromFile("assets/menu/fonts/Mars_Needs_Cunnilingus.ttf");
std::srand(time(nullptr));
using namespace sf;
RenderWindow window(VideoMode(640,480), "UNDERKIT", Style::Close);
std::cout << "UNDERKIT Battle Engine - by Chloe K. @trans_disaster\nPlease see LICENSE.txt for license information";
#ifdef UT_EDITOR
ImGui::SFML::Init(window);
#endif
manager.changeState(std::make_unique<GameStateFight>(GameStateFight(&manager)));
Clock deltaClock;
unsigned long frameCounter = 0;
Clock frameCounterClock;
while (window.isOpen()) {
Event event;
while (window.pollEvent(event)) {
if (event.type == Event::Closed)
window.close();
if (event.type == Event::KeyPressed) {
switch (event.key.code) {
case Keyboard::E:
editing = !editing;
break;
default:
break;
}
}
manager.event(event, window);
}
if (frameCounterClock.getElapsedTime().asSeconds() >= .25f) {
debug_FPS = frameCounter / frameCounterClock.getElapsedTime().asSeconds();
frameCounter = 0;
frameCounterClock.restart();
}
Time deltaTime(deltaClock.restart());
update(deltaTime);
draw(window);
frameCounter++;
}
}
void update(sf::Time delta) {
manager.update(delta);
}
void draw(sf::RenderWindow& window) {
#ifdef _DEBUG
manager.draw(window);
UTText debugText(dtm_sans, "FPS: " + std::to_string(debug_FPS));
window.draw(debugText);
#endif
}