From 2306fd875874b56830269187a7bff9badf8c6a02 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 9 Nov 2003 13:52:40 +0000 Subject: [PATCH] * libee/ee.c: + got rid of DELAY. * test/demo.c: + Minor animation effect. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@94 92316355-f0b4-4df1-b90c-862c8a59935f --- libee/ee.c | 15 +++++++++++---- libee/ee.h | 1 + test/demo.c | 11 +++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libee/ee.c b/libee/ee.c index 0706079..8ec6db2 100644 --- a/libee/ee.c +++ b/libee/ee.c @@ -30,6 +30,8 @@ #include "ee.h" +static int _ee_delay; + int ee_init(void) { #ifdef USE_SLANG @@ -93,10 +95,16 @@ int ee_init(void) /* Dummy driver */ #endif + _ee_delay = 0; return 0; } +void ee_set_delay(int delay) +{ + _ee_delay = delay; +} + int ee_get_width(void) { #ifdef USE_SLANG @@ -153,7 +161,6 @@ static int64_t local_time(void) return now; } -#define DELAY 40000 void ee_refresh(void) { static int64_t local_clock = 0; @@ -182,12 +189,12 @@ void ee_refresh(void) now = local_time(); - if(now < local_clock + DELAY - 10000) + if(now < local_clock + _ee_delay - 10000) { - usleep(local_clock + DELAY - 10000 - now); + usleep(local_clock + _ee_delay - 10000 - now); } - local_clock += DELAY; + local_clock += _ee_delay; } void ee_end(void) diff --git a/libee/ee.h b/libee/ee.h index 37d1ad3..25cbbee 100644 --- a/libee/ee.h +++ b/libee/ee.h @@ -64,6 +64,7 @@ * Prototypes */ int ee_init(void); +void ee_set_delay(int); int ee_get_width(void); int ee_get_height(void); void ee_clear(void); diff --git a/test/demo.c b/test/demo.c index 2db4afd..1e51f0c 100644 --- a/test/demo.c +++ b/test/demo.c @@ -34,6 +34,7 @@ int main(int argc, char **argv) /* Go ! */ while(!quit) { + int i; char key = ee_get_key(); if(key) { @@ -41,8 +42,14 @@ int main(int argc, char **argv) } ee_clear(); - ee_goto(12,14); - ee_putchar('#'); + for(i=1000; i--;) + { + ee_goto(ee_rand(0,ee_get_width()-1), + ee_rand(0,ee_get_height()-1)); + ee_color(ee_rand(1,10)); + ee_putchar('#'); + } + ee_refresh(); }