mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-02 12:19:18 +00:00
ads-game:: display other frames of reference while paused
This commit is contained in:
parent
38b817187e
commit
b1baf393ba
@ -32,10 +32,13 @@ void run_ads_game() {
|
||||
change_default_key('t', 16 + 6);
|
||||
change_default_key('o', 16 + 7);
|
||||
change_default_key('m', 16 + 8);
|
||||
change_default_key('i', 16 + 9);
|
||||
change_default_key('k', 16 + 10);
|
||||
change_default_key('l', 16 + 11);
|
||||
|
||||
nomap = true;
|
||||
no_find_player = true;
|
||||
vctr = cwt.at;
|
||||
vctr = new_vctr = cwt.at;
|
||||
cell *c = hybrid::get_where(vctr).first;
|
||||
hybrid::in_underlying_geometry([&] {
|
||||
gen_terrain(c, ci_at[c], -2);
|
||||
@ -43,7 +46,7 @@ void run_ads_game() {
|
||||
ci_at[c].type = wtNone;
|
||||
ci_at[c].rocks.clear();
|
||||
});
|
||||
vctrV = ads_matrix(Id, 0);
|
||||
vctrV = new_vctrV = ads_matrix(Id, 0);
|
||||
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);
|
||||
|
@ -2,7 +2,7 @@ namespace hr {
|
||||
|
||||
namespace ads_game {
|
||||
|
||||
vector<string> move_names = { "acc down", "acc left", "acc up", "acc right", "fire", "pause", "display times", "switch spin", "menu" };
|
||||
vector<string> move_names = { "acc down", "acc left", "acc up", "acc right", "fire", "pause", "display times", "switch spin", "menu", "[paused] future", "(paused] past", "[paused] move switch" };
|
||||
|
||||
void fire() {
|
||||
if(!pdata.ammo) return;
|
||||
@ -118,12 +118,25 @@ bool ads_turn(int idelta) {
|
||||
for(int i=0; i<NUMACT; i++) if(a[i]) ap.push_back(i);
|
||||
|
||||
if(a[16+4] && !la[16+4]) fire();
|
||||
if(a[16+5] && !la[16+5]) paused = !paused;
|
||||
if(a[16+5] && !la[16+5]) {
|
||||
paused = !paused;
|
||||
if(paused) {
|
||||
current_ship = current;
|
||||
vctr_ship = vctr;
|
||||
vctrV_ship = vctrV;
|
||||
view_pt = 0;
|
||||
}
|
||||
else {
|
||||
current = current_ship;
|
||||
vctr = new_vctr = vctr_ship;
|
||||
vctrV = new_vctrV = vctrV_ship;
|
||||
}
|
||||
}
|
||||
if(a[16+6] && !la[16+6]) view_proper_times = !view_proper_times;
|
||||
if(a[16+7] && !la[16+7]) auto_rotate = !auto_rotate;
|
||||
if(a[16+8] && !la[16+8]) pushScreen(game_menu);
|
||||
|
||||
if(!paused) {
|
||||
if(true) {
|
||||
|
||||
/* proper time passed */
|
||||
ld pt = delta * simspeed;
|
||||
@ -148,25 +161,40 @@ bool ads_turn(int idelta) {
|
||||
if(right && up) ang = 45;
|
||||
if(right && down) ang = 315;
|
||||
|
||||
ld mul = clicks && !game_over ? 1 : 0;
|
||||
ld mul = clicks ? 1 : 0;
|
||||
if(clicks > 2) mul *= .3;
|
||||
if(pdata.fuel < 0) mul = 0;
|
||||
if(!paused) {
|
||||
if(game_over || pdata.fuel < 0) mul = 0;
|
||||
}
|
||||
|
||||
if(paused && a[16+11]) {
|
||||
current = ads_matrix(spin(ang*degree) * xpush(mul*delta*5) * spin(-ang*degree), 0) * current;
|
||||
}
|
||||
else
|
||||
apply_lorentz(spin(ang*degree) * lorentz(0, 2, -delta*accel*mul) * spin(-ang*degree));
|
||||
pdata.fuel -= delta*accel*mul;
|
||||
|
||||
if(!paused) {
|
||||
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);
|
||||
}
|
||||
|
||||
ld tc = 0;
|
||||
if(!paused) tc = pt;
|
||||
else if(a[16+9]) tc = pt;
|
||||
else if(a[16+10]) tc = -pt;
|
||||
|
||||
current.T = cspin(3, 2, tc) * current.T;
|
||||
|
||||
current.T = cspin(3, 2, pt) * current.T;
|
||||
optimize_shift(current);
|
||||
hassert(eqmatrix(chg_shift(current.shift) * current.T, unshift(current)));
|
||||
|
||||
if(auto_rotate)
|
||||
current.T = cspin(1, 0, pt) * current.T;
|
||||
else
|
||||
ang += pt / degree;
|
||||
current.T = cspin(1, 0, tc) * current.T;
|
||||
else if(!paused)
|
||||
ang += tc / degree;
|
||||
|
||||
if(!paused) {
|
||||
ship_pt += pt;
|
||||
pdata.oxygen -= pt;
|
||||
if(pdata.oxygen < 0) {
|
||||
@ -174,6 +202,8 @@ bool ads_turn(int idelta) {
|
||||
game_over = true;
|
||||
}
|
||||
}
|
||||
else view_pt += tc;
|
||||
}
|
||||
|
||||
fixmatrix_ads(current.T);
|
||||
fixmatrix_ads(vctrV.T);
|
||||
|
@ -24,7 +24,7 @@ void draw_game_cell(cell *cs, ads_matrix V, ld plev) {
|
||||
|
||||
if(1) {
|
||||
ld d = hdist0(center.h);
|
||||
if(d < vctr_dist) vctr_dist = d, vctr = PIA( hybrid::get_at(c, 0) ), vctrV = V;
|
||||
if(d < vctr_dist) vctr_dist = d, new_vctr = PIA( hybrid::get_at(c, 0) ), new_vctrV = V;
|
||||
}
|
||||
|
||||
auto& ci = ci_at[c];
|
||||
@ -132,6 +132,8 @@ bool view_ads_game() {
|
||||
gen_budget = 5;
|
||||
displayed.clear();
|
||||
|
||||
vctr = new_vctr;
|
||||
vctrV = new_vctrV;
|
||||
cross_result base;
|
||||
if(1) {
|
||||
// todo rebase
|
||||
@ -207,7 +209,7 @@ bool view_ads_game() {
|
||||
});
|
||||
}
|
||||
|
||||
if(!game_over) {
|
||||
if(!game_over && !paused) {
|
||||
poly_outline = 0xFF;
|
||||
color_t shipcolor = 0x2020FFFF;
|
||||
if(ship_pt < invincibility_pt) {
|
||||
@ -223,6 +225,11 @@ bool view_ads_game() {
|
||||
}
|
||||
}
|
||||
|
||||
if(paused && view_proper_times) {
|
||||
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();
|
||||
|
@ -8,14 +8,17 @@ ld simspeed = TAU;
|
||||
/** by how much do WAS keys accelerate */
|
||||
ld accel = 6;
|
||||
|
||||
/** transform world coordinates to ship coordinates */
|
||||
/** transform world coordinates to current view coordinates */
|
||||
ads_matrix current;
|
||||
|
||||
/** SL cell closest to the ship */
|
||||
cell *vctr;
|
||||
/** transform world coordinates to ship coordinates (used when paused) */
|
||||
ads_matrix current_ship;
|
||||
|
||||
/** SL cell closest to the current view/ship */
|
||||
cell *vctr, *new_vctr, *vctr_ship;
|
||||
|
||||
/** world coordinates of vctr -- technically, this is a shiftmatrix */
|
||||
ads_matrix vctrV;
|
||||
ads_matrix vctrV, new_vctrV, vctrV_ship;
|
||||
|
||||
/** how far is vctr from the ship */
|
||||
ld vctr_dist;
|
||||
@ -26,6 +29,9 @@ ld ang = 0;
|
||||
/** ship's current proper time */
|
||||
ld ship_pt;
|
||||
|
||||
/** paused camera's current proper time */
|
||||
ld view_pt;
|
||||
|
||||
/** until when is the ship invincible */
|
||||
ld invincibility_pt;
|
||||
|
||||
|
@ -194,6 +194,7 @@ void crash_ship() {
|
||||
}
|
||||
|
||||
void handle_crashes() {
|
||||
if(paused) return;
|
||||
vector<ads_object*> missiles;
|
||||
vector<ads_object*> rocks;
|
||||
vector<ads_object*> resources;
|
||||
|
Loading…
Reference in New Issue
Block a user