From 2f78601f0bd330ceba71b49a8a54ba81f3e404e3 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 12 Sep 2022 13:20:04 +0200 Subject: [PATCH] ads-game:: fuel/crash particles --- rogueviz/ads/control.cpp | 4 +++- rogueviz/ads/map.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rogueviz/ads/control.cpp b/rogueviz/ads/control.cpp index 755a3e7a..3fa766f0 100644 --- a/rogueviz/ads/control.cpp +++ b/rogueviz/ads/control.cpp @@ -124,7 +124,6 @@ bool ads_turn(int idelta) { if(a[16+8] && !la[16+8]) pushScreen(game_menu); if(!paused) { - dynamicval g(geometry, geometry == gRotSpace ? geometry : gCubeTiling); /* proper time passed */ ld pt = delta * simspeed; @@ -155,6 +154,9 @@ bool ads_turn(int idelta) { apply_lorentz(spin(ang*degree) * lorentz(0, 2, -delta*accel*mul) * spin(-ang*degree)); pdata.fuel -= delta*accel*mul; + + cell *c = hybrid::get_where(vctr).first; + gen_particles(rpoisson(delta*accel*mul*20), c, ads_inverse(current * vctrV) * spin(ang*degree+M_PI) * rots::uxpush(0.06), rsrc_color[rtFuel], 0.15, 0.02); current.T = cspin(3, 2, pt) * current.T; optimize_shift(current); diff --git a/rogueviz/ads/map.cpp b/rogueviz/ads/map.cpp index a5ffbfcd..6d944ebb 100644 --- a/rogueviz/ads/map.cpp +++ b/rogueviz/ads/map.cpp @@ -148,10 +148,10 @@ void gen_rocks(cell *c, cellinfo& ci, int radius) { ci.rock_dist = radius; } -void gen_particles(int qty, cell *c, shiftmatrix from, color_t col, ld t) { +void gen_particles(int qty, cell *c, shiftmatrix from, color_t col, ld t, ld spread = 1) { auto& ro = ci_at[c].rocks; for(int i=0; i(oParticle, c, from * spin(randd() * TAU) * lorentz(0, 2, 1 + randd()), col ); + auto r = std::make_unique(oParticle, c, from * spin(randd() * TAU * spread) * lorentz(0, 2, 1 + randd()), col ); r->shape = &shape_particle; r->life_end = randd() * t; r->life_start = 0; @@ -187,6 +187,10 @@ void crash_ship() { invincibility_pt = ship_pt + how_much_invincibility; pdata.hitpoints--; if(pdata.hitpoints <= 0) game_over = true; + hybrid::in_actual([&] { + cell *c = hybrid::get_where(vctr).first; + gen_particles(16, c, ads_inverse(current * vctrV) * spin(ang*degree), rsrc_color[rtHull], 0.5); + }); } void handle_crashes() {