#pragma once #include #include #include #include #include #include #include "../globals.hpp" #include "../Base.hpp" #include "../input.hpp" #include "client_common.hpp" #include "GameRenderer.h" /* Controls: mouse: draw linez 1, .. 9, 0: change chord (will also be done automatically) k: change line kind a: toggle autopilot d: toggle drum p: pause q, w, e: music speed (= generation of balls) z, x, c: simulation speed -, + (without shift): global speed r: reload scales (aka chords) s: reload shaders b: clear balls l: clear lines */ namespace games { struct Client : public Base { static constexpr char bundle_name[] = "client"; float global_speed = 1.0; // 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> lines; std::shared_ptr kick; std::shared_ptr snare; simu_type sim; beat_type beat; beat_type chords; float sim_speed{1.0}; bool pause{false}; void add_line(cheap_line_type const & line); void remove_line(int ID); void remove_line(std::shared_ptr const & instr); void add_drum(); void remove_drum(); float x1; float x2; float x3; // Input part cheap_line_type current_line; bool drawing = false; simulation::LineKind current_kind = simulation::kFallThrough; std::stack> undo_stack; // Sound part const std::vector scale_files{ ::bundle.get_sound_path() + "pentatonic.txt", // 0 a ::bundle.get_sound_path() + "c.txt", // 1 c ::bundle.get_sound_path() + "d.txt", // 2 d ::bundle.get_sound_path() + "em.txt", // 3 e ::bundle.get_sound_path() + "maj7.txt", // 4 g ::bundle.get_sound_path() + "noon.txt", // 5 a ::bundle.get_sound_path() + "cnoon.txt", // 6 c ::bundle.get_sound_path() + "blues.txt", // 7 a ::bundle.get_sound_path() + "spanish.txt", // 8 a ::bundle.get_sound_path() + "f.txt", // 9 f }; std::vector scales; Scale scale; const std::vector> chord_progressions{ {1, 2, 3, 3, 1, 2, 3, 4, 1, 2, 3, 3, 1, 2, 3, 4}, {0, 7, 4, 4, 0, 1, 9, 3}, {0, 0, 9, 9, 0, 0, 5, 6} }; std::vector chord_progression{chord_progressions[0]}; std::vector::const_iterator chord_progression_it{chord_progression.begin()}; const std::vector> sounds{ resource_cache.get_sound_buffer(::bundle.get_sound_path() + "guitar440.wav"), resource_cache.get_sound_buffer(::bundle.get_sound_path() + "marimba.wav"), resource_cache.get_sound_buffer(::bundle.get_sound_path() + "kick.wav"), resource_cache.get_sound_buffer(::bundle.get_sound_path() + "snare.wav") }; float music_speed{1.0}; bool auto_pilot{true}; // Graphics GameRenderer game_renderer; std::shared_ptr peeps_lbl; void set_text(std::string peeps); // Base part Client(int window_width, int window_height, std::shared_ptr& 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(); }; }