From 22ef01964ab4f5681965ca54ab50e61d491f34a3 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 17 Sep 2022 16:47:22 +0200 Subject: [PATCH] ads-game:: model permanently switched to underlying geometry --- rogueviz/ads/ads-game.cpp | 19 ++++++++++++++++++- rogueviz/ads/control.cpp | 7 +++++++ rogueviz/ads/display.cpp | 39 ++++++++++++++------------------------ rogueviz/ads/globals.cpp | 2 ++ rogueviz/ads/resources.cpp | 3 ++- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/rogueviz/ads/ads-game.cpp b/rogueviz/ads/ads-game.cpp index 913fd3ad..d6e8fbe1 100644 --- a/rogueviz/ads/ads-game.cpp +++ b/rogueviz/ads/ads-game.cpp @@ -47,10 +47,27 @@ void run_ads_game() { ci_at[c].rocks.clear(); }); vctrV = new_vctrV = ads_matrix(Id, 0); - rogueviz::rv_hook(hooks_prestats, 100, view_ads_game); + rogueviz::rv_hook(hooks_frame, 100, view_ads_game); + rogueviz::rv_hook(hooks_prestats, 100, display_rsrc); rogueviz::rv_hook(hooks_handleKey, 0, handleKey); rogueviz::rv_hook(shmup::hooks_turn, 0, ads_turn); init_rsrc(); + + cgi.use_count++; + hybrid::in_underlying_geometry([] { + cgi.use_count++; + }); + + auto umap = hybrid::get_umap(); + hybrid::actual_geometry = geometry; + geometry = hybrid::underlying; + hybrid::underlying_cgip->single_step = cgi.single_step; + hybrid::underlying_cgip->psl_steps = cgi.psl_steps; + cgip = hybrid::underlying_cgip; + hybrid::pmap = currentmap; + currentmap = umap; + pmodel = mdDisk; + cwt.at = centerover = currentmap->gamestart(); } auto shot_hooks = diff --git a/rogueviz/ads/control.cpp b/rogueviz/ads/control.cpp index da6bb3e5..eac2b8a0 100644 --- a/rogueviz/ads/control.cpp +++ b/rogueviz/ads/control.cpp @@ -108,6 +108,8 @@ bool ads_turn(int idelta) { ld delta = idelta / anims::period; if(!(cmode & sm::NORMAL)) return false; + + hybrid::in_actual([&] { handle_crashes(); @@ -136,6 +138,8 @@ bool ads_turn(int idelta) { if(a[16+7] && !la[16+7]) auto_rotate = !auto_rotate; if(a[16+8] && !la[16+8]) pushScreen(game_menu); + if(auto_angle) pconf.model_orientation += ang; + if(true) { /* proper time passed */ @@ -204,9 +208,12 @@ bool ads_turn(int idelta) { } else view_pt += tc; } + + if(auto_angle) pconf.model_orientation -= ang; fixmatrix_ads(current.T); fixmatrix_ads(vctrV.T); + }); return true; } diff --git a/rogueviz/ads/display.cpp b/rogueviz/ads/display.cpp index ccd8d7fa..fd70da8e 100644 --- a/rogueviz/ads/display.cpp +++ b/rogueviz/ads/display.cpp @@ -127,15 +127,18 @@ void draw_game_cell(cell *cs, ads_matrix V, ld plev) { } -bool view_ads_game() { - auto plev = cgi.plevel; /* we are in another CGI so we have no access to that... */ - gen_budget = 3; +void view_ads_game() { + ld plev; displayed.clear(); - vctr = new_vctr; - vctrV = new_vctrV; - cross_result base; - if(1) { + hybrid::in_actual([&] { + plev = cgi.plevel; /* we are in another CGI so we have no access to that... */ + gen_budget = 3; + + vctr = new_vctr; + vctrV = new_vctrV; + cross_result base; + // todo rebase base = findflat(ads_point(C0, 0)); // println(hlog, base.h); @@ -161,19 +164,13 @@ bool view_ads_game() { else { current = bcurrent; } } } + ); // current = current * gpushxto0(p); // vctrV = rgpushxto0(p) * vctrV; - hybrid::in_underlying_geometry([&] { - dynamicval p(pmodel, mdDisk); - check_cgi(); - cgi.require_basics(); - cgi.require_shapes(); - ptds.clear(); - calcparam(); - clearaura(); + if(1) { make_shape(); - + set visited; queue> dq; auto visit = [&] (cell *c, const ads_matrix& V) { @@ -229,15 +226,7 @@ bool view_ads_game() { string str = format(tformat, view_pt / TAU); queuestr(shiftless(Id), .1, str, 0xFFFF00, 8); } - - if(false) queuepolyat(shiftless(rgpushxto0(base.h)), cgi.shGem[0], 0x2020FFFF, PPR::LINE); - - drawqueue(); - drawaura(); - }); - check_cgi(); - display_rsrc(); - return true; + } } }} diff --git a/rogueviz/ads/globals.cpp b/rogueviz/ads/globals.cpp index 612e10ea..28d7f380 100644 --- a/rogueviz/ads/globals.cpp +++ b/rogueviz/ads/globals.cpp @@ -68,4 +68,6 @@ ld how_much_invincibility = TAU / 4; player_data pdata, max_pdata, tank_pdata; +bool auto_angle = true; + }} diff --git a/rogueviz/ads/resources.cpp b/rogueviz/ads/resources.cpp index e4363400..a6f731a9 100644 --- a/rogueviz/ads/resources.cpp +++ b/rogueviz/ads/resources.cpp @@ -84,7 +84,7 @@ void display(int id, int y, ld val, ld maxv, ld tank, ld unit) { } } -void display_rsrc() { +bool display_rsrc() { dynamicval g(geometry, gEuclid); dynamicval pm(pmodel, mdDisk); dynamicval ga(vid.always3, false); @@ -102,6 +102,7 @@ void display_rsrc() { #undef D quickqueue(); + return true; } void gain_resource(eResourceType rsrc) {