summaryrefslogtreecommitdiff
path: root/Week1-Pacman/src/pacman.c
diff options
context:
space:
mode:
Diffstat (limited to 'Week1-Pacman/src/pacman.c')
-rw-r--r--Week1-Pacman/src/pacman.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/Week1-Pacman/src/pacman.c b/Week1-Pacman/src/pacman.c
index c0a9644..f3a4769 100644
--- a/Week1-Pacman/src/pacman.c
+++ b/Week1-Pacman/src/pacman.c
@@ -2,8 +2,8 @@
#include <stdbool.h>
#include "pacman.h"
-#define PACMAN_SPEED 40
-#define PACMAN_SIDE 20
+#define PACMAN_SPEED 261
+#define PACMAN_SIDE 40
void handle_pacman_input(SDL_Event* e, struct pacman* pacman) {
@@ -23,7 +23,6 @@ void handle_pacman_input(SDL_Event* e, struct pacman* pacman) {
break;
}
}
-
}
void update_pacman(struct pacman* pacman, float dt) {
@@ -38,8 +37,19 @@ void update_pacman(struct pacman* pacman, float dt) {
pacman->xpos += PACMAN_SPEED * dt;
}
+ update_animation(&pacman->animations[pacman->facing], dt);
}
-void draw_pacman(SDL_Renderer* ren, const struct pacman* pacman) {
+void draw_pacman(struct demo* demo, const struct pacman* pacman) {
+ const struct animation* current_animation =
+ &pacman->animations[pacman->facing];
+
+ SDL_Rect d_rect = {
+ .x = pacman->xpos,
+ .y = pacman->ypos,
+ .w = PACMAN_SIDE,
+ .h = PACMAN_SIDE
+ };
+ draw_animation(demo, current_animation, &d_rect);
}