1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

nilrider:: synchronized music

This commit is contained in:
Zeno Rogue 2022-08-14 19:24:13 +02:00
parent dbab2254c6
commit 82e2e853bf
2 changed files with 26 additions and 7 deletions

View File

@ -472,6 +472,9 @@ ld level::safe_alt(hyperpoint h, ld mul, ld mulx) {
bool stepped_display;
int nilrider_tempo = 562;
int nilrider_shift = 2633;
void level::draw_level(const shiftmatrix& V) {
int id = 0;
init_statues();
@ -483,7 +486,11 @@ void level::draw_level(const shiftmatrix& V) {
id++;
if(!gotit) {
for(int i=0; i<6; i++) {
auto &poly = queuepoly(V * rgpushxto0(t.where) * cpush(2, abs(0.2 * sin(current.timer * 5))), shMini[i], t.colors[i]);
ld tim = current.timer * 1000;
tim -= nilrider_shift;
tim /= nilrider_tempo;
tim = abs(0.2 * sin(tim * M_PI));
auto &poly = queuepoly(V * rgpushxto0(t.where) * cpush(2, tim), shMini[i], t.colors[i]);
poly.tinf = &floor_texture_vertices[cgi.shFloor.id];
ensure_vertex_number(*poly.tinf, poly.cnt);
}

View File

@ -67,8 +67,17 @@ bool crash_sound = true;
bool running;
bool backing;
/* land for music */
eLand music_nilrider = eLand(400);
eLand music_nilrider_back = eLand(401);
eLand music_nilrider_paused = eLand(402);
eLand music_nilrider_planning = eLand(403);
eLand music_nilrider_nonrunning = eLand(404);
void sync_music(eLand l) {
musicpos[laCanvas] = curlev->current.timer * 1000;
musicpos[music_nilrider] = zgmod(curlev->current.timer * 1000, musiclength[music_nilrider]);
musicpos[music_nilrider_back] = zgmod(-curlev->current.timer * 1000, musiclength[music_nilrider_back]);
}
bool turn(int delta) {
@ -534,14 +543,14 @@ void nilrider_keys() {
bool nilrider_music(eLand& l) {
if(planning_mode && !view_replay)
l = eLand(1);
l = music_nilrider_planning;
else if(paused)
l = eLand(2);
l = music_nilrider_paused;
else if(!running)
l = eLand(3);
l = music_nilrider_nonrunning;
else if(backing)
l = eLand(4);
else l = laCanvas;
l = music_nilrider_back;
else l = music_nilrider;
return false;
}
@ -562,6 +571,9 @@ void initialize() {
param_enum(stepped_display, "stepped_display", "stepped_display", false)
-> editable({{"smooth", "ride on a smooth surface"}, {"blocky", "makes slopes more visible -- actual physics are not affected"}}, "game mode", 's');
param_i(nilrider_tempo, "nilrider_tempo");
param_i(nilrider_shift, "nilrider_shift");
rv_hook(hooks_frame, 100, frame);
rv_hook(shmup::hooks_turn, 100, turn);
rv_hook(hooks_resetGL, 100, cleanup_textures);