summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Anthony <johnanthony@lavabit.com>2012-07-31 15:25:06 +0100
committerJohn Anthony <johnanthony@lavabit.com>2012-07-31 15:25:06 +0100
commitbb95a386359537567032143b02b819bcf42c44e6 (patch)
tree12579c1bb277ac9f5c96e9e9fadf40b6e11dbe3c
parent764dfb3a777fb5add167c165bcfc72b315c203bd (diff)
downloadnyancat-bb95a386359537567032143b02b819bcf42c44e6.tar.gz
nyancat-bb95a386359537567032143b02b819bcf42c44e6.tar.bz2
nyancat-bb95a386359537567032143b02b819bcf42c44e6.zip
Fixed some magic numbers that prevented the number of animation frames being adjusted properly
-rw-r--r--nyan.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/nyan.c b/nyan.c
index 794e7ef..287cdab 100644
--- a/nyan.c
+++ b/nyan.c
@@ -103,7 +103,7 @@ add_sparkle(void) {
new->loc.x = screen->w + 80;
new->loc.y = (rand() % (screen->h + sparkle_img[0]->h)) - sparkle_img[0]->h;
- new->frame = rand() % 4;
+ new->frame = 0;
new->frame_mov = 1;
new->speed = 10 + (rand() % 30);
new->layer = rand() % 2;
@@ -469,7 +469,7 @@ run(void) {
/* Frame increment and looping */
curr_frame++;
- if (curr_frame > 4)
+ if (curr_frame >= ANIM_FRAMES)
curr_frame = 0;
draw_time = SDL_GetTicks() - last_draw;
@@ -505,7 +505,7 @@ stretch_images(void) {
stretchto.h = stretchto.w * cat_img[0]->h / cat_img[0]->w;
SDL_PixelFormat fmt = *(cat_img[0]->format);
- for(int i=0; i<=4; i++) {
+ for(int i=0; i <= ANIM_FRAMES; i++) {
stretch_cat[i] = SDL_CreateRGBSurface(SURF_TYPE, stretchto.w,
stretchto.h,SCREEN_BPP,fmt.Rmask,fmt.Gmask,fmt.Bmask,fmt.Amask);
SDL_SoftStretch(cat_img[i],NULL,stretch_cat[i],NULL);
@@ -529,7 +529,7 @@ update_sparkles(void) {
s->frame += s->frame_mov;
- if(s->frame > 3 || s->frame < 1)
+ if(s->frame >= ANIM_FRAMES || s->frame < 1)
s->frame_mov = 0 - s->frame_mov;
if (s->loc.x < 0 - sparkle_img[0]->w)