]> git.lizzy.rs Git - nothing.git/commitdiff
(#68) Implement rendering and updating of the boxes
authorrexim <reximkut@gmail.com>
Sat, 12 May 2018 16:19:15 +0000 (23:19 +0700)
committerrexim <reximkut@gmail.com>
Sat, 12 May 2018 16:19:15 +0000 (23:19 +0700)
src/game/level/boxes.c
src/game/level/boxes.h

index 1e54d9298bee7b30d4bc1b0bb2f7fa3a7f0775cd..cc487a945067f7be66b7d7204624f70954fe8185 100644 (file)
@@ -56,13 +56,29 @@ int boxes_render(boxes_t *boxes, camera_t *camera)
 {
     assert(boxes);
     assert(camera);
+
+    for (size_t i = 0; i < boxes->count; ++i) {
+        if (rigid_rect_render(boxes->bodies[i], camera) < 0) {
+            return -1;
+        }
+    }
+
     return 0;
 }
 
-int boxes_update(boxes_t *boxes, float delta_time)
+int boxes_update(boxes_t *boxes,
+                 const platforms_t *platforms,
+                 float delta_time)
 {
     assert(boxes);
     assert(delta_time);
+
+    for (size_t i = 0; i < boxes->count; ++i) {
+        if (rigid_rect_update(boxes->bodies[i], platforms, delta_time) < 0) {
+            return -1;
+        }
+    }
+
     return 0;
 }
 
index d2da86ae64dac3dc39de25f879fdec3c30f32261..1a1239762bd0fc8776cea387105af6ac1105be95 100644 (file)
@@ -10,7 +10,7 @@ boxes_t *create_boxes_from_stream(FILE *stream);
 void destroy_boxes(boxes_t *boxes);
 
 int boxes_render(boxes_t *boxes, camera_t *camera);
-int boxes_update(boxes_t *boxes, float delta_time);
+int boxes_update(boxes_t *boxes, const platforms_t *platforms, float delta_time);
 int boxes_collide_with_platforms(boxes_t *boxes, platforms_t *platforms);
 
 #endif  // BOXES_H_