mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-10-04 16:31:44 +00:00
ru:: two new platform shapes
This commit is contained in:
@@ -519,6 +519,26 @@ struct rope_platform : public moving_platform {
|
|||||||
void draw() override;
|
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 {
|
struct saw: public entity {
|
||||||
unique_ptr<entity> base;
|
unique_ptr<entity> base;
|
||||||
moving_platform& mp() { return (moving_platform&)(*base); }
|
moving_platform& mp() { return (moving_platform&)(*base); }
|
||||||
|
|||||||
@@ -647,6 +647,22 @@ xy pendulum_platform::location_at(ld t) {
|
|||||||
return from_hyper(rgpushxto0(h1) * rspintox(gpushxto0(h1) * h2) * xpush0(x));
|
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) {
|
xy ellipse_platform::location_at(ld t) {
|
||||||
if(points.empty()) {
|
if(points.empty()) {
|
||||||
auto h1 = to_hyper(a);
|
auto h1 = to_hyper(a);
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ void create_long_rope(room& r, int step, xy w) {
|
|||||||
|
|
||||||
mapswitch *lmev;
|
mapswitch *lmev;
|
||||||
|
|
||||||
|
moving_platform *last_platform;
|
||||||
|
|
||||||
void load_room(fhstream& f, cell *c) {
|
void load_room(fhstream& f, cell *c) {
|
||||||
setdist(c, 7, nullptr);
|
setdist(c, 7, nullptr);
|
||||||
auto& r = *get_room_at(c);
|
auto& r = *get_room_at(c);
|
||||||
@@ -329,11 +331,25 @@ void load_room(fhstream& f, cell *c) {
|
|||||||
else if(cap == "PENDULUM") {
|
else if(cap == "PENDULUM") {
|
||||||
auto b = std::make_unique<pendulum_platform>();
|
auto b = std::make_unique<pendulum_platform>();
|
||||||
b->a = get_xy(); b->b = get_xy(); b->period = get_ld(); b->shift = get_ld();
|
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));
|
r.entities.emplace_back(std::move(b));
|
||||||
}
|
}
|
||||||
else if(cap == "ELLIPSE") {
|
else if(cap == "ELLIPSE") {
|
||||||
auto b = std::make_unique<ellipse_platform>();
|
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();
|
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));
|
r.entities.emplace_back(std::move(b));
|
||||||
}
|
}
|
||||||
else if(cap == "SAW") {
|
else if(cap == "SAW") {
|
||||||
|
|||||||
Reference in New Issue
Block a user