inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.24748737"
- inkscape:cx="4815.7619"
- inkscape:cy="2613.6522"
+ inkscape:cx="6339.0719"
+ inkscape:cy="2650.0177"
inkscape:document-units="mm"
inkscape:current-layer="svg4541"
showgrid="false"
- inkscape:window-width="956"
+ inkscape:window-width="1916"
inkscape:window-height="1023"
inkscape:window-x="0"
inkscape:window-y="36"
y="-581.78223"
inkscape:label="#rect4617" />
<rect
- style="fill:#445016;fill-opacity:1;stroke:none;stroke-width:0.57905543"
+ style="fill:#445016;fill-opacity:1;stroke:none;stroke-width:0.5093438"
id="box-1-3"
width="25.34539"
- height="75.592064"
- x="1239.7523"
- y="-478.45993"
+ height="58.486813"
+ x="1885.4755"
+ y="-525.49939"
inkscape:label="#player-3" />
<rect
style="fill:#445016;fill-opacity:1;stroke:none;stroke-width:0.36330926"
5
1111.9325 -526.31775 43.519718 43.519718 445016
909.78552 -581.78223 71.628235 67.351921 445016
-1239.7523 -478.45993 25.34539 75.592064 445016
+1885.4755 -525.49939 25.34539 58.486813 445016
1420.4265 -573.60791 26.414469 28.552624 445016
1679.1434 -511.60135 43.519718 43.519718 445016
#include "color.h"
#include "game/level/lava/wavy_rect.h"
#include "lava.h"
+#include "math/rect.h"
#include "system/error.h"
#include "system/lt.h"
return 0;
}
+
+rect_t lava_overlap_area(const lava_t *lava,
+ rect_t object)
+{
+ for (size_t i = 0; i < lava->rects_count; ++i) {
+ if (wavy_rect_overlaps(lava->rects[i], object)) {
+ return wavy_rect_overlap_area(lava->rects[i], object);
+ }
+ }
+
+ return rect(0.0f, 0.0f, 0.0f, 0.0f);
+}
int lava_overlaps_rect(const lava_t *lava,
rect_t rect);
+rect_t lava_overlap_area(const lava_t *lava,
+ rect_t rect);
+
#endif // LAVA_H_
assert(wavy_rect);
return rects_overlap(wavy_rect->rect, rect);
}
+
+rect_t wavy_rect_overlap_area(const wavy_rect_t *wavy_rect,
+ rect_t rect)
+{
+ assert(wavy_rect);
+ return rects_overlap_area(wavy_rect->rect, rect);
+}
int wavy_rect_overlaps(const wavy_rect_t *wavy_rect,
rect_t rect);
+rect_t wavy_rect_overlap_area(const wavy_rect_t *wavy_rect,
+ rect_t rect);
#endif // WAVY_RECT_H_
vec_t size;
color_t color;
int touches_ground;
+ float floating;
};
static const vec_t opposing_rect_side_forces[RECT_SIDE_N] = {
rigid_rect->size = vec(rect.w, rect.h);
rigid_rect->color = color;
rigid_rect->touches_ground = 0;
+ rigid_rect->floating = 0.0f;
return rigid_rect;
}
rigid_rect->touches_ground = 0;
- rigid_rect->velocity.y += RIGID_RECT_GRAVITY * delta_time;
+ if (rigid_rect->floating > 1e-6) {
+ rigid_rect->velocity = vec_sum(
+ rigid_rect->velocity,
+ vec_scala_mult(
+ vec_sum(
+ vec(0.0f, RIGID_RECT_GRAVITY),
+ vec(0.0f, -RIGID_RECT_GRAVITY * 1.1f * rigid_rect->floating)),
+ delta_time));
+
+ } else {
+ rigid_rect->velocity = vec_sum(
+ rigid_rect->velocity,
+ vec_scala_mult(
+ vec(0.0f, RIGID_RECT_GRAVITY),
+ delta_time));
+ }
+
+
rigid_rect->position = vec_sum(
rigid_rect->position,
vec_scala_mult(
assert(rigid_rect);
assert(lava);
-
+ rect_t overlap_area = lava_overlap_area(lava, rigid_rect_hitbox(rigid_rect));
+ rigid_rect->floating = (overlap_area.w * overlap_area.h) / (rigid_rect->size.x * rigid_rect->size.y);
}