diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index 84f56a10..38b6a3f3 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -332,6 +332,16 @@ struct pendulum_platform : public moving_platform { string get_help() override { return "These pendulum platforms go back and forth between two locations, taking the shortest path possible."; } }; +struct rope_platform : public moving_platform { + ld period, shift, dist, max_swing; + xy location_at(ld t) override; + int width() override { return 1; } + eWall platform_type() override { return wStaircase; } + string glyph() override { return "-"; } + string get_name() override { return "Swinging rope"; } + string get_help() override { return "A part of a swinging rope."; } + }; + struct timed_orb : public entity { int duration; xy siz() override { return {18, 18}; } diff --git a/rogueviz/ru/entity.cpp b/rogueviz/ru/entity.cpp index 5853c7b9..bbb695e2 100644 --- a/rogueviz/ru/entity.cpp +++ b/rogueviz/ru/entity.cpp @@ -442,6 +442,10 @@ xy ferris_platform::location_at(ld t) { return from_hyper(rgpushxto0(to_hyper(ctr)) * xspinpush0(t / game_fps + shift, radius)); } +xy rope_platform::location_at(ld t) { + return from_hyper(eupush(to_hyper(ctr)) * xspinpush0(sin(t / game_fps / period * TAU + shift) * max_swing, dist)); + } + xy pendulum_platform::location_at(ld t) { auto h1 = to_hyper(a); auto h2 = to_hyper(b); diff --git a/rogueviz/ru/map.ru b/rogueviz/ru/map.ru index acd2ac7a..58a8f65e 100644 --- a/rogueviz/ru/map.ru +++ b/rogueviz/ru/map.ru @@ -1508,3 +1508,102 @@ Jack the trader Do you want to buy anthing?\n\nSorry for the traps, last week a thief stole my stuff and escaped through some secret door. So I installed some for protection.\n\nNo idea where it is... OK +MOVE 4 Timed Passage +ROOM Swinging Rope Room +# wall +- platform +. 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#b +ROPE 300 0 0.7 50 5 0 60 +OK + +MOVE 1 Swinging Rope Room +ROOM Above the Rope +! magic fountain +# wall +- platform +. air +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#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b.................. +ROPE 584 288 0.7 50 5 0 60 +OK diff --git a/rogueviz/ru/save.cpp b/rogueviz/ru/save.cpp index 80ed9162..83163f8c 100644 --- a/rogueviz/ru/save.cpp +++ b/rogueviz/ru/save.cpp @@ -234,6 +234,17 @@ void load_room(fhstream& f, cell *c) { r.entities.emplace_back(std::move(b)); } } + else if(cap == "ROPE") { + ld cx, cy, radius, period, shift, max_swing; int qty; + sscanf(param.c_str(), "%lf%lf%lf%d%lf%lf%lf", &cx, &cy, &radius, &qty, &period, &shift, &max_swing); + + for(int i=0; i(); + b->ctr = {cx, cy}; b->radius = radius; b->period = period; b->max_swing = max_swing * 1._deg; b->shift = shift; + b->dist = radius * (i+0.5) / qty; + r.entities.emplace_back(std::move(b)); + } + } else if(cap == "PENDULUM") { auto b = std::make_unique(); 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);