#include "gameconfig.hpp"
#include "main.hpp"
#include "resources.hpp"
+#include "script_manager.hpp"
#include "screen.hpp"
#include "timer.hpp"
running = true;
while(running) {
if(next_screen.get() != NULL) {
- if(nextpush)
+ if(nextpush && current_screen.get() != NULL) {
+ current_screen->leave();
screen_stack.push_back(current_screen.release());
+ }
next_screen->setup();
+ ScriptManager::instance->fire_wakeup_event(ScriptManager::SCREEN_SWITCHED);
current_screen.reset(next_screen.release());
next_screen.reset(NULL);
nextpush = false;
elapsed_time *= speed;
game_time += elapsed_time;
+ ScriptManager::instance->update();
current_screen->update(elapsed_time);
-
+
main_controller->update();
SDL_Event event;
while(SDL_PollEvent(&event)) {