diff options
Diffstat (limited to 'Week1-Pacman/src/main.c')
-rw-r--r-- | Week1-Pacman/src/main.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Week1-Pacman/src/main.c b/Week1-Pacman/src/main.c index 373d795..90e085b 100644 --- a/Week1-Pacman/src/main.c +++ b/Week1-Pacman/src/main.c @@ -4,11 +4,13 @@ #include "demo.h" #include "pacman.h" #include "map.h" +#include "collision.h" #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 int main() { + int counter = 0; SDL_Init(SDL_INIT_EVERYTHING); struct demo demo = {0}; @@ -84,6 +86,21 @@ int main() { draw_map(&demo, &map); draw_pacman(&demo, &pacman); SDL_RenderPresent(demo.ren); + + SDL_Rect r = { + .x = pacman.xpos, + .y = pacman.ypos, + .w = 40, + .h = 40 + }; + + for(int i = 0; i < map.collider_count; i++) { + if(is_colliding(&r, &map.colliders[i])) { + printf("%d: Collision!\n", counter); + counter++; + break; + } + } } SDL_DestroyRenderer(demo.ren); |