Zepha/src/client/Client.cpp

45 lines
945 B
C++
Raw Normal View History

#include <iostream>
#include "Client.h"
#include "util/Types.h"
#include "scene/ConnectScene.h"
#include "scene/MainMenuScene.h"
Client::Client(ivec2 window) :
2020-11-08 22:57:34 -08:00
renderer(window) {
std::cout << Log::info << "Starting Zepha Client." << Log::endl;
scene.setScene(make_unique<MainMenuScene>(*this));
2021-09-01 12:18:21 -07:00
while (!renderer.window.shouldClose())
{
loop();
}
}
f64 Client::getDelta() {
2020-11-08 22:57:34 -08:00
return delta;
}
void Client::startLocalServer(const string& subgame) {
// TODO: Implement Local Server
// localServer = std::make_shared<LocalServerInstance>(executablePath, addr.port, state.subgame);
// localServer->start();
2020-11-08 22:57:34 -08:00
scene.setScene(make_unique<ConnectScene>(*this, Address { "127.0.0.1", Address::DEFAULT_PORT }));
}
void Client::loop() {
f64 now = glfwGetTime();
2020-11-08 22:57:34 -08:00
delta = now - timeElapsed;
timeElapsed = now;
glfwPollEvents();
scene.update();
renderer.update(delta);
2021-09-23 23:16:23 -07:00
game->textures.update();
2021-07-07 15:39:04 -07:00
renderer.swapBuffers();
}