]> git.lizzy.rs Git - nothing.git/blob - src/game/level/solid.c
(#639) Introduce rigid_bodies_collide_with_itself
[nothing.git] / src / game / level / solid.c
1 #include "boxes.h"
2 #include "platforms.h"
3 #include "player.h"
4 #include "player/rigid_rect.h"
5 #include "solid.h"
6
7 void solid_touches_rect_sides(Solid_ref solid,
8                               Rect object,
9                               int sides[RECT_SIDE_N])
10 {
11     switch (solid.tag) {
12     case SOLID_PLATFORMS:
13         platforms_touches_rect_sides((Platforms *) solid.ptr, object, sides);
14         break;
15
16     case SOLID_RIGID_RECT:
17         rigid_rect_touches_rect_sides((Rigid_rect *) solid.ptr, object, sides);
18         break;
19
20     case SOLID_PLAYER:
21         player_touches_rect_sides((Player *) solid.ptr, object, sides);
22         break;
23     }
24 }
25
26 void solid_apply_force(Solid_ref solid,
27                        Vec force)
28 {
29     switch (solid.tag) {
30     case SOLID_PLATFORMS:
31         /* no implementation */
32         break;
33
34     case SOLID_RIGID_RECT:
35         rigid_rect_apply_force((Rigid_rect *) solid.ptr, force);
36         break;
37
38     case SOLID_PLAYER:
39         player_apply_force((Player *) solid.ptr, force);
40         break;
41
42     default: {}
43     }
44 }
45
46 void solid_collide_with_solid(Solid_ref solid,
47                               Solid_ref other_solid)
48 {
49     switch (solid.tag) {
50     case SOLID_PLATFORMS:
51         /* no implementation */
52         break;
53
54     case SOLID_RIGID_RECT:
55         rigid_rect_collide_with_solid((Rigid_rect *) solid.ptr, other_solid);
56         break;
57
58     case SOLID_PLAYER:
59         player_collide_with_solid((Player *) solid.ptr, other_solid);
60         break;
61
62     default: {}
63     }
64 }