Added AsloEngine 0.9.0 to Repository
This commit is contained in:
parent
d017dd84b3
commit
881e6c70f2
60 changed files with 2648 additions and 0 deletions
94
asloengine/core.cpp
Executable file
94
asloengine/core.cpp
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
#include "headers/core.hpp"
|
||||
|
||||
namespace asloengine
|
||||
{
|
||||
|
||||
static sf::RenderWindow *main_window;
|
||||
|
||||
void init(Scene *starting_scene)
|
||||
{
|
||||
|
||||
LOG("START Init");
|
||||
|
||||
main_window = new sf::RenderWindow(sf::VideoMode(RESOLUTION_X, RESOLUTION_Y, BIT_DEPTH),
|
||||
PROGRAM_INFO, sf::Style::Fullscreen);
|
||||
|
||||
main_window->setVerticalSyncEnabled(VSYNC_ENABLED);
|
||||
main_window->setFramerateLimit(MAX_FRAMERATE);
|
||||
|
||||
SceneManager::load_scene(starting_scene);
|
||||
|
||||
LOG("END Init");
|
||||
|
||||
}
|
||||
|
||||
void start_main_game_loop()
|
||||
{
|
||||
|
||||
LOG("START Main Game Loop");
|
||||
|
||||
sf::Clock clock;
|
||||
bool quitting = false;
|
||||
|
||||
SceneManager::scene->start(main_window);
|
||||
|
||||
// Main Game Loop
|
||||
while (main_window->isOpen())
|
||||
{
|
||||
|
||||
Keyboard::entered_text = 0;
|
||||
Mouse::mouse_wheel_delta = 0;
|
||||
|
||||
// Process Events
|
||||
sf::Event event;
|
||||
while (main_window->pollEvent(event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
|
||||
case sf::Event::Closed:
|
||||
SceneManager::unload_scene();
|
||||
quitting = true;
|
||||
main_window->close();
|
||||
break;
|
||||
|
||||
case sf::Event::TextEntered:
|
||||
Keyboard::entered_text = event.text.unicode;
|
||||
break;
|
||||
|
||||
case sf::Event::MouseWheelScrolled:
|
||||
Mouse::mouse_wheel_delta = event.mouseWheelScroll.delta;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
main_window->clear();
|
||||
|
||||
// Scene Drawing
|
||||
if (SceneManager::scene != NULL)
|
||||
{
|
||||
SceneManager::scene->update(clock.restart().asSeconds());
|
||||
SceneManager::scene->draw();
|
||||
} else if (!quitting) {
|
||||
WARN("no scene loaded (pointer refering to nothing)");
|
||||
}
|
||||
|
||||
main_window->display();
|
||||
|
||||
// Load Next Scene if Requested
|
||||
if (SceneManager::next_scene != NULL)
|
||||
{
|
||||
SceneManager::load_scene(SceneManager::next_scene, main_window);
|
||||
SceneManager::next_scene = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delete main_window;
|
||||
|
||||
LOG("END Main Game Loop");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue