From 3578ae06314c557f8d58e14118fd6b6949f50ef4 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 12 Sep 2022 12:24:18 +0200 Subject: [PATCH] ads-game:: resources displayed --- rogueviz/ads/ads-game.cpp | 2 + rogueviz/ads/display.cpp | 1 + rogueviz/ads/globals.cpp | 10 ++++ rogueviz/ads/resources.cpp | 98 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 rogueviz/ads/resources.cpp diff --git a/rogueviz/ads/ads-game.cpp b/rogueviz/ads/ads-game.cpp index 8001086c..b94c1f62 100644 --- a/rogueviz/ads/ads-game.cpp +++ b/rogueviz/ads/ads-game.cpp @@ -5,6 +5,7 @@ #include "shapes.cpp" #include "map.cpp" #include "control.cpp" +#include "resources.cpp" #include "display.cpp" #include "menu.cpp" @@ -45,6 +46,7 @@ void run_ads_game() { rogueviz::rv_hook(hooks_prestats, 100, view_ads_game); rogueviz::rv_hook(hooks_handleKey, 0, handleKey); rogueviz::rv_hook(shmup::hooks_turn, 0, ads_turn); + init_rsrc(); } auto shot_hooks = diff --git a/rogueviz/ads/display.cpp b/rogueviz/ads/display.cpp index fe7f4d9c..e4242b7b 100644 --- a/rogueviz/ads/display.cpp +++ b/rogueviz/ads/display.cpp @@ -223,6 +223,7 @@ bool view_ads_game() { drawaura(); }); check_cgi(); + display_rsrc(); return true; } diff --git a/rogueviz/ads/globals.cpp b/rogueviz/ads/globals.cpp index 58085b01..d0d6d72b 100644 --- a/rogueviz/ads/globals.cpp +++ b/rogueviz/ads/globals.cpp @@ -45,4 +45,14 @@ vector displayed; color_t missile_color = 0xFF0000FF; +struct player_data { + int hitpoints; + int score; + int ammo; + ld fuel; + ld oxygen; + }; + +player_data pdata, max_pdata, tank_pdata; + }} diff --git a/rogueviz/ads/resources.cpp b/rogueviz/ads/resources.cpp new file mode 100644 index 00000000..5347b617 --- /dev/null +++ b/rogueviz/ads/resources.cpp @@ -0,0 +1,98 @@ +namespace hr { + +namespace ads_game { + +void init_rsrc() { + max_pdata.hitpoints = 3; + max_pdata.score = 0; + max_pdata.ammo = 50; + max_pdata.fuel = 12 * TAU; + max_pdata.oxygen = 20 * TAU; + + tank_pdata.hitpoints = 1; + tank_pdata.score = 1; + tank_pdata.ammo = 20; + tank_pdata.fuel = 4 * TAU; + tank_pdata.oxygen = 5 * TAU; + + pdata = max_pdata; + } + +void display(int id, int y, ld val, ld maxv, ld tank, ld unit) { + auto sId = shiftless(Id); + +// ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); + + color_t col = rsrc_color[id]; + + auto& shape = rsrc_shape[id][0]; + int N = isize(shape); + + ld ctr = 20*y+10; + + for(int i=0; i> 8, 1, 0); + return; + } + + curvepoint(atscreenpos(sta, top, 1) * C0); + curvepoint(atscreenpos(fen, top, 1) * C0); + curvepoint(atscreenpos(fen, bot, 1) * C0); + curvepoint(atscreenpos(sta, bot, 1) * C0); + curvepoint(atscreenpos(sta, top, 1) * C0); + queuecurve(sId, col, col - 128, PPR::ZERO); + + ld end = sta + siz * val / maxv; + curvepoint(atscreenpos(sta, top, 1) * C0); + curvepoint(atscreenpos(end, top, 1) * C0); + curvepoint(atscreenpos(end, bot, 1) * C0); + curvepoint(atscreenpos(sta, bot, 1) * C0); + curvepoint(atscreenpos(sta, top, 1) * C0); + queuecurve(sId, col, col, PPR::ZERO); + + if(unit) for(ld u=unit; u g(geometry, gEuclid); + dynamicval pm(pmodel, mdDisk); + dynamicval ga(vid.always3, false); + dynamicval ou(poly_outline); + dynamicval gi(ginf[gEuclid].g, giEuclid2); + initquickqueue(); + check_cgi(); cgi.require_shapes(); + + #define D(id, y, field, unit) display(id, y, pdata.field, max_pdata.field, tank_pdata.field, unit) + D(1, 1, hitpoints, 1); + D(3, 2, ammo, 1); + D(4, 3, fuel, TAU); + D(5, 4, oxygen, TAU); + D(2, 5, score, 10); + #undef D + + quickqueue(); + } + +}}