From 070ec974da68f137f7c5b935f5f075fd925d6d42 Mon Sep 17 00:00:00 2001 From: Joshua Moerman Date: Tue, 23 Apr 2013 10:18:42 +0200 Subject: [PATCH] Added more keys to control stuff, also very nice shaders --- src/client/client.cpp | 39 ++++++++++++++++++++++++++++++++++++--- src/client/client.hpp | 10 +++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index b3c19d5..a62ccdb 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -139,6 +139,34 @@ namespace games { sim.balls.clear(); } + if(input.keys_went_down[SDLK_q]){ + music_speed = 0.5; + } + + if(input.keys_went_down[SDLK_w]){ + music_speed = 1.0; + } + + if(input.keys_went_down[SDLK_e]){ + music_speed = 2.0; + } + + if(input.keys_went_down[SDLK_z]){ + sim_speed = 0.5; + } + + if(input.keys_went_down[SDLK_x]){ + sim_speed = 1.0; + } + + if(input.keys_went_down[SDLK_c]){ + sim_speed = 2.0; + } + + if(input.keys_went_down[SDLK_p]){ + pause = !pause; + } + if(input.keys_went_down[SDLK_l]){ lines.clear(); sim.lines.clear(); @@ -151,11 +179,15 @@ namespace games { } } - if(input.keys_went_down[SDLK_k]){ + if(input.keys_went_down[SDLK_s]){ scene->update_shader_pipeline(); game_renderer.load_shaders(); } + if(input.keys_went_down[SDLK_a]){ + auto_pilot = !auto_pilot; + } + for(char n = '0'; n <= '9'; ++n){ if(input.keys_went_down[n]){ scale = scales[n - '0']; @@ -178,13 +210,14 @@ namespace games { float dt2 = dt; if(dt2 > 1.0/70.0 && dt2 < 1.0/55.0) dt2 = 1.0/60.0; + if(pause) dt2 = 0.0; // simulation for(auto l : lines){ l->update(dt2); } - for(auto x : sim.update(dt2)){ + for(auto x : sim.update(sim_speed * dt2)){ x.line.information->play(); } @@ -192,7 +225,7 @@ namespace games { sim.balls.emplace_back(n.x, n.y, 0, 0, balluid++); } - if(!chords.update(music_speed * dt2).empty()){ + if(!chords.update(music_speed * dt2).empty() && auto_pilot){ std::cout << std::distance(chord_progression.cbegin(), chord_progression_it) + 1 << "th chord\n"; scale = scales[*chord_progression_it]; update_pitches(*this); diff --git a/src/client/client.hpp b/src/client/client.hpp index 545ae90..de3c85a 100644 --- a/src/client/client.hpp +++ b/src/client/client.hpp @@ -18,8 +18,12 @@ /* Controls: 1, .. 9, 0: change chord (will also be done automatically) + q, w, e: music speed (= generation of balls) + z, x, c: simulation speed + a: toggle autopilot + p: pause r: reload scales (aka chords) - k: reload shaders + s: reload shaders b: clear balls l: clear lines */ @@ -42,6 +46,9 @@ namespace games { beat_type beat; beat_type chords; + float sim_speed{1.0}; + bool pause{false}; + void add_line(cheap_line_type const & line); // Sound part @@ -74,6 +81,7 @@ namespace games { }; float music_speed{1.0}; + bool auto_pilot{false}; // Graphics GameRenderer game_renderer;