Rect *rects;
Color *colors;
- int *hiding;
size_t rects_size;
};
}
memcpy(platforms->colors, rect_layer_colors(layer), sizeof(Color) * platforms->rects_size);
- platforms->hiding = PUSH_LT(lt, nth_calloc(1, sizeof(int) * platforms->rects_size), free);
- if (platforms->hiding == NULL) {
- RETURN_LT(lt, NULL);
- }
- memset(platforms->hiding, 0, sizeof(int) * platforms->rects_size);
-
return platforms;
}
return result;
}
-
-#define HIDING_SPEED 2.0f
-
-void platforms_update(Platforms *platforms, float dt)
-{
- trace_assert(platforms);
- for (size_t i = 0; i < platforms->rects_size; ++i) {
- if (platforms->hiding[i]) {
- if (platforms->colors[i].a > 0.0f) {
- platforms->colors[i].a =
- fmaxf(0.0f, platforms->colors[i].a - HIDING_SPEED * dt);
- } else {
- platforms->hiding[i] = 0;
- }
- }
- }
-}
-
-void platforms_hide_platform_at(const Platforms *platforms,
- Vec2f position)
-{
- trace_assert(platforms);
-
- for (size_t i = 0; i < platforms->rects_size; ++i) {
- if (rect_contains_point(platforms->rects[i], position)) {
- platforms->hiding[i] = 1;
- }
- }
-}