diff options
author | BoredGuy <osome3717@gmail.com> | 2024-12-23 12:32:54 +0300 |
---|---|---|
committer | BoredGuy <osome3717@gmail.com> | 2024-12-23 12:32:54 +0300 |
commit | 61252071880c625b367623191cc86b3a98b8d562 (patch) | |
tree | 4718d62c7b13e4f7482a6ee7cdb33cec3e5d69b4 /Week1-Pacman/src/main.c | |
parent | ac7ba6dc94f6eb2d8cf9092391714247bb947148 (diff) |
Work started on adding a level system
- Levels load from tiled CSV export
- Levels also draw
We need to add collisions with the level and adjust the level's width
and height to fit well in a 4:3 window
Diffstat (limited to 'Week1-Pacman/src/main.c')
-rw-r--r-- | Week1-Pacman/src/main.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/Week1-Pacman/src/main.c b/Week1-Pacman/src/main.c index e4113be..373d795 100644 --- a/Week1-Pacman/src/main.c +++ b/Week1-Pacman/src/main.c @@ -3,6 +3,7 @@ #include <stdbool.h> #include "demo.h" #include "pacman.h" +#include "map.h" #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 @@ -25,10 +26,16 @@ int main() { SDL_Event e; struct pacman pacman = {0}; + + map_init(&demo); + + struct map map = {0}; + load_map("assets/Maps/maze.csv", &map); + for(int i = 0; i < 4; i++) init_animation(&pacman.animations[i], &(struct animation_init){ .ren = demo.ren, - .spritesheet = "assets/sprites.png", + .spritesheet = "assets/Sprites/sprites.png", .initial_angle = 90.0 * i, .initial_frame_count = 3, @@ -36,21 +43,21 @@ int main() { .initial_frames = (SDL_Rect[]) { { .x = 0, - .y = 190, - .w = 120, - .h = 130 + .y = 285, + .w = 180, + .h = 195 }, { - .x = 160, - .y = 190, - .w = 120, - .h = 130 + .x = 240, + .y = 285, + .w = 180, + .h = 195 }, { - .x = 310, - .y = 190, - .w = 130, - .h = 130 + .x = 465, + .y = 285, + .w = 195, + .h = 195 } } }); @@ -74,6 +81,7 @@ int main() { SDL_RenderClear(demo.ren); update_pacman(&pacman, dt); update_demo(&demo); + draw_map(&demo, &map); draw_pacman(&demo, &pacman); SDL_RenderPresent(demo.ren); } |