1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-05-16 22:24:07 +00:00

ru:: pendulum platforms

This commit is contained in:
Zeno Rogue 2025-05-03 22:09:30 +02:00
parent 828160f548
commit b9230bd662
4 changed files with 98 additions and 20 deletions

View File

@ -257,6 +257,16 @@ struct moving_platform : public entity {
struct ferris_platform : public moving_platform {
xy location_at(ld t) override;
string get_name() override { return "Ferris platform"; }
string get_help() override { return "Ferris wheel platforms, powered by some ancient mechanism. They always go in perfect circles, with constant velocity."; }
};
struct pendulum_platform : public moving_platform {
xy a, b;
ld period, shift;
xy location_at(ld t) override;
string get_name() override { return "pendulum platform"; }
string get_help() override { return "These pendulum platforms go back and forth between two locations, taking the shortest path possible."; }
};
struct npc : public entity {

View File

@ -296,6 +296,14 @@ xy ferris_platform::location_at(ld t) {
return from_hyper(rgpushxto0(to_hyper(ctr)) * xspinpush0(t / game_fps + shift, radius));
}
xy pendulum_platform::location_at(ld t) {
auto h1 = to_hyper(a);
auto h2 = to_hyper(b);
auto d = hdist(h1, h2);
auto x = (1 - cos(t / game_fps * TAU / period)) / 2 * d;
return from_hyper(rgpushxto0(h1) * rspintox(gpushxto0(h1) * h2) * xpush0(x));
}
void moving_platform::draw() {
double d = get_scale();
for(int w=-1; w<=1; w++) {

View File

@ -1048,6 +1048,7 @@ MOVE 2 Central Cavern Bottom Left
ROOM Ferris Wheel
# wall
. air
- staircase
^ spike
MAP
################################################################################
@ -1058,30 +1059,30 @@ MAP
#########.#b#b......................................................###b#b######
########....####..................................................######...#####
#######.....#b#b#####.............................................#b#b.....#####
######.......................................................######........#####
#####......................................................................#####
####........................................................................####
####........................................................................####
###.........................................................................####
###..........................................................................###
##...........................................................................###
##..............................................................................
.#####.......................................................######........#####
.####......................................................................#####
.###........................................................................####
.##.........................................................................####
.#..........................................................................####
.............................................................................###
.............................................................................###
................................................................................
................................................................................
................................................................................
................................................................................
####################^......................................^####################
####################........................................####################
####################........................................####################
####################........................................####################
####################........................................####################
###########...........................................................##########
###########...........................................................##########
###########...........................................................##########
###########...........................................................##########
####################........................................####################
####################........................................####################
####################........................................####################
................................................................................
...........-########^......................................^####################
..........-#########........................................####################
.........-##########........................................####################
........-###########........................................####################
.......-############........................................####################
......-####...........................................................##########
.....-#####...........................................................##########
....-######...........................................................##########
...-#######...........................................................##########
..-#################........................................####################
.-##################........................................####################
-###################........................................####################
####################........................................####################
####################........................................####################
####################........................................####################
@ -1104,3 +1105,57 @@ ITEM 542 211 8
gold
You find some more gold.
OK
MOVE 2 Ferris Wheel
ROOM Platform Fest
# wall
- staircase
. air
^ spike
MAP
################################################################################
################################################################################
#################################..........................#####################
.................#########..............................................########
..........................................................................######
...........................................................................#####
...........................................................................#####
####.......................................................................#####
####.......................................................................#####
####.......................................................................#####
####.......................................................................#####
####.......................................................................####.
####.......................................................................###..
####.......................................................................##...
####.......................................................................#....
####.......................................................................#....
####.......................................................................#....
####.......................................................................#....
####.......................................................................#....
####.......................................................................#....
####.......................................................................#....
#####......................................................................#....
#####......................................................................#....
#####......................................................................#....
####.......................................................................#....
####......................................................................^.....
####.....................................................................^......
####....................................................................^.......
####...................................................................^.......-
####..................................................................^.......-#
###..................................................................^.......-##
###.........................................................................-###
####.......................................................................-####
####......................................................................-#####
####.....................................................................-######
#b#b.......^...........^..............^.................^...............-####b#b
################################################################################
#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b
################################################################################
#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b
PENDULUM 63 264 90 200 5 0
PENDULUM 200 208 303 235 6 0
PENDULUM 344 229 513 231 5 0
PENDULUM 551 215 554 70 6 0
PENDULUM 510 60 60 60 5 0
OK

View File

@ -145,6 +145,11 @@ void load_room(fhstream& f, cell *c) {
r.entities.emplace_back(std::move(b));
}
}
else if(cap == "PENDULUM") {
auto b = std::make_unique<pendulum_platform>();
sscanf(param.c_str(), "%lf%lf%lf%lf%lf%lf", &b->a.x, &b->a.y, &b->b.x, &b->b.y, &b->period, &b->shift);
r.entities.emplace_back(std::move(b));
}
else if(cap == "HINT") {
auto b = std::make_unique<hint>();
sscanf(param.c_str(), "%lf%lf%lf%lf", &b->where.x, &b->where.y, &b->size.x, &b->size.y);