62 lines
1011 B
C++
62 lines
1011 B
C++
/*
|
|
* Application.cpp
|
|
*
|
|
* Created on: 14.01.2011
|
|
* Author: gmueller
|
|
*/
|
|
|
|
#include "Application.h"
|
|
#include "Time.h"
|
|
#include "network.h"
|
|
|
|
Application::Application() :
|
|
running(false), master(false) {
|
|
|
|
}
|
|
|
|
Application::~Application() {
|
|
|
|
}
|
|
|
|
bool Application::isRunning() {
|
|
return running;
|
|
}
|
|
|
|
void Application::start() {
|
|
running = true;
|
|
}
|
|
|
|
void Application::stop() {
|
|
running = false;
|
|
}
|
|
|
|
void Application::initialize(int argc, char ** argv) {
|
|
game_setup(&game);
|
|
game_reset(&game);
|
|
gameUpdateSchudule.setExact(true);
|
|
gameUpdateSchudule.setInterval(0.05);
|
|
start();
|
|
}
|
|
|
|
void Application::shutdown() {
|
|
shutdown_network();
|
|
}
|
|
|
|
void Application::update() {
|
|
// Get time and mouse position
|
|
time = PerformanceTimer::get();
|
|
dt = time - lastTime;
|
|
lastTime = time;
|
|
|
|
service_network(&game);
|
|
game_update(&game, dt);
|
|
if (master && gameUpdateSchudule.next(time)) {
|
|
send_game_updates(&game);
|
|
}
|
|
}
|
|
|
|
void Application::setMaster(bool master) {
|
|
this->master = master;
|
|
game_set_master(&game, master ? 1 : 0);
|
|
}
|