1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2026-04-16 23:11:22 +00:00

ru:: two new platform shapes

This commit is contained in:
Zeno Rogue
2026-04-06 11:46:37 +02:00
parent 0cee4dbf95
commit 315c64c5e5
3 changed files with 52 additions and 0 deletions

View File

@@ -519,6 +519,26 @@ struct rope_platform : public moving_platform {
void draw() override;
};
struct horoplatform : public moving_platform {
xy a, b;
ld period, shift;
xy location_at(ld t) override;
string get_shape_name() override { return a.y == b.y ? "horo" : "equi"; }
string get_help() override { return
a.y == b.y ?
"Go back and forth between two locations, on a horocyclic path."
: "Go back and forth between two locations, on an equidistant path.";
}
};
struct cycloid_platform : public moving_platform {
moving_platform *base;
ld period, shift;
xy location_at(ld t) override;
string get_shape_name() override { return "cycloid"; }
string get_help() override { return "These go in a circle around another moving object."; }
};
struct saw: public entity {
unique_ptr<entity> base;
moving_platform& mp() { return (moving_platform&)(*base); }

View File

@@ -647,6 +647,22 @@ xy pendulum_platform::location_at(ld t) {
return from_hyper(rgpushxto0(h1) * rspintox(gpushxto0(h1) * h2) * xpush0(x));
}
xy horoplatform::location_at(ld t) {
ld tp = t / game_fps / period - shift;
tp = tp - floor(tp);
tp = min(2*tp, 2-2*tp);
return xy(lerp(a.x, b.x, tp), lerp(a.y, b.y, tp));
}
xy cycloid_platform::location_at(ld t) {
auto b =base->location_at(t);
auto h1 = to_hyper(b);
auto ph = t / game_fps / period + shift;
auto h2 = rgpushxto0(h1) * xspinpush0(ph * TAU, radius);
auto p = from_hyper(h2);
return p;
}
xy ellipse_platform::location_at(ld t) {
if(points.empty()) {
auto h1 = to_hyper(a);

View File

@@ -108,6 +108,8 @@ void create_long_rope(room& r, int step, xy w) {
mapswitch *lmev;
moving_platform *last_platform;
void load_room(fhstream& f, cell *c) {
setdist(c, 7, nullptr);
auto& r = *get_room_at(c);
@@ -329,11 +331,25 @@ void load_room(fhstream& f, cell *c) {
else if(cap == "PENDULUM") {
auto b = std::make_unique<pendulum_platform>();
b->a = get_xy(); b->b = get_xy(); b->period = get_ld(); b->shift = get_ld();
last_platform = &*b;
r.entities.emplace_back(std::move(b));
}
else if(cap == "HORO") {
auto b = std::make_unique<horoplatform>();
b->a = get_xy(); b->b = get_xy(); b->period = get_ld(); b->shift = get_ld();
last_platform = &*b;
r.entities.emplace_back(std::move(b));
}
else if(cap == "ELLIPSE") {
auto b = std::make_unique<ellipse_platform>();
b->a = get_xy(); b->b = get_xy(); b->period = get_ld(); b->shift = get_ld(); b->ratio = get_ld();
last_platform = &*b;
r.entities.emplace_back(std::move(b));
}
else if(cap == "CYCLOID") {
auto b = std::make_unique<cycloid_platform>();
b->base = last_platform; b->radius = get_ld(); b->period = get_ld(); b->shift = get_ld();
last_platform = &*b;
r.entities.emplace_back(std::move(b));
}
else if(cap == "SAW") {