#include #include #include "pacman.h" #define PACMAN_SPEED 40 void handle_pacman_input(SDL_Event* e, struct pacman* pacman) { if(e->type == SDL_KEYDOWN) { switch(e->key.keysym.sym) { case SDLK_UP: pacman->facing = FACING_UP; break; case SDLK_DOWN: pacman->facing = FACING_DOWN; break; case SDLK_LEFT: pacman->facing = FACING_LEFT; break; case SDLK_RIGHT: pacman->facing = FACING_RIGHT; break; } } } void update_pacman(struct pacman* pacman, float dt) { if(pacman->facing == FACING_UP) { pacman->ypos -= PACMAN_SPEED * dt; } else if(pacman->facing == FACING_DOWN) { pacman->ypos += PACMAN_SPEED * dt; } else if(pacman->facing == FACING_LEFT) { pacman->xpos -= PACMAN_SPEED * dt; } else { pacman->xpos += PACMAN_SPEED * dt; } } void draw_pacman(SDL_Renderer* ren, const struct pacman* pacman) { }