Hacked the simulation in (ugly include path, but heck)
This commit is contained in:
parent
b949a9d5a8
commit
47b43e7f33
3 changed files with 44 additions and 2 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -19,3 +19,7 @@ linux-packages
|
|||
.kdev4
|
||||
|
||||
windows\-installer/*.bmp
|
||||
|
||||
game-resources
|
||||
motor
|
||||
sc-includes
|
||||
|
|
|
@ -24,6 +24,13 @@ namespace games {
|
|||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
void Client::add_line(AbstractLine const & line){
|
||||
lines.push_back(line);
|
||||
for(auto & l : line.calculate_lines()){
|
||||
sim.lines.push_back(l);
|
||||
}
|
||||
}
|
||||
|
||||
bool Client::has_ended(){
|
||||
return false;
|
||||
}
|
||||
|
@ -31,7 +38,13 @@ namespace games {
|
|||
Client::Client(int window_width_, int window_height_, std::shared_ptr<Base>& active_base_)
|
||||
: Base(window_width_, window_height_, active_base_)
|
||||
{
|
||||
// *** websockets code ***
|
||||
// simulation
|
||||
beat.notes.emplace_back(note_type::kQuarterNote, note_info{100.0f, 100.0f});
|
||||
|
||||
AbstractLine line(Vec2{50.0f, 100.0f}, Vec2{150.0f, 200.0f}, simulation::kOneWay);
|
||||
add_line(line);
|
||||
|
||||
// websockets
|
||||
lws_context_creation_info info;
|
||||
memset(&info, 0, sizeof info);
|
||||
|
||||
|
@ -46,8 +59,8 @@ namespace games {
|
|||
std::string address = "127.0.0.1";
|
||||
wsi = libwebsocket_client_connect(context, address.c_str(), 7681, false, "/", address.c_str(), "origin", "uberclient", -1);
|
||||
assert(wsi);
|
||||
// *** ***
|
||||
|
||||
// motor
|
||||
{
|
||||
motor::DirectionalLight p{motor::Position{0, 0, 20}, 1.0f, motor::Color{1, 1, 1, 1}};
|
||||
scene->add(std::make_shared<motor::DirectionalLight>(p));
|
||||
|
@ -85,11 +98,22 @@ namespace games {
|
|||
}
|
||||
|
||||
void Client::update(float const dt, Input input){
|
||||
// motor
|
||||
Base::update(dt, input);
|
||||
handle_input(dt, input);
|
||||
|
||||
scene->camera.set_position({0, 0, 20});
|
||||
|
||||
// simulation
|
||||
for(auto x : sim.update(dt)){
|
||||
std::cout << "plop\n";
|
||||
}
|
||||
|
||||
for(auto n : beat.update(dt)){
|
||||
sim.balls.emplace_back(n.x, n.y, 0, 0, balluid++);
|
||||
}
|
||||
|
||||
// websockets
|
||||
const float poll_interval = 5.0;
|
||||
poll_time += dt;
|
||||
|
||||
|
|
|
@ -8,14 +8,28 @@
|
|||
#include "../Base.hpp"
|
||||
#include "../input.hpp"
|
||||
|
||||
#include "../../../beats-server/src/app_common.h"
|
||||
|
||||
|
||||
namespace games {
|
||||
struct Client : public Base {
|
||||
static constexpr char bundle_name[] = "client";
|
||||
|
||||
// websocket part
|
||||
libwebsocket_context * context{nullptr};
|
||||
libwebsocket * wsi{nullptr};
|
||||
float poll_time{0.0};
|
||||
|
||||
// simulation part
|
||||
int balluid{0};
|
||||
std::vector<AbstractLine> lines;
|
||||
|
||||
simu_type sim;
|
||||
beat_type beat;
|
||||
|
||||
void add_line(AbstractLine const & line);
|
||||
|
||||
// Base part
|
||||
Client(int window_width, int window_height, std::shared_ptr<Base>& active_base);
|
||||
|
||||
virtual bool has_ended();
|
||||
|
|
Reference in a new issue