summaryrefslogtreecommitdiff
path: root/PidginImage.c
diff options
context:
space:
mode:
authorVictor Gamper <victor@wenzeslaus.de>2020-01-26 19:45:20 +0100
committerVictor Gamper <victor@wenzeslaus.de>2020-01-26 19:45:20 +0100
commit4abb5e4664654591ba8beecf7774b69365c46d14 (patch)
treed43f81a540360cdc6b6fae8edbc1973038919012 /PidginImage.c
parentdac6b72f8f5fc9ecf564412927dcff7a04d37dc0 (diff)
downloadc-catch-4abb5e4664654591ba8beecf7774b69365c46d14.tar.gz
c-catch-4abb5e4664654591ba8beecf7774b69365c46d14.zip
Added a collision detection
Diffstat (limited to 'PidginImage.c')
-rw-r--r--PidginImage.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/PidginImage.c b/PidginImage.c
index 70dcb78..969fad0 100644
--- a/PidginImage.c
+++ b/PidginImage.c
@@ -7,7 +7,7 @@
#include "pidgin_image.h"
#include "catch.h"
-static int animation_index = 0, ax = 1;
+static int animation_index = 0, delay, ax = 1;
static SDL_Rect sdl_rect_output, sdl_rect_source;
static SDL_Surface* image_pidgin;
@@ -29,8 +29,13 @@ void draw_Pidgin(SDL_Surface* surface, int x, int y) {
}
void Pidgin_IncrementFrame() {
- animation_index+=ax;
- sdl_rect_source.y = animation_index * PIDGIN_HEIGHT;
- if(animation_index > 1) ax = -1;
- if(animation_index < 1) ax = 1;
+ delay++;
+ //printf("%d\n", delay);
+ if(delay >= 50) {
+ delay = 0;
+ animation_index+=ax;
+ sdl_rect_source.y = animation_index * PIDGIN_HEIGHT;
+ if(animation_index > 1) ax = -1;
+ if(animation_index < 1) ax = 1;
+ }
}