diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index ae54ad8a..84f56a10 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -305,7 +305,9 @@ extern man m; struct moving_platform : public entity { xy ctr; ld radius, shift; - xy siz() override { return {36, 12}; } + virtual int width() { return 3; } + virtual eWall platform_type() { return wWall; } + xy siz() override { return {12.*width(), 12}; } string glyph() override { return "#"; } color_t color() override { return 0xFFFFFFFF; } virtual xy location_at(ld t) = 0; diff --git a/rogueviz/ru/entity.cpp b/rogueviz/ru/entity.cpp index 846bae2e..5853c7b9 100644 --- a/rogueviz/ru/entity.cpp +++ b/rogueviz/ru/entity.cpp @@ -178,29 +178,35 @@ void entity::apply_walls() { auto pb = p->get_pixel_bbox_at(screen_ctr); if(intersect(pb, eb)) { - zero_vel = (rmow - screen_ctr) * get_scale_at(npw.y) + npw - where; - + auto zvel = (rmow - screen_ctr) * get_scale_at(npw.y) + npw - where; bool reset = false; - if(intersect(pb, get_pixel_bbox_at(rmow))) { /* should not happen */ } + if(p->platform_type() == wStaircase) { + if(!fallthru) { on_floor = true; zero_vel = zvel; if(rvel.y > 0) rvel.y = 0; } + } + + else if(intersect(pb, get_pixel_bbox_at(rmow))) { /* should not happen */ } else if(!intersect(pb, get_pixel_bbox_at(rmow + xy(rvel.x, 0))) && rvel.y > 0) { on_floor = true; rvel.y /= 2; if(abs(rvel.y) < 1e-6) rvel.y = 0; reset = true; + zero_vel = zvel; } else if(!intersect(pb, get_pixel_bbox_at(rmow + xy(rvel.x, 0))) && rvel.y < 0) { rvel.y /= 2; if(abs(rvel.y) < 1e-6) rvel.y = 0; reset = true; + zero_vel = zvel; } else { rvel.x = -rvel.x; reset = true; + zero_vel = zvel; } vel = (rmow + rvel - screen_ctr) * get_scale_at(npw.y) + npw - where; @@ -446,12 +452,13 @@ xy pendulum_platform::location_at(ld t) { void moving_platform::draw() { double d = get_scale(); - for(int w=-1; w<=1; w++) { - ld minx = where.x + siz().x * d * (w - 0.5) / 3; + auto wi = width(); + for(int w=0; w