mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
nilrider:: load plans as ghosts
This commit is contained in:
parent
c9b1b47150
commit
c4a5438f8d
@ -63,6 +63,17 @@ void frame() {
|
||||
curlev->draw_level_rec(V);
|
||||
|
||||
curlev->current.draw_unilcycle(V);
|
||||
|
||||
for(auto g: curlev->ghosts) {
|
||||
ld t = curlev->current.timer;
|
||||
int a = 0, b = isize(g.history);
|
||||
while(a != b) {
|
||||
int s = (a + b) / 2;
|
||||
if(g.history[s].timer < t) a = s + 1;
|
||||
else b = s;
|
||||
}
|
||||
if(b < isize(g.history)) g.history[b].draw_unilcycle(V);
|
||||
}
|
||||
}
|
||||
|
||||
bool crash_sound = true;
|
||||
@ -756,6 +767,9 @@ auto celldemo = arg::add3("-unilcycle", initialize) + arg::add3("-unilplan", []
|
||||
nisot::geodesic_movement = false;
|
||||
pmodel = mdPerspective;
|
||||
pconf.rotational_nil = 0;
|
||||
})
|
||||
+ arg::add3("-ghost-replays", [] {
|
||||
for(auto& g: curlev->plan_replays) curlev->load_plan_as_ghost(g);
|
||||
});
|
||||
|
||||
auto hook0= addHook(hooks_configfile, 300, default_settings);
|
||||
|
@ -105,6 +105,10 @@ struct goal {
|
||||
|
||||
using surface_fun = std::function<ld(hyperpoint h)>;
|
||||
|
||||
struct ghost {
|
||||
vector<timestamp> history;
|
||||
};
|
||||
|
||||
struct level {
|
||||
string name;
|
||||
char hotkey;
|
||||
@ -180,6 +184,7 @@ struct level {
|
||||
void init();
|
||||
|
||||
vector<timestamp> history;
|
||||
vector<ghost> ghosts;
|
||||
|
||||
vector<manual_replay> manual_replays;
|
||||
vector<plan_replay> plan_replays;
|
||||
@ -221,6 +226,8 @@ struct level {
|
||||
vector<level*> gen_layer_list() {
|
||||
vector<level*> res; gen_layer_list(res); return res;
|
||||
}
|
||||
|
||||
void load_plan_as_ghost(plan_replay&);
|
||||
};
|
||||
|
||||
/** wheel radius */
|
||||
|
@ -105,4 +105,23 @@ void load() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void level::load_plan_as_ghost(plan_replay& r) {
|
||||
vector<timestamp> history_backup;
|
||||
swap(history_backup, history);
|
||||
swap(r.plan, plan);
|
||||
history.clear();
|
||||
history.push_back(start);
|
||||
while(true) {
|
||||
int s = isize(history);
|
||||
if(!simulate()) break;
|
||||
if(isize(history) == s) break;
|
||||
}
|
||||
println(hlog, "a history of length ", isize(history), " becomes a ghost");
|
||||
ghosts.emplace_back();
|
||||
auto& g = ghosts.back();
|
||||
g.history = std::move(history);
|
||||
swap(history_backup, history);
|
||||
swap(r.plan, plan);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user