65 lines
1.8 KiB
C++
65 lines
1.8 KiB
C++
#include "client/window.h"
|
|
#include <deerith/core/log.h>
|
|
|
|
#include <deerith/graphics/window.h>
|
|
#include <deerith/graphics/primitive.h>
|
|
#include <deerith/graphics/input.h>
|
|
#include <deerith/universe.h>
|
|
#include <deerith/engine.h>
|
|
|
|
#include <imgui/imgui.h>
|
|
|
|
glm::vec2 player_pos(5, 5);
|
|
char net_address[16] = "127.0.0.1";
|
|
int port = 8080;
|
|
float vel = 1;
|
|
|
|
void start_window_loop()
|
|
{
|
|
deerith_assert(deerith::init_window() == 0, "Failed to init_window");
|
|
|
|
while (deerith::begin_window_display())
|
|
{
|
|
deerith::define_primitive_viewspace(glm::vec2(0, 0), glm::vec2(10 * deerith::get_window_aspect_ratio(), 10));
|
|
|
|
player_pos += deerith::get_joystick_axes(0, 0) * (vel / 60.0f);
|
|
|
|
deerith::define_primitive_color(glm::vec4(0.4f, 0.7f, 1.0f, 1));
|
|
deerith::draw_primitive_rectangle(player_pos - glm::vec2(0.5f, 0.5f), player_pos + glm::vec2(0.5f, 0.5f));
|
|
|
|
if (ImGui::Begin("Context"))
|
|
{
|
|
ImGui::SliderFloat("Velocity", &vel, 0, 4);
|
|
|
|
if (deerith::is_universe_running())
|
|
{
|
|
ImGui::Text("Universe running");
|
|
}
|
|
else
|
|
{
|
|
ImGui::InputText("Net Address", net_address, 16);
|
|
ImGui::InputInt("Net port", &port);
|
|
|
|
if (ImGui::Button("Connect"))
|
|
{
|
|
deerith::begin_connection_to_universe(net_address, port);
|
|
}
|
|
|
|
if (ImGui::Button("Create server"))
|
|
{
|
|
deerith::execute_server("./SandboxServer", 8080);
|
|
}
|
|
|
|
if (ImGui::Button("Close all servers"))
|
|
{
|
|
deerith::shutdown_executing_servers();
|
|
}
|
|
}
|
|
}
|
|
ImGui::End();
|
|
|
|
deerith::finish_window_display();
|
|
}
|
|
|
|
deerith::shutdown_window();
|
|
} |