From 61252071880c625b367623191cc86b3a98b8d562 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Mon, 23 Dec 2024 12:32:54 +0300 Subject: 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 --- Week1-Pacman/src/main.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'Week1-Pacman/src/main.c') 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 #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); } -- cgit v1.2.3