#include #include #include #include "demo.h" #include "pacman.h" #include "map.h" #include "collision.h" #include "resources.h" #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 const Uint8* keyboard; int main(int argc, char** argv) { (void)argc; (void)argv; SDL_Init(SDL_INIT_EVERYTHING); struct demo demo = {0}; demo.win = SDL_CreateWindow("Pacman", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); demo.ren = SDL_CreateRenderer(demo.win, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); load_resources(&demo); bool running = true; SDL_Event e; struct pacman pacman = {0}; struct map map = {0}; load_map("assets/Maps/maze.csv", &map); keyboard = SDL_GetKeyboardState(NULL); init_pacman(&pacman, &(struct pacman_init) { .initial_xpos = 100, .initial_ypos = 200, .initial_facing = FACING_DOWN }); int then = SDL_GetTicks(); while(running) { while(SDL_PollEvent(&e)) { if(e.type == SDL_QUIT) { running = false; } } int now = SDL_GetTicks(); float dt = (float)(now - then) / 1000; then = now; SDL_RenderClear(demo.ren); update_pacman(&pacman, dt, &map); update_demo(&demo); draw_map(&demo, &map); draw_pacman(&demo, &pacman); SDL_RenderPresent(demo.ren); } SDL_DestroyRenderer(demo.ren); SDL_DestroyWindow(demo.win); SDL_Quit(); return 0; }