diff --git a/.gitignore b/.gitignore
index ecbd5d5..870e824 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,7 @@ linux-packages
.kdev4
windows\-installer/*.bmp
+
+game-resources
+motor
+sc-includes
diff --git a/src/client/client.cpp b/src/client/client.cpp
index abf935b..854c188 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -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& 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(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;
diff --git a/src/client/client.hpp b/src/client/client.hpp
index e83e842..1bb82db 100644
--- a/src/client/client.hpp
+++ b/src/client/client.hpp
@@ -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 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& active_base);
virtual bool has_ended();