1
Fork 0
This repository has been archived on 2025-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
beats-motor-client/src/client/client.hpp

60 lines
1.4 KiB
C++

#pragma once
#include <vector>
#include <memory>
#include <motor/sound/sound.hpp>
#include <motor/basic/texture_label.hpp>
#include <lib/libwebsockets.h>
#include "../globals.hpp"
#include "../Base.hpp"
#include "../input.hpp"
#include "client_common.hpp"
namespace games {
struct Client : public Base {
static constexpr char bundle_name[] = "client";
// websocket part
libwebsocket_context * context{nullptr};
libwebsocket * wsi{nullptr};
float push_time{0.0};
bool lines_changed{true};
// simulation part
int balluid{0};
std::vector<std::shared_ptr<Instrument>> lines;
simu_type sim;
beat_type beat;
void add_line(cheap_line_type const & line);
// Sound part
const std::vector<std::string> scales{
::bundle.get_sound_path() + "maj7.txt",
::bundle.get_sound_path() + "pentatonic"
};
const std::vector<std::shared_ptr<motor::al::Buffer>> sounds{
resource_cache.get_sound_buffer(::bundle.get_sound_path() + "guitar440.wav"),
resource_cache.get_sound_buffer(::bundle.get_sound_path() + "marimba.wav")
};
std::vector<std::string>::const_iterator current_scale{scales.begin()};
Scale scale;
// Base part
Client(int window_width, int window_height, std::shared_ptr<Base>& active_base);
virtual bool has_ended();
virtual void update(float const dt, Input input);
virtual void draw();
void handle_input(float const dt, Input input);
~Client();
};
}