1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-10-18 06:30:41 +00:00

nilrider:: support different unicycle color schemes

This commit is contained in:
Zeno Rogue 2024-08-20 11:47:26 +02:00
parent c4a5438f8d
commit 0ffb187d32
4 changed files with 32 additions and 14 deletions

View File

@ -62,7 +62,7 @@ void frame() {
curlev->draw_level_rec(V); curlev->draw_level_rec(V);
curlev->current.draw_unilcycle(V); curlev->current.draw_unilcycle(V, my_scheme);
for(auto g: curlev->ghosts) { for(auto g: curlev->ghosts) {
ld t = curlev->current.timer; ld t = curlev->current.timer;
@ -72,7 +72,7 @@ void frame() {
if(g.history[s].timer < t) a = s + 1; if(g.history[s].timer < t) a = s + 1;
else b = s; else b = s;
} }
if(b < isize(g.history)) g.history[b].draw_unilcycle(V); if(b < isize(g.history)) g.history[b].draw_unilcycle(V, g.cs);
} }
} }
@ -547,7 +547,7 @@ void main_menu() {
dialog::add_action([] { dialog::add_action([] {
vector<int> ang; vector<int> ang;
for(auto& h: curlev->history) ang.push_back(heading_to_int(h.heading_angle)); for(auto& h: curlev->history) ang.push_back(heading_to_int(h.heading_angle));
curlev->manual_replays.emplace_back(manual_replay{new_replay_name(), std::move(ang)}); curlev->manual_replays.emplace_back(manual_replay{new_replay_name(), my_scheme, std::move(ang)});
save(); save();
}); });
@ -559,7 +559,7 @@ void main_menu() {
#if CAP_SAVE #if CAP_SAVE
dialog::addItem("save this plan", 's'); dialog::addItem("save this plan", 's');
dialog::add_action([] { dialog::add_action([] {
curlev->plan_replays.emplace_back(plan_replay{new_replay_name(), curlev->plan}); curlev->plan_replays.emplace_back(plan_replay{new_replay_name(), my_scheme, curlev->plan});
save(); save();
}); });

View File

@ -9,6 +9,21 @@ struct level;
/** ticks per second */ /** ticks per second */
inline const ld tps = 1000; inline const ld tps = 1000;
struct colorscheme {
color_t wheel1, wheel2, seat, seatpost;
colorscheme(int i) {
if(i == 1) { wheel1 = 0xFFFF40FF; wheel2 = 0xFF4040FF; seat = 0x303030FF; seatpost = 0x303030FF; }
if(i == 2) {
wheel1 = 0xFF | ((rand() % 0x1000000) << 8);
wheel2 = 0xFF | ((rand() % 0x1000000) << 8);
seat = 0xFF | ((rand() % 0x1000000) << 8);
seatpost = 0xFF | ((rand() % 0x1000000) << 8);
}
}
};
colorscheme my_scheme(1);
struct timestamp { struct timestamp {
hyperpoint where; /**< the current position of the unicycle */ hyperpoint where; /**< the current position of the unicycle */
ld heading_angle; /**< the current heading angle */ ld heading_angle; /**< the current heading angle */
@ -36,7 +51,7 @@ struct timestamp {
bool tick(level*, ld timeleft = 1. / tps);/**< one tick of the simulation -- returns false if the unicycle has stopped or crashed */ bool tick(level*, ld timeleft = 1. / tps);/**< 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&, const colorscheme& cs);
void draw_instruments(level*); void draw_instruments(level*);
ld energy_in_squares(); ld energy_in_squares();
bool collect(level*); bool collect(level*);
@ -75,11 +90,13 @@ struct triangledata {
struct manual_replay { struct manual_replay {
string name; string name;
colorscheme cs;
vector<int> headings; vector<int> headings;
}; };
struct plan_replay { struct plan_replay {
string name; string name;
colorscheme cs;
plan_t plan; plan_t plan;
}; };
@ -106,6 +123,7 @@ struct goal {
using surface_fun = std::function<ld(hyperpoint h)>; using surface_fun = std::function<ld(hyperpoint h)>;
struct ghost { struct ghost {
colorscheme cs;
vector<timestamp> history; vector<timestamp> history;
}; };

View File

@ -70,7 +70,7 @@ void load() {
if(size < 0 || size > 1000000) throw hstream_exception(); if(size < 0 || size > 1000000) throw hstream_exception();
for(int i=0; i<size; i++) headings.push_back(scan<int>(f)); for(int i=0; i<size; i++) headings.push_back(scan<int>(f));
auto l = level_by_name(lev); auto l = level_by_name(lev);
if(l) l->manual_replays.emplace_back(manual_replay{name, std::move(headings)}); if(l) l->manual_replays.emplace_back(manual_replay{name, colorscheme(2), std::move(headings)});
continue; continue;
} }
if(s == "*PLANNING") { if(s == "*PLANNING") {
@ -82,7 +82,7 @@ void load() {
plan.resize(size, {C0, C0}); plan.resize(size, {C0, C0});
for(int i=0; i<size; i++) scan(f, plan[i].at[0], plan[i].at[1], plan[i].vel[0], plan[i].vel[1]); for(int i=0; i<size; i++) scan(f, plan[i].at[0], plan[i].at[1], plan[i].vel[0], plan[i].vel[1]);
auto l = level_by_name(lev); auto l = level_by_name(lev);
if(l) l->plan_replays.emplace_back(plan_replay{name, std::move(plan)}); if(l) l->plan_replays.emplace_back(plan_replay{name, colorscheme(2), std::move(plan)});
continue; continue;
} }
if(s == "*RECORD") { if(s == "*RECORD") {
@ -117,7 +117,7 @@ void level::load_plan_as_ghost(plan_replay& r) {
if(isize(history) == s) break; if(isize(history) == s) break;
} }
println(hlog, "a history of length ", isize(history), " becomes a ghost"); println(hlog, "a history of length ", isize(history), " becomes a ghost");
ghosts.emplace_back(); ghosts.emplace_back(ghost{r.cs, {}});
auto& g = ghosts.back(); auto& g = ghosts.back();
g.history = std::move(history); g.history = std::move(history);
swap(history_backup, history); swap(history_backup, history);

View File

@ -8,7 +8,7 @@ EX hyperpoint sym_to_used(hyperpoint H) {
return H; return H;
} }
void timestamp::draw_unilcycle(const shiftmatrix& V) { void timestamp::draw_unilcycle(const shiftmatrix& V, const colorscheme& cs) {
const int points = 60 / (1 + reduce_quality); const int points = 60 / (1 + reduce_quality);
const int spoke_each = 5; const int spoke_each = 5;
hyperpoint whpoint[points+1]; hyperpoint whpoint[points+1];
@ -36,9 +36,9 @@ void timestamp::draw_unilcycle(const shiftmatrix& V) {
curvepoint(whpoint[a+b]); curvepoint(whpoint[a+b]);
curvepoint(hub[b]); curvepoint(hub[b]);
if(a&1) if(a&1)
queuecurve(V * rgpushxto0(where), 0xFFFFFFFF, 0xFFFF40FF, PPR::WALL); queuecurve(V * rgpushxto0(where), 0xFFFFFFFF, cs.wheel1, PPR::WALL);
else else
queuecurve(V * rgpushxto0(where), 0xFFFFFFFF, 0xFF4040FF, PPR::WALL); queuecurve(V * rgpushxto0(where), 0xFFFFFFFF, cs.wheel2, PPR::WALL);
} }
if(1) { if(1) {
@ -46,7 +46,7 @@ void timestamp::draw_unilcycle(const shiftmatrix& V) {
curvepoint(base + Ta * point3(-hublen, -hublen, whrad+hublen)); curvepoint(base + Ta * point3(-hublen, -hublen, whrad+hublen));
curvepoint(base + Ta * point3(-hublen, +hublen, whrad+hublen)); curvepoint(base + Ta * point3(-hublen, +hublen, whrad+hublen));
curvepoint(base + Ta * point3(hublen, 0, whrad+hublen)); curvepoint(base + Ta * point3(hublen, 0, whrad+hublen));
queuecurve(V * rgpushxto0(where), 0xFF, 0x303030FF, PPR::WALL); queuecurve(V * rgpushxto0(where), 0xFF, cs.seat, PPR::WALL);
for(auto& y: {hublen, -hublen}) { for(auto& y: {hublen, -hublen}) {
curvepoint(base + Ta * point3(hublen * .1, -y, 0)); curvepoint(base + Ta * point3(hublen * .1, -y, 0));
@ -54,14 +54,14 @@ void timestamp::draw_unilcycle(const shiftmatrix& V) {
curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen / 2)); curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen / 2));
curvepoint(base + Ta * point3(hublen * .1, 0, whrad + hublen / 2)); curvepoint(base + Ta * point3(hublen * .1, 0, whrad + hublen / 2));
curvepoint(base + Ta * point3(hublen * .1, -y, 0)); curvepoint(base + Ta * point3(hublen * .1, -y, 0));
queuecurve(V * rgpushxto0(where), 0xFF, 0x303030FF, PPR::WALL); queuecurve(V * rgpushxto0(where), 0xFF, cs.seatpost, PPR::WALL);
curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen / 2)); curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen / 2));
curvepoint(base + Ta * point3(hublen * .1, 0, whrad + hublen / 2)); curvepoint(base + Ta * point3(hublen * .1, 0, whrad + hublen / 2));
curvepoint(base + Ta * point3(hublen * .1, 0, whrad + hublen)); curvepoint(base + Ta * point3(hublen * .1, 0, whrad + hublen));
curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen)); curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen));
curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen / 2)); curvepoint(base + Ta * point3(hublen * -.1, 0, whrad + hublen / 2));
queuecurve(V * rgpushxto0(where), 0xFF, 0x303030FF, PPR::WALL); queuecurve(V * rgpushxto0(where), 0xFF, cs.seatpost, PPR::WALL);
} }
} }
} }