1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 17:10:36 +00:00

nilrider:: timer is now recorded with timestamp

This commit is contained in:
Zeno Rogue 2022-05-06 14:31:50 +02:00
parent 4ab376caa7
commit 19a83d2ea8
5 changed files with 19 additions and 21 deletions

View File

@ -97,6 +97,7 @@ void level::init() {
start.where = mappt(startx+.5, starty+.5, 1);
start.t = 0;
start.timer = 0;
current = start;
println(hlog, "start.where = ", start.where);
println(hlog, "current.where = ", current.where, " : ", format("%p", &current));
@ -407,7 +408,6 @@ hyperpoint level::mappt(ld x, ld y, int s) {
void level::init_plan() {
plan.emplace_back(start.where, hpxy(cos(start.heading_angle + 90*degree) * 2, sin(start.heading_angle + 90*degree) * 2));
current = start;
timer = 0;
}
ld level::safe_alt(hyperpoint h, ld mul, ld mulx) {
@ -430,7 +430,7 @@ 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(timer * 5))), shMini[i], t.colors[i]);
auto &poly = queuepoly(V * rgpushxto0(t.where) * cpush(2, abs(0.2 * sin(current.timer * 5))), shMini[i], t.colors[i]);
poly.tinf = &floor_texture_vertices[cgi.shFloor.id];
ensure_vertex_number(*poly.tinf, poly.cnt);
}

View File

@ -102,13 +102,11 @@ bool turn(int delta) {
backing = true;
curlev->history.pop_back();
curlev->current = curlev->history.back();
timer = isize(curlev->history) * 1. / tps;
crash_sound = true;
}
else {
reversals = 0;
loaded_or_planned = false;
timer = 0;
crash_sound = true;
}
}
@ -123,8 +121,10 @@ bool turn(int delta) {
curlev->history.push_back(curlev->current);
curlev->current.be_consistent();
bool b = curlev->current.tick(curlev);
if(b) timer += 1. / tps;
else curlev->history.pop_back(), fail = true;
if(!b) {
curlev->history.pop_back();
fail = true;
}
}
if(t != curlev->current.collected_triangles)
@ -160,7 +160,6 @@ void toggle_replay() {
if(!view_replay && !planning_mode) {
paused = true;
curlev->current = curlev->history.back();
timer = isize(curlev->history) * 1. / tps;
}
}
@ -170,7 +169,6 @@ void run() {
dialog::init();
if(view_replay && !paused) {
int ttick = gmod(ticks - simulation_start_tick, isize(curlev->history));
timer = ttick * 1. / tps;
curlev->current = curlev->history[ttick];
curlev->current.centerview(curlev);
}
@ -188,7 +186,7 @@ void run() {
}
}
}
curlev->current.draw_instruments(curlev, timer);
curlev->current.draw_instruments(curlev);
if(paused && !planning_mode) {
displayButton(current_display->xcenter, current_display->ycenter, mousing ? XLAT("paused -- click to unpause") : XLAT("paused -- press p to continue"), 'p', 8);
@ -221,7 +219,7 @@ void run() {
if(pause_av) dialog::add_key_action(PSEUDOKEY_PAUSE, [] {
paused = !paused;
if(view_replay && !paused)
simulation_start_tick = ticks - timer * tps;
simulation_start_tick = ticks - curlev->current.timer * tps;
});
dialog::add_key_action('-', [] {
paused = false;
@ -248,7 +246,6 @@ void clear_path(level *l) {
l->history.clear();
l->current = l->start;
l->history.push_back(l->start);
timer = 0;
paused = false;
reversals = 0;
loaded_or_planned = false;
@ -538,7 +535,6 @@ auto celldemo = arg::add3("-unilcycle", initialize) + arg::add3("-unilplan", []
popScreenAll();
rv_hook(anims::hooks_anim, 100, [] {
int ttick = ticks % isize(curlev->history);
timer = ttick * 1. / tps;
curlev->current = curlev->history[ttick];
curlev->current.centerview(curlev);
anims::moved();

View File

@ -13,6 +13,7 @@ struct timestamp {
ld circpos; /**< controls the wheel graphics */
ld slope; /**< the current slope */
ld t; /**< planning spline parameter */
ld timer = 0; /**< the timer, in seconds */
flagtype collected_triangles; /**< a bitset which shows which triangles are collected */
flagtype goals; /**< a bitset which shows which goals are complete */
@ -21,7 +22,7 @@ struct timestamp {
bool tick(level*);/**< one tick of the simulation -- returns false if the unicycle has stopped or crashed */
void centerview(level*);
void draw_unilcycle(const shiftmatrix&);
void draw_instruments(level*, ld t);
void draw_instruments(level*);
ld energy_in_squares();
bool collect(level*);
void be_consistent();
@ -185,9 +186,6 @@ inline ld min_gfx_slope = +M_PI/2;
/** current slope for rendering */
inline ld gfx_slope = 0;
/** the timer */
inline ld timer = 0;
/** default block unit */
inline double dft_block = 1;

View File

@ -178,7 +178,6 @@ void level::draw_planning_screen() {
}
current = history[mint];
timer = mint * 1. / tps;
}
draw_sq(get_spline(closest_t), 0x8080FFFF, PPR::ITEM);

View File

@ -134,6 +134,7 @@ bool timestamp::tick(level *lev) {
where[2] = lev->surface(where);
circpos += mvel / whrad / tps;
timer += 1. / tps;
return true;
}
@ -169,7 +170,11 @@ void timestamp::centerview(level *lev) {
playermoved = false;
}
void timestamp::draw_instruments(level* l, ld t) {
string format_timer(ld t) {
return format("%d:%02d.%02d", int(t / 60), int(t) % 60, int(frac(t) * 100));
}
void timestamp::draw_instruments(level* l) {
dynamicval<eGeometry> g(geometry, gEuclid);
dynamicval<eModel> pm(pmodel, mdDisk);
dynamicval<bool> ga(vid.always3, false);
@ -303,7 +308,7 @@ void timestamp::draw_instruments(level* l, ld t) {
bool gsuccess = goals & Flag(gid);
if(lshiftclick) gfailed = true, gsuccess = false;
if(anyctrlclick) gfailed = false, gsuccess = true;
string s = format("%d:%02d.%02d", int(t / 60), int(t) % 60, int(frac(t) * 100));
string s = format_timer(timer);
shiftmatrix T = sId * atscreenpos(cx+rad/2, cy+(gid-1)*rad/1.2, pix * rad * 1.2);
poly_outline = 0xFF; color_t f = darkena(g.color, 0, 0xFF);
if(gsuccess) {
@ -321,9 +326,9 @@ void timestamp::draw_instruments(level* l, ld t) {
quickqueue();
glflush();
string s = format("%d:%02d.%02d", int(t / 60), int(t) % 60, int(frac(t) * 100));
displaystr(vid.xres - vid.fsize, vid.fsize*2, 0, vid.fsize * 2, s, 0, 16);
displaystr(vid.xres - vid.fsize, vid.fsize*2, 0, vid.fsize * 2, format_timer(timer), 0, 16);
string s;
if(loaded_or_planned) s = "R";
else if(reversals) s = format("+%d", reversals);
else return;