From 61586b966e6879170191460157d54d4611de0c8b Mon Sep 17 00:00:00 2001 From: Jean-Yves Lamoureux Date: Thu, 13 Apr 2006 08:58:55 +0000 Subject: [PATCH] * Added silly play with interframe delay. Need to rework sprite format. --- test/spritedit.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/spritedit.c b/test/spritedit.c index 6ff1dce..a21d3ab 100644 --- a/test/spritedit.c +++ b/test/spritedit.c @@ -18,6 +18,8 @@ #include "cucul.h" #include "caca.h" +#define DELAY 100 + int main(int argc, char **argv) { cucul_t *qq; @@ -26,6 +28,8 @@ int main(int argc, char **argv) int quit = 0; struct cucul_sprite *sprite; int frame = 0; + unsigned char play = 0; + unsigned int delay = 0; if(argc < 2) { @@ -74,9 +78,28 @@ int main(int argc, char **argv) if(frame < cucul_get_sprite_frames(qq, sprite) - 1) frame++; break; + case 'p': + play=!play; + } } + if(play) { + if(!delay) { + if(frame < cucul_get_sprite_frames(qq, sprite) - 1) { + frame++; + } + else { + frame = 0; + } + } + delay++; + if(delay>=DELAY) { + delay = 0; + } + } + + cucul_clear(qq); cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);