mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-24 05:17:17 +00:00
nilrider:: timer is now recorded with timestamp
This commit is contained in:
parent
4ab376caa7
commit
19a83d2ea8
@ -97,6 +97,7 @@ void level::init() {
|
|||||||
|
|
||||||
start.where = mappt(startx+.5, starty+.5, 1);
|
start.where = mappt(startx+.5, starty+.5, 1);
|
||||||
start.t = 0;
|
start.t = 0;
|
||||||
|
start.timer = 0;
|
||||||
current = start;
|
current = start;
|
||||||
println(hlog, "start.where = ", start.where);
|
println(hlog, "start.where = ", start.where);
|
||||||
println(hlog, "current.where = ", current.where, " : ", format("%p", ¤t));
|
println(hlog, "current.where = ", current.where, " : ", format("%p", ¤t));
|
||||||
@ -407,7 +408,6 @@ hyperpoint level::mappt(ld x, ld y, int s) {
|
|||||||
void level::init_plan() {
|
void level::init_plan() {
|
||||||
plan.emplace_back(start.where, hpxy(cos(start.heading_angle + 90*degree) * 2, sin(start.heading_angle + 90*degree) * 2));
|
plan.emplace_back(start.where, hpxy(cos(start.heading_angle + 90*degree) * 2, sin(start.heading_angle + 90*degree) * 2));
|
||||||
current = start;
|
current = start;
|
||||||
timer = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ld level::safe_alt(hyperpoint h, ld mul, ld mulx) {
|
ld level::safe_alt(hyperpoint h, ld mul, ld mulx) {
|
||||||
@ -430,7 +430,7 @@ void level::draw_level(const shiftmatrix& V) {
|
|||||||
id++;
|
id++;
|
||||||
if(!gotit) {
|
if(!gotit) {
|
||||||
for(int i=0; i<6; i++) {
|
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];
|
poly.tinf = &floor_texture_vertices[cgi.shFloor.id];
|
||||||
ensure_vertex_number(*poly.tinf, poly.cnt);
|
ensure_vertex_number(*poly.tinf, poly.cnt);
|
||||||
}
|
}
|
||||||
|
@ -102,13 +102,11 @@ bool turn(int delta) {
|
|||||||
backing = true;
|
backing = true;
|
||||||
curlev->history.pop_back();
|
curlev->history.pop_back();
|
||||||
curlev->current = curlev->history.back();
|
curlev->current = curlev->history.back();
|
||||||
timer = isize(curlev->history) * 1. / tps;
|
|
||||||
crash_sound = true;
|
crash_sound = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reversals = 0;
|
reversals = 0;
|
||||||
loaded_or_planned = false;
|
loaded_or_planned = false;
|
||||||
timer = 0;
|
|
||||||
crash_sound = true;
|
crash_sound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,8 +121,10 @@ bool turn(int delta) {
|
|||||||
curlev->history.push_back(curlev->current);
|
curlev->history.push_back(curlev->current);
|
||||||
curlev->current.be_consistent();
|
curlev->current.be_consistent();
|
||||||
bool b = curlev->current.tick(curlev);
|
bool b = curlev->current.tick(curlev);
|
||||||
if(b) timer += 1. / tps;
|
if(!b) {
|
||||||
else curlev->history.pop_back(), fail = true;
|
curlev->history.pop_back();
|
||||||
|
fail = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(t != curlev->current.collected_triangles)
|
if(t != curlev->current.collected_triangles)
|
||||||
@ -160,7 +160,6 @@ void toggle_replay() {
|
|||||||
if(!view_replay && !planning_mode) {
|
if(!view_replay && !planning_mode) {
|
||||||
paused = true;
|
paused = true;
|
||||||
curlev->current = curlev->history.back();
|
curlev->current = curlev->history.back();
|
||||||
timer = isize(curlev->history) * 1. / tps;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +169,6 @@ void run() {
|
|||||||
dialog::init();
|
dialog::init();
|
||||||
if(view_replay && !paused) {
|
if(view_replay && !paused) {
|
||||||
int ttick = gmod(ticks - simulation_start_tick, isize(curlev->history));
|
int ttick = gmod(ticks - simulation_start_tick, isize(curlev->history));
|
||||||
timer = ttick * 1. / tps;
|
|
||||||
curlev->current = curlev->history[ttick];
|
curlev->current = curlev->history[ttick];
|
||||||
curlev->current.centerview(curlev);
|
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) {
|
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);
|
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, [] {
|
if(pause_av) dialog::add_key_action(PSEUDOKEY_PAUSE, [] {
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
if(view_replay && !paused)
|
if(view_replay && !paused)
|
||||||
simulation_start_tick = ticks - timer * tps;
|
simulation_start_tick = ticks - curlev->current.timer * tps;
|
||||||
});
|
});
|
||||||
dialog::add_key_action('-', [] {
|
dialog::add_key_action('-', [] {
|
||||||
paused = false;
|
paused = false;
|
||||||
@ -248,7 +246,6 @@ void clear_path(level *l) {
|
|||||||
l->history.clear();
|
l->history.clear();
|
||||||
l->current = l->start;
|
l->current = l->start;
|
||||||
l->history.push_back(l->start);
|
l->history.push_back(l->start);
|
||||||
timer = 0;
|
|
||||||
paused = false;
|
paused = false;
|
||||||
reversals = 0;
|
reversals = 0;
|
||||||
loaded_or_planned = false;
|
loaded_or_planned = false;
|
||||||
@ -538,7 +535,6 @@ auto celldemo = arg::add3("-unilcycle", initialize) + arg::add3("-unilplan", []
|
|||||||
popScreenAll();
|
popScreenAll();
|
||||||
rv_hook(anims::hooks_anim, 100, [] {
|
rv_hook(anims::hooks_anim, 100, [] {
|
||||||
int ttick = ticks % isize(curlev->history);
|
int ttick = ticks % isize(curlev->history);
|
||||||
timer = ttick * 1. / tps;
|
|
||||||
curlev->current = curlev->history[ttick];
|
curlev->current = curlev->history[ttick];
|
||||||
curlev->current.centerview(curlev);
|
curlev->current.centerview(curlev);
|
||||||
anims::moved();
|
anims::moved();
|
||||||
|
@ -13,6 +13,7 @@ struct timestamp {
|
|||||||
ld circpos; /**< controls the wheel graphics */
|
ld circpos; /**< controls the wheel graphics */
|
||||||
ld slope; /**< the current slope */
|
ld slope; /**< the current slope */
|
||||||
ld t; /**< planning spline parameter */
|
ld t; /**< planning spline parameter */
|
||||||
|
ld timer = 0; /**< the timer, in seconds */
|
||||||
|
|
||||||
flagtype collected_triangles; /**< a bitset which shows which triangles are collected */
|
flagtype collected_triangles; /**< a bitset which shows which triangles are collected */
|
||||||
flagtype goals; /**< a bitset which shows which goals are complete */
|
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 */
|
bool tick(level*);/**< one tick of the simulation -- returns false if the unicycle has stopped or crashed */
|
||||||
void centerview(level*);
|
void centerview(level*);
|
||||||
void draw_unilcycle(const shiftmatrix&);
|
void draw_unilcycle(const shiftmatrix&);
|
||||||
void draw_instruments(level*, ld t);
|
void draw_instruments(level*);
|
||||||
ld energy_in_squares();
|
ld energy_in_squares();
|
||||||
bool collect(level*);
|
bool collect(level*);
|
||||||
void be_consistent();
|
void be_consistent();
|
||||||
@ -185,9 +186,6 @@ inline ld min_gfx_slope = +M_PI/2;
|
|||||||
/** current slope for rendering */
|
/** current slope for rendering */
|
||||||
inline ld gfx_slope = 0;
|
inline ld gfx_slope = 0;
|
||||||
|
|
||||||
/** the timer */
|
|
||||||
inline ld timer = 0;
|
|
||||||
|
|
||||||
/** default block unit */
|
/** default block unit */
|
||||||
inline double dft_block = 1;
|
inline double dft_block = 1;
|
||||||
|
|
||||||
|
@ -178,7 +178,6 @@ void level::draw_planning_screen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
current = history[mint];
|
current = history[mint];
|
||||||
timer = mint * 1. / tps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_sq(get_spline(closest_t), 0x8080FFFF, PPR::ITEM);
|
draw_sq(get_spline(closest_t), 0x8080FFFF, PPR::ITEM);
|
||||||
|
@ -134,6 +134,7 @@ bool timestamp::tick(level *lev) {
|
|||||||
where[2] = lev->surface(where);
|
where[2] = lev->surface(where);
|
||||||
circpos += mvel / whrad / tps;
|
circpos += mvel / whrad / tps;
|
||||||
|
|
||||||
|
timer += 1. / tps;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +170,11 @@ void timestamp::centerview(level *lev) {
|
|||||||
playermoved = false;
|
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<eGeometry> g(geometry, gEuclid);
|
||||||
dynamicval<eModel> pm(pmodel, mdDisk);
|
dynamicval<eModel> pm(pmodel, mdDisk);
|
||||||
dynamicval<bool> ga(vid.always3, false);
|
dynamicval<bool> ga(vid.always3, false);
|
||||||
@ -303,7 +308,7 @@ void timestamp::draw_instruments(level* l, ld t) {
|
|||||||
bool gsuccess = goals & Flag(gid);
|
bool gsuccess = goals & Flag(gid);
|
||||||
if(lshiftclick) gfailed = true, gsuccess = false;
|
if(lshiftclick) gfailed = true, gsuccess = false;
|
||||||
if(anyctrlclick) gfailed = false, gsuccess = true;
|
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);
|
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);
|
poly_outline = 0xFF; color_t f = darkena(g.color, 0, 0xFF);
|
||||||
if(gsuccess) {
|
if(gsuccess) {
|
||||||
@ -321,9 +326,9 @@ void timestamp::draw_instruments(level* l, ld t) {
|
|||||||
quickqueue();
|
quickqueue();
|
||||||
glflush();
|
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, format_timer(timer), 0, 16);
|
||||||
displaystr(vid.xres - vid.fsize, vid.fsize*2, 0, vid.fsize * 2, s, 0, 16);
|
|
||||||
|
|
||||||
|
string s;
|
||||||
if(loaded_or_planned) s = "R";
|
if(loaded_or_planned) s = "R";
|
||||||
else if(reversals) s = format("+%d", reversals);
|
else if(reversals) s = format("+%d", reversals);
|
||||||
else return;
|
else return;
|
||||||
|
Loading…
Reference in New Issue
Block a user