- Timestamp:
- Nov 16, 2003, 1:33:35 AM (19 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 31 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/Makefile.am
r159 r185 3 3 ############################################################################### 4 4 5 SUBDIRS = lib eetest src5 SUBDIRS = libcaca test src 6 6 DIST_SUBDIRS = $(SUBDIRS) autotools data debian 7 7 -
libcaca/trunk/TODO
r159 r185 1 1 $Id$ 2 2 3 TODO for lib ee3 TODO for libcaca 4 4 5 5 o Sprite library -
libcaca/trunk/configure.ac
r157 r185 61 61 AC_OUTPUT([ 62 62 Makefile 63 lib ee/Makefile63 libcaca/Makefile 64 64 test/Makefile 65 65 src/Makefile -
libcaca/trunk/libcaca/Makefile.am
r183 r185 1 1 ############################################################################### 2 # Automake targets and declarations for lib ee2 # Automake targets and declarations for libcaca 3 3 ############################################################################### 4 4 5 lib_LIBRARIES = lib ee.a6 lib ee_a_SOURCES = \7 ee.c \8 ee.h \9 ee_internals.h \5 lib_LIBRARIES = libcaca.a 6 libcaca_a_SOURCES = \ 7 caca.c \ 8 caca.h \ 9 caca_internals.h \ 10 10 graphics.c \ 11 11 io.c \ -
libcaca/trunk/libcaca/blit.c
r183 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 31 31 #include <stdlib.h> 32 32 33 #include " ee.h"34 #include " ee_internals.h"33 #include "caca.h" 34 #include "caca_internals.h" 35 35 36 36 #include <stdio.h> 37 void ee_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h)37 void caca_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h) 38 38 { 39 39 char foo[] = { ' ', '.', ':', ';', '=', '$', '%', '@', '#', '8', 'W' }; … … 52 52 pitch = (3 * w + 3) / 4 * 4; 53 53 54 for(y = y1 > 0 ? y1 : 0; y <= y2 && y <= ee_get_height(); y++)55 for(x = x1 > 0 ? x1 : 0; x <= x2 && x <= ee_get_width(); x++)54 for(y = y1 > 0 ? y1 : 0; y <= y2 && y <= caca_get_height(); y++) 55 for(x = x1 > 0 ? x1 : 0; x <= x2 && x <= caca_get_width(); x++) 56 56 { 57 57 int fromx = w * (x - x1) / (x2 - x1 + 1); … … 63 63 if(r == g && g == b) 64 64 { 65 ee_set_color(EE_LIGHTGRAY);65 caca_set_color(EE_LIGHTGRAY); 66 66 } 67 67 else … … 89 89 hue += 360; 90 90 91 ee_set_color(foo_colors[(int)(hue + 30) / 60]);91 caca_set_color(foo_colors[(int)(hue + 30) / 60]); 92 92 } 93 93 else 94 94 { 95 ee_set_color(EE_LIGHTGRAY);95 caca_set_color(EE_LIGHTGRAY); 96 96 } 97 97 } 98 98 99 ee_putchar(x, y, foo[(r + g + b) / 3 / 25]);99 caca_putchar(x, y, foo[(r + g + b) / 3 / 25]); 100 100 } 101 101 } -
libcaca/trunk/libcaca/box.c
r159 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 25 25 #include <stdlib.h> 26 26 27 #include " ee.h"28 #include " ee_internals.h"27 #include "caca.h" 28 #include "caca_internals.h" 29 29 30 void ee_draw_box(int x1, int y1, int x2, int y2, char c)30 void caca_draw_box(int x1, int y1, int x2, int y2, char c) 31 31 { 32 ee_draw_line(x1, y1, x1, y2, c);33 ee_draw_line(x1, y2, x2, y2, c);34 ee_draw_line(x2, y2, x2, y1, c);35 ee_draw_line(x2, y1, x1, y1, c);32 caca_draw_line(x1, y1, x1, y2, c); 33 caca_draw_line(x1, y2, x2, y2, c); 34 caca_draw_line(x2, y2, x2, y1, c); 35 caca_draw_line(x2, y1, x1, y1, c); 36 36 } 37 37 38 void ee_draw_thin_box(int x1, int y1, int x2, int y2)38 void caca_draw_thin_box(int x1, int y1, int x2, int y2) 39 39 { 40 40 int x, y, xmax, ymax; … … 52 52 } 53 53 54 xmax = ee_get_width() - 1;55 ymax = ee_get_height() - 1;54 xmax = caca_get_width() - 1; 55 ymax = caca_get_height() - 1; 56 56 57 57 if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax) … … 61 61 if(y1 >= 0) 62 62 for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) 63 ee_putchar(x, y1, '-');63 caca_putchar(x, y1, '-'); 64 64 65 65 if(y2 <= ymax) 66 66 for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) 67 ee_putchar(x, y2, '-');67 caca_putchar(x, y2, '-'); 68 68 69 69 if(x1 >= 0) 70 70 for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) 71 ee_putchar(x1, y, '|');71 caca_putchar(x1, y, '|'); 72 72 73 73 if(x2 <= xmax) 74 74 for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) 75 ee_putchar(x2, y, '|');75 caca_putchar(x2, y, '|'); 76 76 77 77 /* Draw corners */ 78 78 if(x1 >= 0 && y1 >= 0) 79 ee_putchar(x1, y1, ',');79 caca_putchar(x1, y1, ','); 80 80 81 81 if(x1 >= 0 && y2 <= ymax) 82 ee_putchar(x1, y2, '`');82 caca_putchar(x1, y2, '`'); 83 83 84 84 if(x2 <= xmax && y1 >= 0) 85 ee_putchar(x2, y1, '.');85 caca_putchar(x2, y1, '.'); 86 86 87 87 if(x2 <= xmax && y2 <= ymax) 88 ee_putchar(x2, y2, '\'');88 caca_putchar(x2, y2, '\''); 89 89 } 90 90 91 void ee_fill_box(int x1, int y1, int x2, int y2, char c)91 void caca_fill_box(int x1, int y1, int x2, int y2, char c) 92 92 { 93 93 int x, y, xmax, ymax; … … 105 105 } 106 106 107 xmax = ee_get_width() - 1;108 ymax = ee_get_height() - 1;107 xmax = caca_get_width() - 1; 108 ymax = caca_get_height() - 1; 109 109 110 110 if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax) … … 118 118 for(y = y1; y <= y2; y++) 119 119 for(x = x1; x <= x2; x++) 120 ee_putchar(x, y, c);120 caca_putchar(x, y, c); 121 121 } 122 122 -
libcaca/trunk/libcaca/caca.c
r184 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 43 43 #include <time.h> 44 44 45 #include " ee.h"46 #include " ee_internals.h"47 48 static unsigned int _ ee_delay;49 static unsigned int _ ee_rendertime;50 char *_ ee_empty_line;51 char *_ ee_scratch_line;45 #include "caca.h" 46 #include "caca_internals.h" 47 48 static unsigned int _caca_delay; 49 static unsigned int _caca_rendertime; 50 char *_caca_empty_line; 51 char *_caca_scratch_line; 52 52 53 53 #if defined(USE_NCURSES) 54 int _ ee_attr[16];54 int _caca_attr[16]; 55 55 #endif 56 56 57 57 #if defined(USE_CONIO) 58 58 static struct text_info ti; 59 char *_ ee_screen;60 #endif 61 62 int ee_init(void)59 char *_caca_screen; 60 #endif 61 62 int caca_init(void) 63 63 { 64 64 #if defined(USE_SLANG) … … 144 144 for(i = 0; i < 8; i++) 145 145 { 146 _ ee_attr[i] = COLOR_PAIR(1 + i);147 _ ee_attr[i + 8] = A_BOLD | COLOR_PAIR(1 + i);146 _caca_attr[i] = COLOR_PAIR(1 + i); 147 _caca_attr[i + 8] = A_BOLD | COLOR_PAIR(1 + i); 148 148 } 149 149 150 150 #elif defined(USE_CONIO) 151 151 gettextinfo(&ti); 152 _ ee_screen = malloc(2 * ti.screenwidth * ti.screenheight);153 if(_ ee_screen == NULL)152 _caca_screen = malloc(2 * ti.screenwidth * ti.screenheight); 153 if(_caca_screen == NULL) 154 154 return -1; 155 155 _wscroll = 0; … … 157 157 clrscr(); 158 158 # if defined(SCREENUPDATE_IN_PC_H) 159 ScreenRetrieve(_ ee_screen);159 ScreenRetrieve(_caca_screen); 160 160 # else 161 161 /* FIXME */ … … 163 163 164 164 #endif 165 _ ee_empty_line = malloc(ee_get_width() + 1);166 memset(_ ee_empty_line, ' ', ee_get_width());167 _ ee_empty_line[ee_get_width()] = '\0';168 169 _ ee_scratch_line = malloc(ee_get_width() + 1);170 171 _ ee_delay = 0;172 _ ee_rendertime = 0;165 _caca_empty_line = malloc(caca_get_width() + 1); 166 memset(_caca_empty_line, ' ', caca_get_width()); 167 _caca_empty_line[caca_get_width()] = '\0'; 168 169 _caca_scratch_line = malloc(caca_get_width() + 1); 170 171 _caca_delay = 0; 172 _caca_rendertime = 0; 173 173 174 174 return 0; 175 175 } 176 176 177 unsigned int ee_get_width(void)177 unsigned int caca_get_width(void) 178 178 { 179 179 #if defined(USE_SLANG) … … 186 186 } 187 187 188 unsigned int ee_get_height(void)188 unsigned int caca_get_height(void) 189 189 { 190 190 #if defined(USE_SLANG) … … 197 197 } 198 198 199 void ee_set_delay(unsigned int usec)200 { 201 _ ee_delay = usec;202 } 203 204 unsigned int ee_get_rendertime(void)205 { 206 return _ ee_rendertime;207 } 208 209 const char * ee_get_color_name(unsigned int color)199 void caca_set_delay(unsigned int usec) 200 { 201 _caca_delay = usec; 202 } 203 204 unsigned int caca_get_rendertime(void) 205 { 206 return _caca_rendertime; 207 } 208 209 const char *caca_get_color_name(unsigned int color) 210 210 { 211 211 static const char *color_names[16] = … … 235 235 } 236 236 237 static unsigned int _ ee_getticks(void)237 static unsigned int _caca_getticks(void) 238 238 { 239 239 static unsigned int last_sec = 0, last_usec = 0; … … 255 255 } 256 256 257 void ee_refresh(void)257 void caca_refresh(void) 258 258 { 259 259 #define IDLE_USEC 10000 260 260 static unsigned int lastticks = 0; 261 unsigned int ticks = lastticks + _ ee_getticks();261 unsigned int ticks = lastticks + _caca_getticks(); 262 262 263 263 #if defined(USE_SLANG) … … 267 267 #elif defined(USE_CONIO) 268 268 # if defined(SCREENUPDATE_IN_PC_H) 269 ScreenUpdate(_ ee_screen);269 ScreenUpdate(_caca_screen); 270 270 # else 271 271 /* FIXME */ … … 273 273 #endif 274 274 275 /* Wait until _ ee_delay + time of last call */276 ticks += _ ee_getticks();277 for(; ticks < _ ee_delay - IDLE_USEC; ticks += _ee_getticks())275 /* Wait until _caca_delay + time of last call */ 276 ticks += _caca_getticks(); 277 for(; ticks < _caca_delay - IDLE_USEC; ticks += _caca_getticks()) 278 278 usleep(IDLE_USEC); 279 279 280 280 /* Update the sliding mean of the render time */ 281 _ ee_rendertime = (7 * _ee_rendertime + ticks) / 8;282 283 lastticks = ticks - _ ee_delay;281 _caca_rendertime = (7 * _caca_rendertime + ticks) / 8; 282 283 lastticks = ticks - _caca_delay; 284 284 285 285 /* If we drifted too much, it's bad, bad, bad. */ 286 if(lastticks > _ ee_delay)286 if(lastticks > _caca_delay) 287 287 lastticks = 0; 288 288 } 289 289 290 void ee_end(void)290 void caca_end(void) 291 291 { 292 292 #if defined(USE_SLANG) … … 301 301 textcolor((enum COLORS)WHITE); 302 302 textbackground((enum COLORS)BLACK); 303 gotoxy( ee_get_width(), ee_get_height());303 gotoxy(caca_get_width(), caca_get_height()); 304 304 cputs("\r\n"); 305 305 _setcursortype(_NORMALCURSOR); -
libcaca/trunk/libcaca/caca.h
r184 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 32 32 * Colors 33 33 */ 34 enum ee_colors34 enum caca_colors 35 35 { 36 36 EE_BLACK = 0, … … 55 55 * Types 56 56 */ 57 struct ee_sprite;57 struct caca_sprite; 58 58 59 59 /* 60 60 * Prototypes 61 61 */ 62 int ee_init(void);63 void ee_set_delay(unsigned int);64 unsigned int ee_get_rendertime(void);65 unsigned int ee_get_width(void);66 unsigned int ee_get_height(void);67 const char * ee_get_color_name(unsigned int);68 void ee_refresh(void);69 void ee_end(void);62 int caca_init(void); 63 void caca_set_delay(unsigned int); 64 unsigned int caca_get_rendertime(void); 65 unsigned int caca_get_width(void); 66 unsigned int caca_get_height(void); 67 const char *caca_get_color_name(unsigned int); 68 void caca_refresh(void); 69 void caca_end(void); 70 70 71 char ee_get_key(void);71 char caca_get_key(void); 72 72 73 void ee_set_color(int);74 int ee_get_color(void);75 void ee_putchar(int, int, char);76 void ee_putstr(int, int, const char *);77 void ee_printf(int, int, const char *, ...);78 void ee_clear(void);73 void caca_set_color(int); 74 int caca_get_color(void); 75 void caca_putchar(int, int, char); 76 void caca_putstr(int, int, const char *); 77 void caca_printf(int, int, const char *, ...); 78 void caca_clear(void); 79 79 80 void ee_draw_line(int, int, int, int, char);81 void ee_draw_polyline(const int[], const int[], int, char);82 void ee_draw_thin_line(int, int, int, int);83 void ee_draw_thin_polyline(const int[], const int[], int);80 void caca_draw_line(int, int, int, int, char); 81 void caca_draw_polyline(const int[], const int[], int, char); 82 void caca_draw_thin_line(int, int, int, int); 83 void caca_draw_thin_polyline(const int[], const int[], int); 84 84 85 void ee_draw_circle(int, int, int, char);86 void ee_draw_ellipse(int, int, int, int, char);87 void ee_draw_thin_ellipse(int, int, int, int);88 void ee_fill_ellipse(int, int, int, int, char);85 void caca_draw_circle(int, int, int, char); 86 void caca_draw_ellipse(int, int, int, int, char); 87 void caca_draw_thin_ellipse(int, int, int, int); 88 void caca_fill_ellipse(int, int, int, int, char); 89 89 90 void ee_draw_box(int, int, int, int, char);91 void ee_draw_thin_box(int, int, int, int);92 void ee_fill_box(int, int, int, int, char);90 void caca_draw_box(int, int, int, int, char); 91 void caca_draw_thin_box(int, int, int, int); 92 void caca_fill_box(int, int, int, int, char); 93 93 94 void ee_draw_triangle(int, int, int, int, int, int, char);95 void ee_draw_thin_triangle(int, int, int, int, int, int);96 void ee_fill_triangle(int, int, int, int, int, int, char);94 void caca_draw_triangle(int, int, int, int, int, int, char); 95 void caca_draw_thin_triangle(int, int, int, int, int, int); 96 void caca_fill_triangle(int, int, int, int, int, int, char); 97 97 98 int ee_rand(int, int);99 unsigned int ee_sqrt(unsigned int);98 int caca_rand(int, int); 99 unsigned int caca_sqrt(unsigned int); 100 100 101 struct ee_sprite * ee_load_sprite(const char *);102 int ee_get_sprite_frames(struct ee_sprite *);103 int ee_get_sprite_width(struct ee_sprite *, int);104 int ee_get_sprite_height(struct ee_sprite *, int);105 int ee_get_sprite_dx(struct ee_sprite *, int);106 int ee_get_sprite_dy(struct ee_sprite *, int);107 void ee_draw_sprite(int, int, struct ee_sprite *, int);108 void ee_free_sprite(struct ee_sprite *);101 struct caca_sprite * caca_load_sprite(const char *); 102 int caca_get_sprite_frames(struct caca_sprite *); 103 int caca_get_sprite_width(struct caca_sprite *, int); 104 int caca_get_sprite_height(struct caca_sprite *, int); 105 int caca_get_sprite_dx(struct caca_sprite *, int); 106 int caca_get_sprite_dy(struct caca_sprite *, int); 107 void caca_draw_sprite(int, int, struct caca_sprite *, int); 108 void caca_free_sprite(struct caca_sprite *); 109 109 110 void ee_blit(int, int, int, int, void *, int, int);110 void caca_blit(int, int, int, int, void *, int, int); 111 111 112 112 #ifdef __cplusplus -
libcaca/trunk/libcaca/caca_internals.h
r184 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 25 25 26 26 #if defined(USE_NCURSES) 27 extern int _ ee_attr[];27 extern int _caca_attr[]; 28 28 #endif 29 29 30 30 #if defined(USE_CONIO) 31 extern char *_ ee_screen;31 extern char *_caca_screen; 32 32 #endif 33 33 34 extern char *_ ee_empty_line;35 extern char *_ ee_scratch_line;34 extern char *_caca_empty_line; 35 extern char *_caca_scratch_line; 36 36 37 37 #endif /* __EE_INTERNALS_H__ */ -
libcaca/trunk/libcaca/conic.c
r165 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 31 31 #include <stdlib.h> 32 32 33 #include " ee.h"34 #include " ee_internals.h"33 #include "caca.h" 34 #include "caca_internals.h" 35 35 36 36 static void ellipsepoints(int, int, int, int, char); 37 37 38 void ee_draw_circle(int x, int y, int r, char c)38 void caca_draw_circle(int x, int y, int r, char c) 39 39 { 40 40 int test, dx, dy; … … 50 50 } 51 51 52 void ee_fill_ellipse(int xo, int yo, int a, int b, char c)52 void caca_fill_ellipse(int xo, int yo, int a, int b, char c) 53 53 { 54 54 int d2; … … 66 66 { 67 67 d1 += b*b*(2*x*1) + a*a*(-2*y+2); 68 ee_draw_line(xo - x, yo - y, xo + x, yo - y, c);69 ee_draw_line(xo - x, yo + y, xo + x, yo + y, c);68 caca_draw_line(xo - x, yo - y, xo + x, yo - y, c); 69 caca_draw_line(xo - x, yo + y, xo + x, yo + y, c); 70 70 y--; 71 71 } … … 73 73 } 74 74 75 ee_draw_line(xo - x, yo - y, xo + x, yo - y, c);76 ee_draw_line(xo - x, yo + y, xo + x, yo + y, c);75 caca_draw_line(xo - x, yo - y, xo + x, yo - y, c); 76 caca_draw_line(xo - x, yo + y, xo + x, yo + y, c); 77 77 78 78 d2 = b*b*(x+0.5)*(x+0.5) + a*a*(y-1)*(y-1) - a*a*b*b; … … 90 90 91 91 y--; 92 ee_draw_line(xo - x, yo - y, xo + x, yo - y, c);93 ee_draw_line(xo - x, yo + y, xo + x, yo + y, c);94 } 95 } 96 97 void ee_draw_ellipse(int xo, int yo, int a, int b, char c)92 caca_draw_line(xo - x, yo - y, xo + x, yo - y, c); 93 caca_draw_line(xo - x, yo + y, xo + x, yo + y, c); 94 } 95 } 96 97 void caca_draw_ellipse(int xo, int yo, int a, int b, char c) 98 98 { 99 99 int d2; … … 137 137 } 138 138 139 void ee_draw_thin_ellipse(int xo, int yo, int a, int b)139 void caca_draw_thin_ellipse(int xo, int yo, int a, int b) 140 140 { 141 141 /* FIXME: this is not correct */ … … 184 184 uint8_t b = 0; 185 185 186 if(xo + x >= 0 && xo + x < ee_get_width())186 if(xo + x >= 0 && xo + x < caca_get_width()) 187 187 b |= 0x1; 188 if(xo - x >= 0 && xo - x < ee_get_width())188 if(xo - x >= 0 && xo - x < caca_get_width()) 189 189 b |= 0x2; 190 if(yo + y >= 0 && yo + y < ee_get_height())190 if(yo + y >= 0 && yo + y < caca_get_height()) 191 191 b |= 0x4; 192 if(yo - y >= 0 && yo - y < ee_get_height())192 if(yo - y >= 0 && yo - y < caca_get_height()) 193 193 b |= 0x8; 194 194 195 195 if((b & (0x1|0x4)) == (0x1|0x4)) 196 ee_putchar(xo + x, yo + y, c);196 caca_putchar(xo + x, yo + y, c); 197 197 198 198 if((b & (0x2|0x4)) == (0x2|0x4)) 199 ee_putchar(xo - x, yo + y, c);199 caca_putchar(xo - x, yo + y, c); 200 200 201 201 if((b & (0x1|0x8)) == (0x1|0x8)) 202 ee_putchar(xo + x, yo - y, c);202 caca_putchar(xo + x, yo - y, c); 203 203 204 204 if((b & (0x2|0x8)) == (0x2|0x8)) 205 ee_putchar(xo - x, yo - y, c);206 } 207 205 caca_putchar(xo - x, yo - y, c); 206 } 207 -
libcaca/trunk/libcaca/graphics.c
r181 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 37 37 #include <stdarg.h> 38 38 39 #include " ee.h"40 #include " ee_internals.h"39 #include "caca.h" 40 #include "caca_internals.h" 41 41 42 static int _ ee_color = 0;42 static int _caca_color = 0; 43 43 44 void ee_set_color(int color)44 void caca_set_color(int color) 45 45 { 46 46 if(color < 0 || color > 15) 47 47 return; 48 48 49 _ ee_color = color;49 _caca_color = color; 50 50 #if defined(USE_SLANG) 51 51 SLsmg_set_color(color + 1); 52 52 #elif defined(USE_NCURSES) 53 attrset(_ ee_attr[color]);53 attrset(_caca_attr[color]); 54 54 #elif defined(USE_CONIO) 55 55 textcolor(color); … … 57 57 } 58 58 59 int ee_get_color(void)59 int caca_get_color(void) 60 60 { 61 return _ ee_color;61 return _caca_color; 62 62 } 63 63 64 void ee_putchar(int x, int y, char c)64 void caca_putchar(int x, int y, char c) 65 65 { 66 if(x < 0 || x >= ee_get_width() || y < 0 || y >= ee_get_height())66 if(x < 0 || x >= caca_get_width() || y < 0 || y >= caca_get_height()) 67 67 return; 68 68 … … 74 74 addch(c); 75 75 #elif defined(USE_CONIO) 76 _ ee_screen[2 * (x + y * ee_get_width())] = c;77 _ ee_screen[2 * (x + y * ee_get_width()) + 1] = _ee_color;76 _caca_screen[2 * (x + y * caca_get_width())] = c; 77 _caca_screen[2 * (x + y * caca_get_width()) + 1] = _caca_color; 78 78 // gotoxy(x + 1, y + 1); 79 79 // putch(c); … … 81 81 } 82 82 83 void ee_putstr(int x, int y, const char *s)83 void caca_putstr(int x, int y, const char *s) 84 84 { 85 85 int len; 86 86 87 if(y < 0 || y >= ee_get_height() || x >= ee_get_width())87 if(y < 0 || y >= caca_get_height() || x >= caca_get_width()) 88 88 return; 89 89 … … 99 99 } 100 100 101 if(x + len >= ee_get_width())101 if(x + len >= caca_get_width()) 102 102 { 103 memcpy(_ ee_scratch_line, s, ee_get_width() - x);104 _ ee_scratch_line[ee_get_width() - x] = '\0';105 s = _ ee_scratch_line;103 memcpy(_caca_scratch_line, s, caca_get_width() - x); 104 _caca_scratch_line[caca_get_width() - x] = '\0'; 105 s = _caca_scratch_line; 106 106 } 107 107 … … 113 113 addstr(s); 114 114 #elif defined(USE_CONIO) 115 char *buf = _ ee_screen + 2 * (x + y * ee_get_width());115 char *buf = _caca_screen + 2 * (x + y * caca_get_width()); 116 116 while(*s) 117 117 { 118 118 *buf++ = *s++; 119 *buf++ = _ ee_color;119 *buf++ = _caca_color; 120 120 } 121 121 // gotoxy(x + 1, y + 1); … … 124 124 } 125 125 126 void ee_printf(int x, int y, const char *format, ...)126 void caca_printf(int x, int y, const char *format, ...) 127 127 { 128 128 char tmp[BUFSIZ]; … … 130 130 va_list args; 131 131 132 if(y < 0 || y >= ee_get_height() || x >= ee_get_width())132 if(y < 0 || y >= caca_get_height() || x >= caca_get_width()) 133 133 return; 134 134 135 if( ee_get_width() - x + 1 > BUFSIZ)136 buf = malloc( ee_get_width() - x + 1);135 if(caca_get_width() - x + 1 > BUFSIZ) 136 buf = malloc(caca_get_width() - x + 1); 137 137 138 138 va_start(args, format); 139 vsnprintf(buf, ee_get_width() - x + 1, format, args);140 buf[ ee_get_width() - x] = '\0';139 vsnprintf(buf, caca_get_width() - x + 1, format, args); 140 buf[caca_get_width() - x] = '\0'; 141 141 va_end(args); 142 142 143 ee_putstr(x, y, buf);143 caca_putstr(x, y, buf); 144 144 145 145 if(buf != tmp) … … 147 147 } 148 148 149 void ee_clear(void)149 void caca_clear(void) 150 150 { 151 151 /* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ 152 int y = ee_get_height();152 int y = caca_get_height(); 153 153 154 154 while(y--) 155 ee_putstr(0, y, _ee_empty_line);155 caca_putstr(0, y, _caca_empty_line); 156 156 } 157 157 -
libcaca/trunk/libcaca/io.c
r159 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 33 33 #endif 34 34 35 #include " ee.h"36 #include " ee_internals.h"35 #include "caca.h" 36 #include "caca_internals.h" 37 37 38 char ee_get_key(void)38 char caca_get_key(void) 39 39 { 40 40 #if defined(USE_SLANG) -
libcaca/trunk/libcaca/line.c
r179 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 31 31 #include <stdlib.h> 32 32 33 #include " ee.h"34 #include " ee_internals.h"33 #include "caca.h" 34 #include "caca_internals.h" 35 35 36 36 struct line … … 57 57 * \return nothing 58 58 */ 59 void ee_draw_line(int x1, int y1, int x2, int y2, char c)59 void caca_draw_line(int x1, int y1, int x2, int y2, char c) 60 60 { 61 61 struct line s; … … 69 69 } 70 70 71 void ee_draw_polyline(const int x[], const int y[], int n, char c)71 void caca_draw_polyline(const int x[], const int y[], int n, char c) 72 72 { 73 73 int i; … … 95 95 * \return nothing 96 96 */ 97 void ee_draw_thin_line(int x1, int y1, int x2, int y2)97 void caca_draw_thin_line(int x1, int y1, int x2, int y2) 98 98 { 99 99 struct line s; … … 106 106 } 107 107 108 void ee_draw_thin_polyline(const int x[], const int y[], int n)108 void caca_draw_thin_polyline(const int x[], const int y[], int n) 109 109 { 110 110 int i; … … 164 164 else if(bits1 & (1<<1)) 165 165 { 166 int xmax = ee_get_width() - 1;166 int xmax = caca_get_width() - 1; 167 167 s->y1 = s->y2 - (s->x2 - xmax) * (s->y2 - s->y1) / (s->x2 - s->x1); 168 168 s->x1 = xmax; … … 175 175 else if(bits1 & (1<<3)) 176 176 { 177 int ymax = ee_get_height() - 1;177 int ymax = caca_get_height() - 1; 178 178 s->x1 = s->x2 - (s->y2 - ymax) * (s->x2 - s->x1) / (s->y2 - s->y1); 179 179 s->y1 = ymax; … … 196 196 if(x < 0) 197 197 b |= (1<<0); 198 else if(x >= ee_get_width())198 else if(x >= caca_get_width()) 199 199 b |= (1<<1); 200 200 201 201 if(y < 0) 202 202 b |= (1<<2); 203 else if(y >= ee_get_height())203 else if(y >= caca_get_height()) 204 204 b |= (1<<3); 205 205 … … 236 236 for(; dx>=0; dx--) 237 237 { 238 ee_putchar(x1, y1, s->c);238 caca_putchar(x1, y1, s->c); 239 239 if(delta > 0) 240 240 { … … 258 258 for(; dy >= 0; dy--) 259 259 { 260 ee_putchar(x1, y1, s->c);260 caca_putchar(x1, y1, s->c); 261 261 if(delta > 0) 262 262 { … … 330 330 if(delta > 0) 331 331 { 332 ee_putchar(x1, y1, charmapy[1]);332 caca_putchar(x1, y1, charmapy[1]); 333 333 x1++; 334 334 y1 += yinc; … … 339 339 { 340 340 if(prev) 341 ee_putchar(x1, y1, charmapy[0]);341 caca_putchar(x1, y1, charmapy[0]); 342 342 else 343 ee_putchar(x1, y1, '-');343 caca_putchar(x1, y1, '-'); 344 344 x1++; 345 345 delta += dpr; … … 358 358 if(delta > 0) 359 359 { 360 ee_putchar(x1, y1, charmapx[0]);361 ee_putchar(x1 + 1, y1, charmapx[1]);360 caca_putchar(x1, y1, charmapx[0]); 361 caca_putchar(x1 + 1, y1, charmapx[1]); 362 362 x1++; 363 363 y1 += yinc; … … 366 366 else 367 367 { 368 ee_putchar(x1, y1, '|');368 caca_putchar(x1, y1, '|'); 369 369 y1 += yinc; 370 370 delta += dpr; -
libcaca/trunk/libcaca/math.c
r171 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 25 25 #include <stdlib.h> 26 26 27 #include " ee.h"28 #include " ee_internals.h"27 #include "caca.h" 28 #include "caca_internals.h" 29 29 30 int ee_rand(int min, int max)30 int caca_rand(int min, int max) 31 31 { 32 32 return min + (int)((1.0*(max-min+1)) * rand() / (RAND_MAX+1.0)); 33 33 } 34 34 35 unsigned int ee_sqrt(unsigned int a)35 unsigned int caca_sqrt(unsigned int a) 36 36 { 37 37 if(a == 0) … … 55 55 } 56 56 57 return 2 * ee_sqrt(a / 4);57 return 2 * caca_sqrt(a / 4); 58 58 } 59 59 -
libcaca/trunk/libcaca/sprite.c
r167 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 27 27 #include <string.h> 28 28 29 #include " ee.h"30 #include " ee_internals.h"31 32 struct ee_frame29 #include "caca.h" 30 #include "caca_internals.h" 31 32 struct caca_frame 33 33 { 34 34 int w, h; … … 38 38 }; 39 39 40 struct ee_sprite40 struct caca_sprite 41 41 { 42 42 int nf; 43 struct ee_frame *frames;43 struct caca_frame *frames; 44 44 }; 45 45 46 struct ee_sprite *ee_load_sprite(const char *file)46 struct caca_sprite *caca_load_sprite(const char *file) 47 47 { 48 48 char buf[BUFSIZ]; 49 struct ee_sprite *sprite;49 struct caca_sprite *sprite; 50 50 FILE *fd; 51 51 … … 54 54 return NULL; 55 55 56 sprite = malloc(sizeof(struct ee_sprite));56 sprite = malloc(sizeof(struct caca_sprite)); 57 57 if(sprite == NULL) 58 58 goto sprite_alloc_failed; … … 65 65 int x, y; 66 66 int w = 0, h = 0, dx = 0, dy = 0; 67 struct ee_frame *frame;67 struct caca_frame *frame; 68 68 69 69 /* Get width and height */ … … 78 78 { 79 79 void *tmp = realloc(sprite->frames, 80 (sprite->nf + 1) * sizeof(struct ee_frame));80 (sprite->nf + 1) * sizeof(struct caca_frame)); 81 81 if(tmp == NULL) 82 82 goto frame_failed; … … 86 86 else 87 87 { 88 sprite->frames = malloc((sprite->nf + 1) * sizeof(struct ee_frame));88 sprite->frames = malloc((sprite->nf + 1) * sizeof(struct caca_frame)); 89 89 if(sprite->frames == NULL) 90 90 goto sprite_failed; … … 159 159 } 160 160 161 int ee_get_sprite_frames(struct ee_sprite *sprite)161 int caca_get_sprite_frames(struct caca_sprite *sprite) 162 162 { 163 163 if(sprite == NULL) … … 167 167 } 168 168 169 int ee_get_sprite_width(struct ee_sprite *sprite, int f)169 int caca_get_sprite_width(struct caca_sprite *sprite, int f) 170 170 { 171 171 if(sprite == NULL) … … 178 178 } 179 179 180 int ee_get_sprite_height(struct ee_sprite *sprite, int f)180 int caca_get_sprite_height(struct caca_sprite *sprite, int f) 181 181 { 182 182 if(sprite == NULL) … … 189 189 } 190 190 191 int ee_get_sprite_dx(struct ee_sprite *sprite, int f)191 int caca_get_sprite_dx(struct caca_sprite *sprite, int f) 192 192 { 193 193 if(sprite == NULL) … … 200 200 } 201 201 202 int ee_get_sprite_dy(struct ee_sprite *sprite, int f)202 int caca_get_sprite_dy(struct caca_sprite *sprite, int f) 203 203 { 204 204 if(sprite == NULL) … … 211 211 } 212 212 213 void ee_draw_sprite(int x, int y, struct ee_sprite *sprite, int f)213 void caca_draw_sprite(int x, int y, struct caca_sprite *sprite, int f) 214 214 { 215 215 int i, j, oldcol; 216 struct ee_frame *frame;216 struct caca_frame *frame; 217 217 218 218 if(sprite == NULL) … … 224 224 frame = &sprite->frames[f]; 225 225 226 oldcol = ee_get_color();226 oldcol = caca_get_color(); 227 227 228 228 for(j = 0; j < frame->h; j++) … … 233 233 if(col >= 0) 234 234 { 235 ee_set_color(col);236 ee_putchar(x + i - frame->dx, y + j - frame->dy,235 caca_set_color(col); 236 caca_putchar(x + i - frame->dx, y + j - frame->dy, 237 237 frame->chars[frame->w * j + i]); 238 238 } … … 240 240 } 241 241 242 ee_set_color(oldcol);243 } 244 245 void ee_free_sprite(struct ee_sprite *sprite)242 caca_set_color(oldcol); 243 } 244 245 void caca_free_sprite(struct caca_sprite *sprite) 246 246 { 247 247 int i; … … 252 252 for(i = sprite->nf; i--;) 253 253 { 254 struct ee_frame *frame = &sprite->frames[i];254 struct caca_frame *frame = &sprite->frames[i]; 255 255 free(frame->chars); 256 256 free(frame->color); -
libcaca/trunk/libcaca/triangle.c
r159 r185 1 1 /* 2 * lib eeASCII-Art library2 * libcaca ASCII-Art library 3 3 * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 25 25 #include <stdlib.h> 26 26 27 #include " ee.h"28 #include " ee_internals.h"27 #include "caca.h" 28 #include "caca_internals.h" 29 29 30 void ee_draw_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c)30 void caca_draw_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) 31 31 { 32 ee_draw_line(x1, y1, x2, y2, c);33 ee_draw_line(x2, y2, x3, y3, c);34 ee_draw_line(x3, y3, x1, y1, c);32 caca_draw_line(x1, y1, x2, y2, c); 33 caca_draw_line(x2, y2, x3, y3, c); 34 caca_draw_line(x3, y3, x1, y1, c); 35 35 } 36 36 37 void ee_draw_thin_triangle(int x1, int y1, int x2, int y2, int x3, int y3)37 void caca_draw_thin_triangle(int x1, int y1, int x2, int y2, int x3, int y3) 38 38 { 39 ee_draw_thin_line(x1, y1, x2, y2);40 ee_draw_thin_line(x2, y2, x3, y3);41 ee_draw_thin_line(x3, y3, x1, y1);39 caca_draw_thin_line(x1, y1, x2, y2); 40 caca_draw_thin_line(x2, y2, x3, y3); 41 caca_draw_thin_line(x3, y3, x1, y1); 42 42 } 43 43 44 void ee_fill_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c)44 void caca_fill_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) 45 45 { 46 46 int x, y, xa, xb, xmax, ymax; … … 49 49 if(y1 > y2) 50 50 { 51 ee_fill_triangle(x2, y2, x1, y1, x3, y3, c);51 caca_fill_triangle(x2, y2, x1, y1, x3, y3, c); 52 52 return; 53 53 } … … 55 55 if(y2 > y3) 56 56 { 57 ee_fill_triangle(x1, y1, x3, y3, x2, y2, c);57 caca_fill_triangle(x1, y1, x3, y3, x2, y2, c); 58 58 return; 59 59 } … … 64 64 x3 *= 4; 65 65 66 xmax = ee_get_width() - 1;67 ymax = ee_get_height() - 1;66 xmax = caca_get_width() - 1; 67 ymax = caca_get_height() - 1; 68 68 69 69 /* Rasterize our triangle */ … … 97 97 98 98 for(x = xa; x <= xb; x++) 99 ee_putchar(x, y, c);99 caca_putchar(x, y, c); 100 100 } 101 101 } -
libcaca/trunk/src/Makefile.am
r175 r185 3 3 ############################################################################### 4 4 5 AM_CPPFLAGS = -I$(top_srcdir)/lib ee5 AM_CPPFLAGS = -I$(top_srcdir)/libcaca 6 6 7 7 if USE_SLANG … … 30 30 weapons.c \ 31 31 $(NULL) 32 ttyvaders_LDADD = ../lib ee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm32 ttyvaders_LDADD = ../libcaca/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm 33 33 -
libcaca/trunk/src/aliens.c
r163 r185 27 27 #include "common.h" 28 28 29 struct ee_sprite *foo_sprite;30 struct ee_sprite *bar_sprite;31 struct ee_sprite *baz_sprite;29 struct caca_sprite *foo_sprite; 30 struct caca_sprite *bar_sprite; 31 struct caca_sprite *baz_sprite; 32 32 33 33 void init_aliens(game *g, aliens *al) … … 40 40 } 41 41 42 foo_sprite = ee_load_sprite("data/foofight.txt");43 bar_sprite = ee_load_sprite("data/barfight.txt");44 baz_sprite = ee_load_sprite("data/bazfight.txt");42 foo_sprite = caca_load_sprite("data/foofight.txt"); 43 bar_sprite = caca_load_sprite("data/barfight.txt"); 44 baz_sprite = caca_load_sprite("data/bazfight.txt"); 45 45 } 46 46 … … 54 54 { 55 55 case ALIEN_FOO: 56 ee_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 8);56 caca_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 8); 57 57 break; 58 58 case ALIEN_BAR: 59 ee_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2);59 caca_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2); 60 60 break; 61 61 case ALIEN_BAZ: 62 ee_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 6);62 caca_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 6); 63 63 break; 64 64 case ALIEN_NONE: … … 79 79 add_explosion(g, g->ex, al->x[i], al->y[i], 0, 0, EXPLOSION_MEDIUM); 80 80 al->type[i] = ALIEN_NONE; 81 add_bonus(g, g->bo, al->x[i], al->y[i], ee_rand(0,4) ? BONUS_GREEN : BONUS_LIFE);81 add_bonus(g, g->bo, al->x[i], al->y[i], caca_rand(0,4) ? BONUS_GREEN : BONUS_LIFE); 82 82 } 83 83 -
libcaca/trunk/src/bonus.c
r163 r185 27 27 #include "common.h" 28 28 29 struct ee_sprite *heart_sprite;30 struct ee_sprite *gem_sprite;29 struct caca_sprite *heart_sprite; 30 struct caca_sprite *gem_sprite; 31 31 32 32 void init_bonus(game *g, bonus *bo) … … 39 39 } 40 40 41 heart_sprite = ee_load_sprite("data/bonheart.txt");42 gem_sprite = ee_load_sprite("data/bongem.txt");41 heart_sprite = caca_load_sprite("data/bonheart.txt"); 42 gem_sprite = caca_load_sprite("data/bongem.txt"); 43 43 } 44 44 … … 52 52 { 53 53 case BONUS_GREEN: 54 ee_draw_sprite(bo->x[i], bo->y[i], gem_sprite,54 caca_draw_sprite(bo->x[i], bo->y[i], gem_sprite, 55 55 (bo->n[i]/2 % 3) ? 0 : 1); 56 56 break; 57 57 case BONUS_LIFE: 58 ee_draw_sprite(bo->x[i], bo->y[i], heart_sprite,58 caca_draw_sprite(bo->x[i], bo->y[i], heart_sprite, 59 59 (bo->n[i] % 3) ? 0 : 1); 60 60 break; -
libcaca/trunk/src/box.c
r173 r185 46 46 int j, frame; 47 47 48 ee_set_color(EE_YELLOW);48 caca_set_color(EE_YELLOW); 49 49 50 50 /* Draw the thin horizontal line */ 51 51 if(b->frame < 8) 52 52 { 53 ee_draw_line(b->x - b->w * b->frame / 16, b->y,53 caca_draw_line(b->x - b->w * b->frame / 16, b->y, 54 54 b->x + b->w * b->frame / 16 - 1, b->y, 'X'); 55 55 return; … … 59 59 frame = b->frame < 12 ? b->frame : 12; 60 60 61 ee_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,61 caca_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8, 62 62 b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 'X'); 63 ee_draw_line(b->x - b->w / 2, b->y + b->h * (frame - 8) / 8,63 caca_draw_line(b->x - b->w / 2, b->y + b->h * (frame - 8) / 8, 64 64 b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, 'X'); 65 65 66 ee_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,66 caca_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8, 67 67 b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, 'X'); 68 ee_draw_line(b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8,68 caca_draw_line(b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 69 69 b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X'); 70 70 71 ee_set_color(EE_BLACK);71 caca_set_color(EE_BLACK); 72 72 73 73 for(j = b->y - b->h * (frame - 8) / 8 + 1; … … 75 75 j++) 76 76 { 77 ee_draw_line(b->x - b->w / 2 + 1, j,77 caca_draw_line(b->x - b->w / 2 + 1, j, 78 78 b->x + b->w / 2 - 2, j, 'X'); 79 79 } … … 85 85 86 86 /* Draw the text inside the frame */ 87 ee_set_color(EE_YELLOW);87 caca_set_color(EE_YELLOW); 88 88 89 89 /* FIXME: use a font */ 90 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2,90 caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2, 91 91 "XXXX. .XXXX X X .XXXX .XXXX XXXX."); 92 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3,92 caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3, 93 93 "X `X X' X X X X' X' X `X"); 94 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4,94 caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4, 95 95 "XXXX' XXXXX X X `XXX XXXX X X"); 96 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5,96 caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5, 97 97 "X' X' `X X. ,X `X X' X ,X"); 98 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6,98 caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6, 99 99 "X X X `XXXX XXXX' `XXXX XXXX'"); 100 100 } -
libcaca/trunk/src/ceo.c
r87 r185 34 34 while(!end) 35 35 { 36 ee_clear();36 caca_clear(); 37 37 38 if( ee_get_key() == '\t')38 if(caca_get_key() == '\t') 39 39 { 40 40 end = 1; … … 43 43 fprintf(stderr, "foo\n"); 44 44 45 ee_refresh();45 caca_refresh(); 46 46 47 47 usleep(40000); -
libcaca/trunk/src/collide.c
r149 r185 128 128 { 129 129 add_explosion(g, ex, GET_MIN(t->left[y-j], x+3), y-j, 0, 1, EXPLOSION_SMALL); 130 t->left[y-j] -= ee_rand(0,2);130 t->left[y-j] -= caca_rand(0,2); 131 131 } 132 132 else if(x + 3 >= t->right[y-j]) 133 133 { 134 134 add_explosion(g, ex, GET_MAX(t->right[y-j], x-2), y-j, 0, 1, EXPLOSION_SMALL); 135 t->right[y-j] += ee_rand(0,2);135 t->right[y-j] += caca_rand(0,2); 136 136 } 137 137 } -
libcaca/trunk/src/common.h
r153 r185 45 45 * Graphics primitives 46 46 */ 47 #include " ee.h"47 #include "caca.h" 48 48 49 49 /* -
libcaca/trunk/src/explosions.c
r163 r185 27 27 #include "common.h" 28 28 29 struct ee_sprite *medium_sprite;30 struct ee_sprite *small_sprite;29 struct caca_sprite *medium_sprite; 30 struct caca_sprite *small_sprite; 31 31 32 32 void init_explosions(game *g, explosions *ex) … … 39 39 } 40 40 41 medium_sprite = ee_load_sprite("data/xplmed.txt");42 small_sprite = ee_load_sprite("data/xplsmall.txt");41 medium_sprite = caca_load_sprite("data/xplmed.txt"); 42 small_sprite = caca_load_sprite("data/xplsmall.txt"); 43 43 } 44 44 … … 77 77 { 78 78 #if 0 79 ee_set_color(GREEN);80 ee_goto(ex->x[i] + 3, ex->y[i]);81 switch( ee_rand(0,2))79 caca_set_color(GREEN); 80 caca_goto(ex->x[i] + 3, ex->y[i]); 81 switch(caca_rand(0,2)) 82 82 { 83 83 case 0: 84 ee_putchar('p');85 ee_putchar('i');86 ee_putchar('f');84 caca_putchar('p'); 85 caca_putchar('i'); 86 caca_putchar('f'); 87 87 break; 88 88 case 1: 89 ee_putchar('p');90 ee_putchar('a');91 ee_putchar('f');89 caca_putchar('p'); 90 caca_putchar('a'); 91 caca_putchar('f'); 92 92 break; 93 93 case 2: 94 ee_putchar('p');95 ee_putchar('o');96 ee_putchar('u');97 ee_putchar('f');94 caca_putchar('p'); 95 caca_putchar('o'); 96 caca_putchar('u'); 97 caca_putchar('f'); 98 98 break; 99 99 } 100 ee_putchar('!');100 caca_putchar('!'); 101 101 #endif 102 102 … … 104 104 { 105 105 case EXPLOSION_MEDIUM: 106 ee_draw_sprite(ex->x[i], ex->y[i], medium_sprite,106 caca_draw_sprite(ex->x[i], ex->y[i], medium_sprite, 107 107 10 - ex->n[i]); 108 108 break; 109 109 case EXPLOSION_SMALL: 110 ee_draw_sprite(ex->x[i], ex->y[i], small_sprite,110 caca_draw_sprite(ex->x[i], ex->y[i], small_sprite, 111 111 6 - ex->n[i]); 112 112 break; -
libcaca/trunk/src/intro.c
r169 r185 31 31 void intro(void) 32 32 { 33 struct ee_sprite *foo_sprite = ee_load_sprite("data/foofight.txt");34 struct ee_sprite *bar_sprite = ee_load_sprite("data/barfight.txt");35 struct ee_sprite *baz_sprite = ee_load_sprite("data/bazfight.txt");33 struct caca_sprite *foo_sprite = caca_load_sprite("data/foofight.txt"); 34 struct caca_sprite *bar_sprite = caca_load_sprite("data/barfight.txt"); 35 struct caca_sprite *baz_sprite = caca_load_sprite("data/bazfight.txt"); 36 36 37 37 int frame = 0; 38 38 39 while( ee_get_key() == 0)39 while(caca_get_key() == 0) 40 40 { 41 41 int i, xo, yo, x[5], y[5]; … … 43 43 frame++; 44 44 45 ee_clear();45 caca_clear(); 46 46 47 xo = ee_get_width() / 2;48 yo = ee_get_height() / 2;47 xo = caca_get_width() / 2; 48 yo = caca_get_height() / 2; 49 49 50 ee_set_color(EE_RED);51 ee_fill_ellipse(xo, yo, 16, 8, '#');52 ee_set_color(EE_GREEN);53 ee_draw_thin_ellipse(xo, yo, 16, 8);50 caca_set_color(EE_RED); 51 caca_fill_ellipse(xo, yo, 16, 8, '#'); 52 caca_set_color(EE_GREEN); 53 caca_draw_thin_ellipse(xo, yo, 16, 8); 54 54 55 55 for(i = 0; i < 4; i ++) … … 61 61 y[4] = y[0]; 62 62 63 ee_set_color(EE_BLACK);64 ee_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' ');65 ee_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' ');66 ee_draw_line(x[0], y[0], x[2], y[2], ' ');67 ee_set_color(EE_GREEN);68 ee_draw_thin_polyline(x, y, 4);63 caca_set_color(EE_BLACK); 64 caca_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' '); 65 caca_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' '); 66 caca_draw_line(x[0], y[0], x[2], y[2], ' '); 67 caca_set_color(EE_GREEN); 68 caca_draw_thin_polyline(x, y, 4); 69 69 70 ee_draw_sprite(xo, yo, foo_sprite, frame % 5);70 caca_draw_sprite(xo, yo, foo_sprite, frame % 5); 71 71 72 ee_refresh();72 caca_refresh(); 73 73 74 74 usleep(40000); -
libcaca/trunk/src/main.c
r177 r185 42 42 srand(time(NULL)); 43 43 44 if( ee_init())44 if(caca_init()) 45 45 { 46 46 return 1; 47 47 } 48 48 49 ee_set_delay(100000);49 caca_set_delay(100000); 50 50 51 51 /* Initialize our program */ 52 g->w = ee_get_width();53 g->h = ee_get_height();52 g->w = caca_get_width(); 53 g->h = caca_get_height(); 54 54 55 55 intro(); … … 59 59 60 60 /* Clean up */ 61 ee_end();61 caca_end(); 62 62 63 63 return 0; … … 101 101 char key; 102 102 103 while((key = ee_get_key()))103 while((key = caca_get_key())) 104 104 { 105 105 switch(key) … … 199 199 200 200 /* XXX: to be removed */ 201 if( ee_rand(0, 9) == 0)201 if(caca_rand(0, 9) == 0) 202 202 { 203 203 int list[3] = { ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ }; 204 204 205 add_alien(g, g->al, 0, rand() % g->h / 2, list[ ee_rand(0,2)]);205 add_alien(g, g->al, 0, rand() % g->h / 2, list[caca_rand(0,2)]); 206 206 } 207 207 … … 232 232 233 233 /* Clear screen */ 234 ee_clear();234 caca_clear(); 235 235 236 236 /* Print starfield, tunnel, aliens, player and explosions */ … … 252 252 253 253 /* Refresh */ 254 ee_refresh();254 caca_refresh(); 255 255 256 256 purcompteur++; -
libcaca/trunk/src/overlay.c
r159 r185 33 33 34 34 /* Draw life jauge */ 35 ee_set_color(EE_DARKGRAY);36 ee_putstr(4, 1, dots30);35 caca_set_color(EE_DARKGRAY); 36 caca_putstr(4, 1, dots30); 37 37 38 38 if(g->p->life > MAX_LIFE * 7 / 10) 39 39 { 40 ee_set_color(EE_GREEN);40 caca_set_color(EE_GREEN); 41 41 } 42 42 else if(g->p->life > MAX_LIFE * 3 / 10) 43 43 { 44 ee_set_color(EE_YELLOW);44 caca_set_color(EE_YELLOW); 45 45 } 46 46 else 47 47 { 48 ee_set_color(EE_RED);48 caca_set_color(EE_RED); 49 49 } 50 50 51 ee_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);51 caca_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); 52 52 53 ee_set_color(EE_WHITE);54 ee_putstr(1, 1, "L |");55 ee_putstr(34, 1, "|");53 caca_set_color(EE_WHITE); 54 caca_putstr(1, 1, "L |"); 55 caca_putstr(34, 1, "|"); 56 56 57 57 /* Draw weapon jauge */ 58 ee_set_color(EE_DARKGRAY);59 ee_putstr(42, 1, dots30 + 10);58 caca_set_color(EE_DARKGRAY); 59 caca_putstr(42, 1, dots30 + 10); 60 60 61 61 if(g->p->special > MAX_SPECIAL * 9 / 10) 62 62 { 63 ee_set_color(EE_WHITE);63 caca_set_color(EE_WHITE); 64 64 } 65 65 else if(g->p->special > MAX_SPECIAL * 3 / 10) 66 66 { 67 ee_set_color(EE_CYAN);67 caca_set_color(EE_CYAN); 68 68 } 69 69 else 70 70 { 71 ee_set_color(EE_BLUE);71 caca_set_color(EE_BLUE); 72 72 } 73 73 74 ee_putstr(42, 1, dashes30 + 1074 caca_putstr(42, 1, dashes30 + 10 75 75 + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); 76 76 77 ee_set_color(EE_WHITE);78 ee_putstr(39, 1, "S |");79 ee_putstr(62, 1, "|");77 caca_set_color(EE_WHITE); 78 caca_putstr(39, 1, "S |"); 79 caca_putstr(62, 1, "|"); 80 80 } 81 81 -
libcaca/trunk/src/player.c
r173 r185 27 27 #include "common.h" 28 28 29 struct ee_sprite *ship_sprite;29 struct caca_sprite *ship_sprite; 30 30 31 31 /* Init tunnel */ … … 45 45 p->dead = 0; 46 46 47 ship_sprite = ee_load_sprite("data/ship.txt");47 ship_sprite = caca_load_sprite("data/ship.txt"); 48 48 49 49 return p; … … 60 60 return; 61 61 62 ee_draw_sprite(p->x, p->y, ship_sprite, 0);62 caca_draw_sprite(p->x, p->y, ship_sprite, 0); 63 63 } 64 64 -
libcaca/trunk/src/starfield.c
r173 r185 38 38 for(i = 0; i < STARS; i++) 39 39 { 40 s[i].x = ee_rand(0, g->w - 1);41 s[i].y = ee_rand(0, g->h - 1);42 s[i].z = ee_rand(1, 3);43 s[i].c = ee_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY;44 s[i].ch = ee_rand(0, 1) ? '.' : '\'';40 s[i].x = caca_rand(0, g->w - 1); 41 s[i].y = caca_rand(0, g->h - 1); 42 s[i].z = caca_rand(1, 3); 43 s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY; 44 s[i].ch = caca_rand(0, 1) ? '.' : '\''; 45 45 } 46 46 … … 56 56 if(s[i].x >= 0) 57 57 { 58 ee_set_color(s[i].c);59 ee_putchar(s[i].x, s[i].y, s[i].ch);58 caca_set_color(s[i].c); 59 caca_putchar(s[i].x, s[i].y, s[i].ch); 60 60 } 61 61 } … … 70 70 if(s[i].x < 0) 71 71 { 72 s[i].x = ee_rand(0, g->w - 1);72 s[i].x = caca_rand(0, g->w - 1); 73 73 s[i].y = 0; 74 s[i].z = ee_rand(1, 2);75 s[i].c = ee_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY;76 s[i].ch = ee_rand(0, 1) ? '.' : '\'';74 s[i].z = caca_rand(1, 2); 75 s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY; 76 s[i].ch = caca_rand(0, 1) ? '.' : '\''; 77 77 } 78 78 else if(s[i].y < g->h-1) -
libcaca/trunk/src/tunnel.c
r173 r185 78 78 char c; 79 79 80 ee_set_color(EE_GREEN);80 caca_set_color(EE_GREEN); 81 81 82 82 /* Left border */ … … 91 91 c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<'; 92 92 93 ee_putchar(t->left[i] + 1, i, c);93 caca_putchar(t->left[i] + 1, i, c); 94 94 95 95 if(i + 1 < g->h) 96 96 for(j = 1; j < t->left[i+1] - t->left[i]; j++) 97 ee_putchar(t->left[i] + j + 1, i, '_');97 caca_putchar(t->left[i] + j + 1, i, '_'); 98 98 } 99 99 … … 111 111 if(i + 1 < g->h) 112 112 for(j = 1; j < t->right[i] - t->right[i+1]; j++) 113 ee_putchar(t->right[i+1] + j - 1, i, '_');114 115 ee_putchar(t->right[i] - 1, i, c);116 } 117 118 ee_set_color(EE_RED);113 caca_putchar(t->right[i+1] + j - 1, i, '_'); 114 115 caca_putchar(t->right[i] - 1, i, c); 116 } 117 118 caca_set_color(EE_RED); 119 119 120 120 /* Left concrete */ 121 121 for(i = 0; i < g->h ; i++) 122 122 for(j = 0 ; j <= t->left[i]; j++) 123 ee_putchar(j, i, '#');123 caca_putchar(j, i, '#'); 124 124 125 125 /* Right concrete */ 126 126 for(i = 0; i < g->h ; i++) 127 127 for(j = t->right[i] ; j < g->w ; j++) 128 ee_putchar(j, i, '#');128 caca_putchar(j, i, '#'); 129 129 } 130 130 … … 142 142 143 143 /* Generate new values */ 144 i = delta[ ee_rand(0,5)];145 j = delta[ ee_rand(0,5)];144 i = delta[caca_rand(0,5)]; 145 j = delta[caca_rand(0,5)]; 146 146 147 147 /* Check in which direction we need to alter tunnel */ -
libcaca/trunk/src/weapons.c
r173 r185 32 32 static void draw_fragbomb(int x, int y, int frame); 33 33 34 struct ee_sprite *bomb_sprite;35 struct ee_sprite *fragbomb_sprite;34 struct caca_sprite *bomb_sprite; 35 struct caca_sprite *fragbomb_sprite; 36 36 37 37 void init_weapons(game *g, weapons *wp) … … 44 44 } 45 45 46 bomb_sprite = ee_load_sprite("data/wpnbomb.txt");47 fragbomb_sprite = ee_load_sprite("data/wpnfrag.txt");46 bomb_sprite = caca_load_sprite("data/wpnbomb.txt"); 47 fragbomb_sprite = caca_load_sprite("data/wpnfrag.txt"); 48 48 } 49 49 … … 57 57 { 58 58 case WEAPON_LASER: 59 ee_set_color(EE_WHITE);60 ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|');61 ee_set_color(EE_CYAN);62 ee_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');59 caca_set_color(EE_WHITE); 60 caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|'); 61 caca_set_color(EE_CYAN); 62 caca_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); 63 63 break; 64 64 case WEAPON_SEEKER: 65 ee_set_color(EE_CYAN);66 ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');67 ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');68 ee_set_color(EE_WHITE);69 ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@');65 caca_set_color(EE_CYAN); 66 caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); 67 caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); 68 caca_set_color(EE_WHITE); 69 caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@'); 70 70 break; 71 71 case WEAPON_BOMB: 72 ee_set_color(EE_DARKGRAY);73 ee_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');74 ee_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');75 ee_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');76 ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');77 ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, '.');72 caca_set_color(EE_DARKGRAY); 73 caca_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); 74 caca_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); 75 caca_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.'); 76 caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); 77 caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, '.'); 78 78 draw_bomb(wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]); 79 79 break; … … 170 170 if(dx | dy) 171 171 { 172 unsigned int norm = ee_sqrt(dx * dx + 4 * dy * dy);172 unsigned int norm = caca_sqrt(dx * dx + 4 * dy * dy); 173 173 dx = dx * 32 / norm; 174 174 dy = dy * 32 / norm; … … 182 182 if(dx | dy) 183 183 { 184 unsigned int norm = ee_sqrt(dx * dx + 4 * dy * dy);184 unsigned int norm = caca_sqrt(dx * dx + 4 * dy * dy); 185 185 wp->vx[i] = dx * 32 / norm; 186 186 wp->vy[i] = dy * 32 / norm; … … 334 334 } 335 335 336 ee_draw_sprite(x, y, bomb_sprite, frame);336 caca_draw_sprite(x, y, bomb_sprite, frame); 337 337 } 338 338 … … 340 340 { 341 341 /* Draw the head */ 342 ee_draw_sprite(x, y, fragbomb_sprite, frame & 1);342 caca_draw_sprite(x, y, fragbomb_sprite, frame & 1); 343 343 344 344 /* Draw the tail */ 345 ee_draw_sprite(x, y, fragbomb_sprite, 2 + (frame % 4));345 caca_draw_sprite(x, y, fragbomb_sprite, 2 + (frame % 4)); 346 346 } 347 347 … … 354 354 { 355 355 case 24: 356 ee_set_color(EE_WHITE);357 ee_putstr(x, y-3, "__");358 ee_putchar(x-1, y-2, '\'');359 ee_putchar(x+2, y-2, '`');356 caca_set_color(EE_WHITE); 357 caca_putstr(x, y-3, "__"); 358 caca_putchar(x-1, y-2, '\''); 359 caca_putchar(x+2, y-2, '`'); 360 360 break; 361 361 case 23: 362 ee_set_color(EE_CYAN);363 ee_putstr(x, y-3, "__");364 ee_set_color(EE_WHITE);365 ee_putstr(x-2, y-2, "-'");366 ee_putstr(x+2, y-2, "`-");362 caca_set_color(EE_CYAN); 363 caca_putstr(x, y-3, "__"); 364 caca_set_color(EE_WHITE); 365 caca_putstr(x-2, y-2, "-'"); 366 caca_putstr(x+2, y-2, "`-"); 367 367 break; 368 368 case 22: 369 ee_set_color(EE_CYAN);370 ee_putstr(x, y-3, "__");371 ee_putchar(x-1, y-2, '\'');372 ee_putchar(x+2, y-2, '`');373 ee_set_color(EE_WHITE);374 ee_putstr(x-3, y-2, ",-");375 ee_putstr(x+3, y-2, "-.");369 caca_set_color(EE_CYAN); 370 caca_putstr(x, y-3, "__"); 371 caca_putchar(x-1, y-2, '\''); 372 caca_putchar(x+2, y-2, '`'); 373 caca_set_color(EE_WHITE); 374 caca_putstr(x-3, y-2, ",-"); 375 caca_putstr(x+3, y-2, "-."); 376 376 break; 377 377 case 21: 378 ee_set_color(EE_CYAN);379 ee_putstr(x-1, y-3, "____");380 ee_putchar(x-2, y-2, '\'');381 ee_putchar(x+3, y-2, '`');382 ee_set_color(EE_WHITE);383 ee_putstr(x-4, y-2, ",-");384 ee_putstr(x+4, y-2, "-.");378 caca_set_color(EE_CYAN); 379 caca_putstr(x-1, y-3, "____"); 380 caca_putchar(x-2, y-2, '\''); 381 caca_putchar(x+3, y-2, '`'); 382 caca_set_color(EE_WHITE); 383 caca_putstr(x-4, y-2, ",-"); 384 caca_putstr(x+4, y-2, "-."); 385 385 break; 386 386 case 20: 387 ee_set_color(EE_WHITE);388 ee_putstr(x, y-3, "%%");389 ee_putchar(x-4, y-2, ',');390 ee_putchar(x+5, y-2, '.');391 ee_set_color(EE_CYAN);392 ee_putchar(x-1, y-3, ':');393 ee_putchar(x+2, y-3, ':');394 ee_putstr(x-3, y-2, "-'");395 ee_putstr(x+3, y-2, "`-");387 caca_set_color(EE_WHITE); 388 caca_putstr(x, y-3, "%%"); 389 caca_putchar(x-4, y-2, ','); 390 caca_putchar(x+5, y-2, '.'); 391 caca_set_color(EE_CYAN); 392 caca_putchar(x-1, y-3, ':'); 393 caca_putchar(x+2, y-3, ':'); 394 caca_putstr(x-3, y-2, "-'"); 395 caca_putstr(x+3, y-2, "`-"); 396 396 break; 397 397 case 19: 398 ee_set_color(EE_WHITE);399 ee_putstr(x, y-4, "%%");400 ee_putstr(x, y-3, "##");401 ee_set_color(EE_CYAN);402 ee_putchar(x-1, y-4, ':');403 ee_putchar(x+2, y-4, ':');404 ee_putchar(x-1, y-3, '%');405 ee_putchar(x+2, y-3, '%');406 ee_putstr(x-4, y-2, ",-'");407 ee_putstr(x+3, y-2, "`-.");408 ee_set_color(EE_BLUE);409 ee_putchar(x-2, y-3, ':');410 ee_putchar(x+3, y-3, ':');398 caca_set_color(EE_WHITE); 399 caca_putstr(x, y-4, "%%"); 400 caca_putstr(x, y-3, "##"); 401 caca_set_color(EE_CYAN); 402 caca_putchar(x-1, y-4, ':'); 403 caca_putchar(x+2, y-4, ':'); 404 caca_putchar(x-1, y-3, '%'); 405 caca_putchar(x+2, y-3, '%'); 406 caca_putstr(x-4, y-2, ",-'"); 407 caca_putstr(x+3, y-2, "`-."); 408 caca_set_color(EE_BLUE); 409 caca_putchar(x-2, y-3, ':'); 410 caca_putchar(x+3, y-3, ':'); 411 411 break; 412 412 case 18: 413 413 default: 414 414 r = (18 - frame) * (18 - frame); 415 ee_set_color(EE_WHITE);416 ee_putstr(x-1, y-5-r, ":%%:");417 ee_putstr(x-1, y-4-r, "%##%");418 ee_set_color(EE_CYAN);419 ee_putchar(x-2, y-4-r, ':');420 ee_putchar(x+3, y-4-r, ':');421 ee_putchar(x-2, y-2, '\'');422 ee_putchar(x+3, y-2, '`');423 ee_set_color(EE_BLUE);424 ee_putchar(x-3, y-2, ':');425 ee_putchar(x+4, y-2, ':');415 caca_set_color(EE_WHITE); 416 caca_putstr(x-1, y-5-r, ":%%:"); 417 caca_putstr(x-1, y-4-r, "%##%"); 418 caca_set_color(EE_CYAN); 419 caca_putchar(x-2, y-4-r, ':'); 420 caca_putchar(x+3, y-4-r, ':'); 421 caca_putchar(x-2, y-2, '\''); 422 caca_putchar(x+3, y-2, '`'); 423 caca_set_color(EE_BLUE); 424 caca_putchar(x-3, y-2, ':'); 425 caca_putchar(x+4, y-2, ':'); 426 426 for(i = 0; i <= r; i++) 427 427 { 428 ee_set_color(EE_WHITE);429 ee_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");430 ee_set_color(EE_CYAN);431 ee_putchar(x-2, y-3-i, '%');432 ee_putchar(x+3, y-3-i, '%');433 ee_set_color(EE_BLUE);434 ee_putchar(x-3, y-3-i, ':');435 ee_putchar(x+4, y-3-i, ':');428 caca_set_color(EE_WHITE); 429 caca_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); 430 caca_set_color(EE_CYAN); 431 caca_putchar(x-2, y-3-i, '%'); 432 caca_putchar(x+3, y-3-i, '%'); 433 caca_set_color(EE_BLUE); 434 caca_putchar(x-3, y-3-i, ':'); 435 caca_putchar(x+4, y-3-i, ':'); 436 436 } 437 437 break; … … 444 444 445 445 /* Lots of duplicate pixels, but we don't care */ 446 ee_set_color(EE_BLUE);447 ee_draw_ellipse(x, y, r, r / 2, ':');448 ee_draw_ellipse(x, y, r + 1, r / 2, ':');449 ee_draw_ellipse(x, y, r + 2, r / 2, ':');450 ee_set_color(EE_CYAN);451 ee_draw_ellipse(x, y, r + 2, r / 2 + 1, '%');452 ee_draw_ellipse(x, y, r + 3, r / 2 + 1, '%');453 ee_set_color(EE_WHITE);454 ee_draw_ellipse(x, y, r + 3, r / 2 + 2, '#');455 ee_draw_ellipse(x, y, r + 4, r / 2 + 2, '#');456 ee_draw_ellipse(x, y, r + 4, r / 2 + 3, '#');457 } 458 446 caca_set_color(EE_BLUE); 447 caca_draw_ellipse(x, y, r, r / 2, ':'); 448 caca_draw_ellipse(x, y, r + 1, r / 2, ':'); 449 caca_draw_ellipse(x, y, r + 2, r / 2, ':'); 450 caca_set_color(EE_CYAN); 451 caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '%'); 452 caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '%'); 453 caca_set_color(EE_WHITE); 454 caca_draw_ellipse(x, y, r + 3, r / 2 + 2, '#'); 455 caca_draw_ellipse(x, y, r + 4, r / 2 + 2, '#'); 456 caca_draw_ellipse(x, y, r + 4, r / 2 + 3, '#'); 457 } 458 -
libcaca/trunk/test/Makefile.am
r183 r185 1 1 ############################################################################### 2 # Automake targets and declarations for lib eetests2 # Automake targets and declarations for libcaca tests 3 3 ############################################################################### 4 4 5 AM_CPPFLAGS = -I$(top_srcdir)/lib ee5 AM_CPPFLAGS = -I$(top_srcdir)/libcaca 6 6 7 7 if USE_SLANG … … 15 15 16 16 demo_SOURCES = demo.c 17 demo_LDADD = ../lib ee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm17 demo_LDADD = ../libcaca/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm 18 18 demo_CFLAGS = `pkg-config --cflags gtk+-2.0` 19 19 demo_LDFLAGS = `pkg-config --libs gtk+-2.0` 20 20 21 21 spritedit_SOURCES = spritedit.c 22 spritedit_LDADD = ../lib ee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm22 spritedit_LDADD = ../libcaca/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm 23 23 -
libcaca/trunk/test/demo.c
r183 r185 1 1 /* 2 * demo demo using lib ee2 * demo demo using libcaca 3 3 * Copyright (c) 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 30 30 #include <gdk/gdkpixbuf.h> 31 31 32 #include " ee.h"32 #include "caca.h" 33 33 34 34 static void display_menu(void); … … 47 47 int bounds = 0; 48 48 int outline = 0; 49 struct ee_sprite *sprite = NULL;49 struct caca_sprite *sprite = NULL; 50 50 51 51 GdkPixbuf *pixbuf; … … 58 58 int quit = 0; 59 59 60 if( ee_init())60 if(caca_init()) 61 61 { 62 62 return 1; 63 63 } 64 64 65 ee_set_delay(40000);65 caca_set_delay(40000); 66 66 67 67 /* Initialize data */ 68 sprite = ee_load_sprite("data/barboss.txt");68 sprite = caca_load_sprite("data/barboss.txt"); 69 69 70 70 gdk_init (&argc, &argv); … … 83 83 /* Main menu */ 84 84 display_menu(); 85 ee_refresh();85 caca_refresh(); 86 86 87 87 /* Go ! */ 88 88 while(!quit) 89 89 { 90 char key = ee_get_key();90 char key = caca_get_key(); 91 91 92 92 if(key && demo) 93 93 { 94 94 display_menu(); 95 ee_refresh();95 caca_refresh(); 96 96 demo = NULL; 97 97 } … … 149 149 150 150 if(demo) 151 ee_clear();152 153 key = ee_get_key();151 caca_clear(); 152 153 key = caca_get_key(); 154 154 if(key) 155 155 goto handle_key; 156 156 157 ee_refresh();157 caca_refresh(); 158 158 } 159 159 … … 162 162 demo(); 163 163 164 ee_set_color(EE_WHITE);165 ee_draw_thin_box(1, 1, ee_get_width() - 2, ee_get_height() - 2);166 ee_printf(4, 1, "[%i.%i fps]----",167 1000000 / ee_get_rendertime(),168 (10000000 / ee_get_rendertime()) % 10);169 ee_refresh();164 caca_set_color(EE_WHITE); 165 caca_draw_thin_box(1, 1, caca_get_width() - 2, caca_get_height() - 2); 166 caca_printf(4, 1, "[%i.%i fps]----", 167 1000000 / caca_get_rendertime(), 168 (10000000 / caca_get_rendertime()) % 10); 169 caca_refresh(); 170 170 } 171 171 } 172 172 173 173 /* Clean up */ 174 ee_free_sprite(sprite);175 ee_end();174 caca_free_sprite(sprite); 175 caca_end(); 176 176 177 177 return 0; … … 180 180 static void display_menu(void) 181 181 { 182 int xo = ee_get_width() - 2;183 int yo = ee_get_height() - 2;184 185 ee_clear();186 ee_set_color(EE_WHITE);187 ee_draw_thin_box(1, 1, xo, yo);188 189 ee_putstr((xo - strlen("libee demo")) / 2, 3, "libeedemo");190 ee_putstr((xo - strlen("============")) / 2, 4, "============");191 192 ee_putstr(4, 6, "demos:");193 ee_putstr(4, 7, "'f': full");194 ee_putstr(4, 8, "'1': dots");195 ee_putstr(4, 9, "'2': lines");196 ee_putstr(4, 10, "'3': boxes");197 ee_putstr(4, 11, "'4': triangles");198 ee_putstr(4, 12, "'5': ellipses");199 ee_putstr(4, 13, "'s': sprites");200 ee_putstr(4, 14, "'c': color");201 ee_putstr(4, 15, "'i': image blit");202 203 ee_putstr(4, 17, "settings:");204 ee_printf(4, 18, "'o': outline: %s",182 int xo = caca_get_width() - 2; 183 int yo = caca_get_height() - 2; 184 185 caca_clear(); 186 caca_set_color(EE_WHITE); 187 caca_draw_thin_box(1, 1, xo, yo); 188 189 caca_putstr((xo - strlen("libcaca demo")) / 2, 3, "libcaca demo"); 190 caca_putstr((xo - strlen("==============")) / 2, 4, "=============="); 191 192 caca_putstr(4, 6, "demos:"); 193 caca_putstr(4, 7, "'f': full"); 194 caca_putstr(4, 8, "'1': dots"); 195 caca_putstr(4, 9, "'2': lines"); 196 caca_putstr(4, 10, "'3': boxes"); 197 caca_putstr(4, 11, "'4': triangles"); 198 caca_putstr(4, 12, "'5': ellipses"); 199 caca_putstr(4, 13, "'s': sprites"); 200 caca_putstr(4, 14, "'c': color"); 201 caca_putstr(4, 15, "'i': image blit"); 202 203 caca_putstr(4, 17, "settings:"); 204 caca_printf(4, 18, "'o': outline: %s", 205 205 outline == 0 ? "none" : outline == 1 ? "solid" : "thin"); 206 ee_printf(4, 19, "'b': drawing boundaries: %s",206 caca_printf(4, 19, "'b': drawing boundaries: %s", 207 207 bounds == 0 ? "screen" : "infinite"); 208 208 209 ee_putstr(4, yo - 2, "'q': quit");209 caca_putstr(4, yo - 2, "'q': quit"); 210 210 } 211 211 … … 218 218 i++; 219 219 220 ee_clear();220 caca_clear(); 221 221 222 222 /* Draw the sun */ 223 ee_set_color(EE_YELLOW);224 xo = ee_get_width() / 4;225 yo = ee_get_height() / 4 + 5 * sin(0.03*i);223 caca_set_color(EE_YELLOW); 224 xo = caca_get_width() / 4; 225 yo = caca_get_height() / 4 + 5 * sin(0.03*i); 226 226 227 227 for(j = 0; j < 16; j++) … … 229 229 xa = xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + M_PI*j/8); 230 230 ya = yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + M_PI*j/8); 231 ee_draw_thin_line(xo, yo, xa, ya);231 caca_draw_thin_line(xo, yo, xa, ya); 232 232 } 233 233 234 234 j = 15 + sin(0.03*i) * 8; 235 ee_set_color(EE_WHITE);236 ee_fill_ellipse(xo, yo, j, j / 2, '#');237 ee_set_color(EE_YELLOW);238 ee_draw_ellipse(xo, yo, j, j / 2, '#');235 caca_set_color(EE_WHITE); 236 caca_fill_ellipse(xo, yo, j, j / 2, '#'); 237 caca_set_color(EE_YELLOW); 238 caca_draw_ellipse(xo, yo, j, j / 2, '#'); 239 239 240 240 /* Draw the pyramid */ 241 xo = ee_get_width() * 5 / 8;241 xo = caca_get_width() * 5 / 8; 242 242 yo = 2; 243 243 244 xa = ee_get_width() / 8 + sin(0.03*i) * 5;245 ya = ee_get_height() / 2 + cos(0.03*i) * 5;246 247 xb = ee_get_width() - 10 - cos(0.02*i) * 10;248 yb = ee_get_height() * 3 / 4 - 5 + sin(0.02*i) * 5;249 250 xc = ee_get_width() / 4 - sin(0.02*i) * 5;251 yc = ee_get_height() * 3 / 4 + cos(0.02*i) * 5;252 253 ee_set_color(EE_GREEN);254 ee_fill_triangle(xo, yo, xb, yb, xa, ya, '%');255 ee_set_color(EE_YELLOW);256 ee_draw_thin_triangle(xo, yo, xb, yb, xa, ya);257 258 ee_set_color(EE_RED);259 ee_fill_triangle(xa, ya, xb, yb, xc, yc, '#');260 ee_set_color(EE_YELLOW);261 ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc);262 263 ee_set_color(EE_BLUE);264 ee_fill_triangle(xo, yo, xb, yb, xc, yc, '%');265 ee_set_color(EE_YELLOW);266 ee_draw_thin_triangle(xo, yo, xb, yb, xc, yc);244 xa = caca_get_width() / 8 + sin(0.03*i) * 5; 245 ya = caca_get_height() / 2 + cos(0.03*i) * 5; 246 247 xb = caca_get_width() - 10 - cos(0.02*i) * 10; 248 yb = caca_get_height() * 3 / 4 - 5 + sin(0.02*i) * 5; 249 250 xc = caca_get_width() / 4 - sin(0.02*i) * 5; 251 yc = caca_get_height() * 3 / 4 + cos(0.02*i) * 5; 252 253 caca_set_color(EE_GREEN); 254 caca_fill_triangle(xo, yo, xb, yb, xa, ya, '%'); 255 caca_set_color(EE_YELLOW); 256 caca_draw_thin_triangle(xo, yo, xb, yb, xa, ya); 257 258 caca_set_color(EE_RED); 259 caca_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); 260 caca_set_color(EE_YELLOW); 261 caca_draw_thin_triangle(xa, ya, xb, yb, xc, yc); 262 263 caca_set_color(EE_BLUE); 264 caca_fill_triangle(xo, yo, xb, yb, xc, yc, '%'); 265 caca_set_color(EE_YELLOW); 266 caca_draw_thin_triangle(xo, yo, xb, yb, xc, yc); 267 267 268 268 /* Draw a background triangle */ … … 270 270 ya = 2; 271 271 272 xb = ee_get_width() - 3;273 yb = ee_get_height() / 2;274 275 xc = ee_get_width() / 3;276 yc = ee_get_height() - 3;277 278 ee_set_color(EE_CYAN);279 ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc);280 281 xo = ee_get_width() / 2 + cos(0.027*i) * ee_get_width() / 3;282 yo = ee_get_height() / 2 - sin(0.027*i) * ee_get_height() / 2;283 284 ee_draw_thin_line(xa, ya, xo, yo);285 ee_draw_thin_line(xb, yb, xo, yo);286 ee_draw_thin_line(xc, yc, xo, yo);272 xb = caca_get_width() - 3; 273 yb = caca_get_height() / 2; 274 275 xc = caca_get_width() / 3; 276 yc = caca_get_height() - 3; 277 278 caca_set_color(EE_CYAN); 279 caca_draw_thin_triangle(xa, ya, xb, yb, xc, yc); 280 281 xo = caca_get_width() / 2 + cos(0.027*i) * caca_get_width() / 3; 282 yo = caca_get_height() / 2 - sin(0.027*i) * caca_get_height() / 2; 283 284 caca_draw_thin_line(xa, ya, xo, yo); 285 caca_draw_thin_line(xb, yb, xo, yo); 286 caca_draw_thin_line(xc, yc, xo, yo); 287 287 288 288 /* Draw a sprite on the pyramid */ 289 ee_draw_sprite(xo, yo, sprite, 0);289 caca_draw_sprite(xo, yo, sprite, 0); 290 290 291 291 /* Draw a trail behind the foreground sprite */ 292 292 for(j = i - 60; j < i; j++) 293 293 { 294 int delta = ee_rand(-5, 5);295 ee_set_color(ee_rand(0, 15));296 ee_putchar(ee_get_width() / 2297 + cos(0.02*j) * (delta + ee_get_width() / 4),298 ee_get_height() / 2299 + sin(0.02*j) * (delta + ee_get_height() / 3),294 int delta = caca_rand(-5, 5); 295 caca_set_color(caca_rand(0, 15)); 296 caca_putchar(caca_get_width() / 2 297 + cos(0.02*j) * (delta + caca_get_width() / 4), 298 caca_get_height() / 2 299 + sin(0.02*j) * (delta + caca_get_height() / 3), 300 300 '#'); 301 301 } 302 302 303 303 /* Draw foreground sprite */ 304 ee_draw_sprite(ee_get_width() / 2 + cos(0.02*i) * ee_get_width() / 4,305 ee_get_height() / 2 + sin(0.02*i) * ee_get_height() / 3,304 caca_draw_sprite(caca_get_width() / 2 + cos(0.02*i) * caca_get_width() / 4, 305 caca_get_height() / 2 + sin(0.02*i) * caca_get_height() / 3, 306 306 sprite, 0); 307 307 } … … 309 309 static void demo_dots(void) 310 310 { 311 int xmax = ee_get_width() - 1;312 int ymax = ee_get_height() - 1;311 int xmax = caca_get_width() - 1; 312 int ymax = caca_get_height() - 1; 313 313 int i; 314 314 … … 316 316 { 317 317 /* Putpixel */ 318 ee_set_color(ee_rand(0, 15));319 ee_putchar(ee_rand(0, xmax), ee_rand(0, ymax), '#');318 caca_set_color(caca_rand(0, 15)); 319 caca_putchar(caca_rand(0, xmax), caca_rand(0, ymax), '#'); 320 320 } 321 321 } … … 326 326 char buf[BUFSIZ]; 327 327 328 ee_clear();328 caca_clear(); 329 329 for(i = 0; i < 16; i++) 330 330 { 331 sprintf(buf, "'%c': %i (%s)", 'a' + i, i, ee_get_color_name(i));332 ee_set_color(EE_WHITE);333 ee_putstr(4, i + 3, buf);334 ee_set_color(i);335 ee_putstr(40, i + 3, "XXXXXXXXXX-XX--X----------");331 sprintf(buf, "'%c': %i (%s)", 'a' + i, i, caca_get_color_name(i)); 332 caca_set_color(EE_WHITE); 333 caca_putstr(4, i + 3, buf); 334 caca_set_color(i); 335 caca_putstr(40, i + 3, "XXXXXXXXXX-XX--X----------"); 336 336 } 337 337 } … … 339 339 static void demo_lines(void) 340 340 { 341 int w = ee_get_width();342 int h = ee_get_height();341 int w = caca_get_width(); 342 int h = caca_get_height(); 343 343 int xa, ya, xb, yb; 344 344 345 345 if(bounds) 346 346 { 347 xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h);348 xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h);347 xa = caca_rand(- w, 2 * w); ya = caca_rand(- h, 2 * h); 348 xb = caca_rand(- w, 2 * w); yb = caca_rand(- h, 2 * h); 349 349 } 350 350 else 351 351 { 352 xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1);353 xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1);354 } 355 356 ee_set_color(ee_rand(0, 15));352 xa = caca_rand(0, w - 1); ya = caca_rand(0, h - 1); 353 xb = caca_rand(0, w - 1); yb = caca_rand(0, h - 1); 354 } 355 356 caca_set_color(caca_rand(0, 15)); 357 357 if(outline > 1) 358 ee_draw_thin_line(xa, ya, xb, yb);358 caca_draw_thin_line(xa, ya, xb, yb); 359 359 else 360 ee_draw_line(xa, ya, xb, yb, '#');360 caca_draw_line(xa, ya, xb, yb, '#'); 361 361 } 362 362 363 363 static void demo_boxes(void) 364 364 { 365 int w = ee_get_width();366 int h = ee_get_height();365 int w = caca_get_width(); 366 int h = caca_get_height(); 367 367 int xa, ya, xb, yb; 368 368 369 369 if(bounds) 370 370 { 371 xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h);372 xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h);371 xa = caca_rand(- w, 2 * w); ya = caca_rand(- h, 2 * h); 372 xb = caca_rand(- w, 2 * w); yb = caca_rand(- h, 2 * h); 373 373 } 374 374 else 375 375 { 376 xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1);377 xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1);378 } 379 380 ee_set_color(ee_rand(0, 15));381 ee_fill_box(xa, ya, xb, yb, '#');382 383 ee_set_color(ee_rand(0, 15));376 xa = caca_rand(0, w - 1); ya = caca_rand(0, h - 1); 377 xb = caca_rand(0, w - 1); yb = caca_rand(0, h - 1); 378 } 379 380 caca_set_color(caca_rand(0, 15)); 381 caca_fill_box(xa, ya, xb, yb, '#'); 382 383 caca_set_color(caca_rand(0, 15)); 384 384 if(outline == 2) 385 ee_draw_thin_box(xa, ya, xb, yb);385 caca_draw_thin_box(xa, ya, xb, yb); 386 386 else if(outline == 1) 387 ee_draw_box(xa, ya, xb, yb, '#');387 caca_draw_box(xa, ya, xb, yb, '#'); 388 388 } 389 389 390 390 static void demo_ellipses(void) 391 391 { 392 int w = ee_get_width();393 int h = ee_get_height();392 int w = caca_get_width(); 393 int h = caca_get_height(); 394 394 int x, y, a, b; 395 395 396 396 if(bounds) 397 397 { 398 x = ee_rand(- w, 2 * w); y = ee_rand(- h, 2 * h);399 a = ee_rand(0, w); b = ee_rand(0, h);398 x = caca_rand(- w, 2 * w); y = caca_rand(- h, 2 * h); 399 a = caca_rand(0, w); b = caca_rand(0, h); 400 400 } 401 401 else … … 403 403 do 404 404 { 405 x = ee_rand(0, w); y = ee_rand(0, h);406 a = ee_rand(0, w); b = ee_rand(0, h);405 x = caca_rand(0, w); y = caca_rand(0, h); 406 a = caca_rand(0, w); b = caca_rand(0, h); 407 407 408 408 } while(x - a < 0 || x + a >= w || y - b < 0 || y + b >= h); 409 409 } 410 410 411 ee_set_color(ee_rand(0, 15));412 ee_fill_ellipse(x, y, a, b, '#');413 414 ee_set_color(ee_rand(0, 15));411 caca_set_color(caca_rand(0, 15)); 412 caca_fill_ellipse(x, y, a, b, '#'); 413 414 caca_set_color(caca_rand(0, 15)); 415 415 if(outline == 2) 416 ee_draw_thin_ellipse(x, y, a, b);416 caca_draw_thin_ellipse(x, y, a, b); 417 417 else if(outline == 1) 418 ee_draw_ellipse(x, y, a, b, '#');418 caca_draw_ellipse(x, y, a, b, '#'); 419 419 } 420 420 421 421 static void demo_triangles(void) 422 422 { 423 int w = ee_get_width();424 int h = ee_get_height();423 int w = caca_get_width(); 424 int h = caca_get_height(); 425 425 int xa, ya, xb, yb, xc, yc; 426 426 427 427 if(bounds) 428 428 { 429 xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h);430 xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h);431 xc = ee_rand(- w, 2 * w); yc = ee_rand(- h, 2 * h);429 xa = caca_rand(- w, 2 * w); ya = caca_rand(- h, 2 * h); 430 xb = caca_rand(- w, 2 * w); yb = caca_rand(- h, 2 * h); 431 xc = caca_rand(- w, 2 * w); yc = caca_rand(- h, 2 * h); 432 432 } 433 433 else 434 434 { 435 435 436 xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1);437 xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1);438 xc = ee_rand(0, w - 1); yc = ee_rand(0, h - 1);439 } 440 441 ee_set_color(ee_rand(0, 15));442 ee_fill_triangle(xa, ya, xb, yb, xc, yc, '#');443 444 ee_set_color(ee_rand(0, 15));436 xa = caca_rand(0, w - 1); ya = caca_rand(0, h - 1); 437 xb = caca_rand(0, w - 1); yb = caca_rand(0, h - 1); 438 xc = caca_rand(0, w - 1); yc = caca_rand(0, h - 1); 439 } 440 441 caca_set_color(caca_rand(0, 15)); 442 caca_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); 443 444 caca_set_color(caca_rand(0, 15)); 445 445 if(outline == 2) 446 ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc);446 caca_draw_thin_triangle(xa, ya, xb, yb, xc, yc); 447 447 else if(outline == 1) 448 ee_draw_triangle(xa, ya, xb, yb, xc, yc, '#');448 caca_draw_triangle(xa, ya, xb, yb, xc, yc, '#'); 449 449 } 450 450 451 451 static void demo_sprites(void) 452 452 { 453 ee_draw_sprite(ee_rand(0, ee_get_width() - 1),454 ee_rand(0, ee_get_height() - 1), sprite, 0);453 caca_draw_sprite(caca_rand(0, caca_get_width() - 1), 454 caca_rand(0, caca_get_height() - 1), sprite, 0); 455 455 } 456 456 457 457 static void demo_blit(void) 458 458 { 459 ee_set_color(EE_LIGHTGRAY);460 ee_blit(6, 4, ee_get_width() - 6, ee_get_height() - 4, pixels, bufx, bufy);461 } 462 459 caca_set_color(EE_LIGHTGRAY); 460 caca_blit(6, 4, caca_get_width() - 6, caca_get_height() - 4, pixels, bufx, bufy); 461 } 462 -
libcaca/trunk/test/spritedit.c
r153 r185 1 1 /* 2 * spritedit sprite editor using lib ee2 * spritedit sprite editor using libcaca 3 3 * Copyright (c) 2003 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 25 25 #include <stdio.h> 26 26 27 #include " ee.h"27 #include "caca.h" 28 28 29 29 int main(int argc, char **argv) 30 30 { 31 31 int quit = 0; 32 struct ee_sprite *sprite;32 struct caca_sprite *sprite; 33 33 int frame = 0; 34 34 … … 39 39 } 40 40 41 if( ee_init())41 if(caca_init()) 42 42 return 1; 43 43 44 sprite = ee_load_sprite(argv[1]);44 sprite = caca_load_sprite(argv[1]); 45 45 46 46 if(!sprite) 47 47 { 48 ee_end();48 caca_end(); 49 49 fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]); 50 50 return 1; … … 57 57 char buf[BUFSIZ]; 58 58 59 switch( ee_get_key())59 switch(caca_get_key()) 60 60 { 61 61 case 0: … … 69 69 break; 70 70 case '+': 71 if(frame < ee_get_sprite_frames(sprite) - 1)71 if(frame < caca_get_sprite_frames(sprite) - 1) 72 72 frame++; 73 73 break; 74 74 } 75 75 76 ee_clear();76 caca_clear(); 77 77 78 ee_set_color(EE_WHITE);79 ee_draw_thin_box(0, 0, ee_get_width() - 1, ee_get_height() - 1);78 caca_set_color(EE_WHITE); 79 caca_draw_thin_box(0, 0, caca_get_width() - 1, caca_get_height() - 1); 80 80 81 ee_putstr(3, 0, "[ Sprite editor for libee]");81 caca_putstr(3, 0, "[ Sprite editor for libcaca ]"); 82 82 83 83 sprintf(buf, "sprite `%s'", argv[1]); 84 ee_putstr(3, 2, buf);85 sprintf(buf, "frame %i/%i", frame, ee_get_sprite_frames(sprite) - 1);86 ee_putstr(3, 3, buf);84 caca_putstr(3, 2, buf); 85 sprintf(buf, "frame %i/%i", frame, caca_get_sprite_frames(sprite) - 1); 86 caca_putstr(3, 3, buf); 87 87 88 88 /* Crosshair */ 89 ee_draw_thin_line(57, 2, 57, 18);90 ee_draw_thin_line(37, 10, 77, 10);91 ee_putchar(57, 10, '+');89 caca_draw_thin_line(57, 2, 57, 18); 90 caca_draw_thin_line(37, 10, 77, 10); 91 caca_putchar(57, 10, '+'); 92 92 93 93 /* Boxed sprite */ 94 xa = -1 - ee_get_sprite_dx(sprite, frame);95 ya = -1 - ee_get_sprite_dy(sprite, frame);96 xb = xa + 1 + ee_get_sprite_width(sprite, frame);97 yb = ya + 1 + ee_get_sprite_height(sprite, frame);98 ee_set_color(EE_BLACK);99 ee_fill_box(57 + xa, 10 + ya, 57 + xb, 10 + yb, ' ');100 ee_set_color(EE_WHITE);101 ee_draw_thin_box(57 + xa, 10 + ya, 57 + xb, 10 + yb);102 ee_draw_sprite(57, 10, sprite, frame);94 xa = -1 - caca_get_sprite_dx(sprite, frame); 95 ya = -1 - caca_get_sprite_dy(sprite, frame); 96 xb = xa + 1 + caca_get_sprite_width(sprite, frame); 97 yb = ya + 1 + caca_get_sprite_height(sprite, frame); 98 caca_set_color(EE_BLACK); 99 caca_fill_box(57 + xa, 10 + ya, 57 + xb, 10 + yb, ' '); 100 caca_set_color(EE_WHITE); 101 caca_draw_thin_box(57 + xa, 10 + ya, 57 + xb, 10 + yb); 102 caca_draw_sprite(57, 10, sprite, frame); 103 103 104 104 /* Free sprite */ 105 ee_draw_sprite(20, 10, sprite, frame);105 caca_draw_sprite(20, 10, sprite, frame); 106 106 107 ee_refresh();107 caca_refresh(); 108 108 } 109 109 110 110 /* Clean up */ 111 ee_end();111 caca_end(); 112 112 113 113 return 0;
Note: See TracChangeset
for help on using the changeset viewer.