2020-07-06 18:34:59 -07:00
|
|
|
#include <iostream>
|
|
|
|
|
2019-07-11 23:50:24 -07:00
|
|
|
#include "Client.h"
|
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
#include "util/Types.h"
|
2020-07-06 14:00:46 -07:00
|
|
|
#include "scene/ConnectScene.h"
|
|
|
|
#include "scene/MainMenuScene.h"
|
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
Client::Client(ivec2 window) :
|
2020-11-08 22:57:34 -08:00
|
|
|
renderer(window) {
|
|
|
|
|
|
|
|
std::cout << Log::info << "Starting Zepha Client." << Log::endl;
|
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
scene.setScene(make_unique<MainMenuScene>(*this));
|
2021-09-01 12:18:21 -07:00
|
|
|
while (!renderer.window.shouldClose())
|
|
|
|
{
|
|
|
|
loop();
|
|
|
|
}
|
2019-07-11 23:50:24 -07:00
|
|
|
}
|
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
f64 Client::getDelta() {
|
2020-11-08 22:57:34 -08:00
|
|
|
return delta;
|
2020-11-03 23:29:30 -08:00
|
|
|
}
|
2019-07-11 23:50:24 -07:00
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
void Client::startLocalServer(const string& subgame) {
|
2021-09-02 23:48:09 -07:00
|
|
|
// TODO: Implement Local Server
|
2020-11-03 23:29:30 -08:00
|
|
|
// localServer = std::make_shared<LocalServerInstance>(executablePath, addr.port, state.subgame);
|
|
|
|
// localServer->start();
|
2020-11-08 22:57:34 -08:00
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
scene.setScene(make_unique<ConnectScene>(*this, Address { "127.0.0.1", Address::DEFAULT_PORT }));
|
2019-07-11 23:50:24 -07:00
|
|
|
}
|
|
|
|
|
2020-11-03 23:29:30 -08:00
|
|
|
void Client::loop() {
|
2021-06-21 22:09:35 -07:00
|
|
|
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();
|
2019-07-11 23:50:24 -07:00
|
|
|
}
|