Changeset 147
- Timestamp:
- Nov 11, 2003, 12:38:50 AM (19 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 16 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/libee/Makefile.am
r129 r147 7 7 ee.c \ 8 8 ee.h \ 9 graphics.c \ 9 10 io.c \ 10 11 math.c \ -
libcaca/trunk/libee/conic.c
r137 r147 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 24 30 25 31 #include <stdlib.h> … … 100 106 101 107 if((b & (0x1|0x4)) == (0x1|0x4)) 102 { 103 ee_goto(xo + x, yo + y); 104 ee_putchar(c); 105 } 108 ee_putchar(xo + x, yo + y, c); 106 109 107 110 if((b & (0x2|0x4)) == (0x2|0x4)) 108 { 109 ee_goto(xo - x, yo + y); 110 ee_putchar(c); 111 } 111 ee_putchar(xo - x, yo + y, c); 112 112 113 113 if((b & (0x1|0x8)) == (0x1|0x8)) 114 { 115 ee_goto(xo + x, yo - y); 116 ee_putchar(c); 117 } 114 ee_putchar(xo + x, yo - y, c); 118 115 119 116 if((b & (0x2|0x8)) == (0x2|0x8)) 120 { 121 ee_goto(xo - x, yo - y); 122 ee_putchar(c); 123 } 117 ee_putchar(xo - x, yo - y, c); 124 118 } 125 119 -
libcaca/trunk/libee/ee.c
r93 r147 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 24 30 25 31 #include <stdlib.h> … … 128 134 } 129 135 130 void ee_clear(void)131 {132 #if defined(USE_SLANG) || defined(USE_NCURSES)133 /* We could use SLsmg_cls(), but drawing empty lines is much faster */134 int x = ee_get_width(), y = ee_get_height();135 char *empty_line = malloc((x + 1) * sizeof(char));136 137 memset(empty_line, ' ', x);138 empty_line[x] = '\0';139 140 while(y--)141 {142 ee_goto(0, y);143 ee_putstr(empty_line);144 }145 146 free(empty_line);147 #else148 /* Use dummy driver */149 #endif150 }151 152 136 static int64_t local_time(void) 153 137 { … … 166 150 static int64_t local_clock = 0; 167 151 int64_t now; 168 169 ee_goto(0, 0);170 152 171 153 if(!local_clock) -
libcaca/trunk/libee/ee.h
r131 r147 22 22 23 23 /* 24 * Graphics primitives 25 */ 26 #ifdef USE_SLANG 27 # include <slang.h> 28 # define ee_color(x) SLsmg_set_color(x) 29 # define ee_goto(x,y) SLsmg_gotorc(y,x) 30 # define ee_putchar(x) SLsmg_write_char(x) 31 # define ee_putstr(x) SLsmg_write_string(x) 32 #elif USE_NCURSES 33 # define box box_divert 34 # include <curses.h> 35 # undef box 36 # define ee_color(x) attrset(COLOR_PAIR(x)) 37 # define ee_goto(x,y) move(y,x) 38 # define ee_putchar(x) addch(x) 39 # define ee_putstr(x) addstr(x) 40 #else 41 # define ee_color(x) (void)(x) 42 # define ee_goto(x,y) do{ (void)(x); (void)(y); } while(0) 43 # define ee_putchar(x) (void)(x) 44 # define ee_putstr(x) (void)(x) 45 #endif 46 47 #define ee_putcharTO(x,y,c) do{ ee_goto(x,y); ee_putchar(c); }while(0) 48 49 /* 50 * Colours 24 * Colors 51 25 */ 52 26 #define EE_BLACK 1 … … 73 47 int ee_get_width(void); 74 48 int ee_get_height(void); 75 void ee_clear(void);76 49 void ee_refresh(void); 77 50 void ee_end(void); 78 51 79 52 char ee_get_key(void); 53 54 void ee_color(int); 55 void ee_putchar(int, int, char); 56 void ee_putstr(int, int, char *); 57 void ee_clear(void); 80 58 81 59 void ee_draw_line(int, int, int, int, char); -
libcaca/trunk/libee/graphics.c
r146 r147 23 23 #include "config.h" 24 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 30 31 #include <string.h> 25 32 #include <stdlib.h> 26 #include <unistd.h>27 #include <string.h>28 #include <sys/time.h>29 #include <time.h>30 33 31 34 #include "ee.h" 32 35 33 static int _ee_delay; 34 35 int ee_init(void) 36 void ee_color(int color) 36 37 { 37 38 #ifdef USE_SLANG 38 static char * colors[] = { "black", "green", "yellow", "white", 39 "red", "gray", "lightgray", "blue", "cyan", "magenta", NULL }; 40 int i; 41 42 /* Initialize slang library */ 43 SLsig_block_signals(); 44 SLtt_get_terminfo(); 45 46 if(SLkp_init() == -1) 47 { 48 SLsig_unblock_signals(); 49 return -1; 50 } 51 52 SLang_init_tty(-1, 0, 1); 53 54 if(SLsmg_init_smg() == -1) 55 { 56 SLsig_unblock_signals(); 57 return -1; 58 } 59 60 SLsig_unblock_signals(); 61 62 SLsmg_cls(); 63 SLtt_set_cursor_visibility(0); 64 SLsmg_refresh(); 65 66 for(i = 0; colors[i]; i++) 67 { 68 SLtt_set_color(i + 1, NULL, colors[i], "black"); 69 } 70 39 SLsmg_set_color(color); 71 40 #elif USE_NCURSES 72 /* Initialize ncurses library */ 73 initscr(); 74 keypad(stdscr, TRUE); 75 nonl(); 76 cbreak(); 77 noecho(); 78 nodelay(stdscr, TRUE); 79 curs_set(0); 80 81 start_color(); 82 83 init_pair(EE_BLACK, COLOR_BLACK, COLOR_BLACK); 84 init_pair(EE_GREEN, COLOR_GREEN, COLOR_BLACK); 85 init_pair(EE_YELLOW, COLOR_YELLOW, COLOR_BLACK); 86 init_pair(EE_WHITE, COLOR_WHITE, COLOR_BLACK); 87 init_pair(EE_RED, COLOR_RED, COLOR_BLACK); 88 init_pair(EE_GRAY, COLOR_WHITE, COLOR_BLACK); // XXX 89 init_pair(EE_LIGHTGRAY, COLOR_WHITE, COLOR_BLACK); // XXX 90 init_pair(EE_BLUE, COLOR_BLUE, COLOR_BLACK); 91 init_pair(EE_CYAN, COLOR_CYAN, COLOR_BLACK); 92 init_pair(EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); 93 41 attrset(COLOR_PAIR(color)); 94 42 #else 95 /* Dummy driver */ 96 97 #endif 98 _ee_delay = 0; 99 100 return 0; 101 } 102 103 void ee_set_delay(int delay) 104 { 105 _ee_delay = delay; 106 } 107 108 int ee_get_width(void) 109 { 110 #ifdef USE_SLANG 111 return SLtt_Screen_Cols; 112 #elif USE_NCURSES 113 return COLS; 114 #else 115 return 80; 43 /* Use dummy driver */ 116 44 #endif 117 45 } 118 46 119 int ee_get_height(void)47 void ee_putchar(int x, int y, char c) 120 48 { 121 49 #ifdef USE_SLANG 122 return SLtt_Screen_Rows; 50 SLsmg_gotorc(y,x); 51 SLsmg_write_char(c); 123 52 #elif USE_NCURSES 124 return LINES; 53 move(y,x); 54 addch(c); 125 55 #else 126 return 25; 56 /* Use dummy driver */ 57 #endif 58 } 59 60 void ee_putstr(int x, int y, char *s) 61 { 62 #ifdef USE_SLANG 63 SLsmg_gotorc(y,x); 64 SLsmg_write_string(s); 65 #elif USE_NCURSES 66 move(y,x); 67 addstr(s); 68 #else 69 /* Use dummy driver */ 127 70 #endif 128 71 } … … 140 83 while(y--) 141 84 { 142 ee_goto(0, y); 143 ee_putstr(empty_line); 85 ee_putstr(0, y, empty_line); 144 86 } 145 87 … … 150 92 } 151 93 152 static int64_t local_time(void)153 {154 struct timeval tv;155 int64_t now;156 157 gettimeofday(&tv, NULL);158 now = tv.tv_sec;159 now *= 1000000;160 now += tv.tv_usec;161 return now;162 }163 164 void ee_refresh(void)165 {166 static int64_t local_clock = 0;167 int64_t now;168 169 ee_goto(0, 0);170 171 if(!local_clock)172 {173 /* Initialize local_clock */174 local_clock = local_time();175 }176 177 if(local_time() > local_clock + 10000)178 {179 /* If we are late, we shouldn't display anything */180 }181 182 #ifdef USE_SLANG183 SLsmg_refresh();184 #elif USE_NCURSES185 refresh();186 #else187 /* Use dummy driver */188 #endif189 190 now = local_time();191 192 if(now < local_clock + _ee_delay - 10000)193 {194 usleep(local_clock + _ee_delay - 10000 - now);195 }196 197 local_clock += _ee_delay;198 }199 200 void ee_end(void)201 {202 #ifdef USE_SLANG203 SLtt_set_cursor_visibility(1);204 SLang_reset_tty();205 SLsmg_reset_smg();206 #elif USE_NCURSES207 curs_set(1);208 endwin();209 #else210 /* Use dummy driver */211 #endif212 }213 -
libcaca/trunk/libee/io.c
r89 r147 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 24 30 25 31 #include "ee.h" -
libcaca/trunk/libee/line.c
r129 r147 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 24 30 25 31 #include <inttypes.h> … … 197 203 for(; dx>=0; dx--) 198 204 { 199 ee_goto(x1, y1); 200 ee_putchar(s->c); 205 ee_putchar(x1, y1, s->c); 201 206 if(delta > 0) 202 207 { … … 220 225 for(; dy >= 0; dy--) 221 226 { 222 ee_goto(x1, y1); 223 ee_putchar(s->c); 227 ee_putchar(x1, y1, s->c); 224 228 if(delta > 0) 225 229 { … … 291 295 for(; dx>=0; dx--) 292 296 { 293 ee_goto(x1, y1);294 297 if(delta > 0) 295 298 { 296 ee_putchar( charmapy[1]);299 ee_putchar(x1, y1, charmapy[1]); 297 300 x1++; 298 301 y1 += yinc; … … 303 306 { 304 307 if(prev) 305 ee_putchar( charmapy[0]);308 ee_putchar(x1, y1, charmapy[0]); 306 309 else 307 ee_putchar( '-');310 ee_putchar(x1, y1, '-'); 308 311 x1++; 309 312 delta += dpr; … … 320 323 for(; dy >= 0; dy--) 321 324 { 322 ee_goto(x1, y1);323 325 if(delta > 0) 324 326 { 325 ee_putchar( charmapx[0]);326 ee_putchar( charmapx[1]);327 ee_putchar(x1, y1, charmapx[0]); 328 ee_putchar(x1 + 1, y1, charmapx[1]); 327 329 x1++; 328 330 y1 += yinc; … … 331 333 else 332 334 { 333 ee_putchar( '|');335 ee_putchar(x1, y1, '|'); 334 336 y1 += yinc; 335 337 delta += dpr; -
libcaca/trunk/libee/math.c
r91 r147 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 24 30 25 31 #include <stdlib.h> -
libcaca/trunk/libee/sprite.c
r139 r147 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 24 30 25 31 #include <stdio.h> … … 167 173 if(col >= 0) 168 174 { 169 ee_goto(x + i - frame->dx, y + j - frame->dy);170 175 ee_color(col); 171 ee_putchar(frame->chars[frame->w * j + i]); 176 ee_putchar(x + i - frame->dx, y + j - frame->dy, 177 frame->chars[frame->w * j + i]); 172 178 } 173 179 } -
libcaca/trunk/libee/triangle.c
r105 r147 22 22 23 23 #include "config.h" 24 25 #ifdef USE_SLANG 26 # include <slang.h> 27 #elif USE_NCURSES 28 # include <curses.h> 29 #endif 24 30 25 31 #include <stdlib.h> … … 82 88 83 89 for(x = xa; x <= xb; x++) 84 { 85 ee_goto(x, y); 86 ee_putchar(c); 87 } 90 ee_putchar(x, y, c); 88 91 } 89 92 } -
libcaca/trunk/src/box.c
r121 r147 86 86 87 87 /* FIXME: use a font */ 88 ee_ goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2);89 ee_putstr("XXXX. .XXXX X X .XXXX .XXXX XXXX.");90 ee_ goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3);91 ee_putstr("X `X X' X X X X' X' X `X");92 ee_ goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4);93 ee_putstr("XXXX' XXXXX X X `XXX XXXX X X");94 ee_ goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5);95 ee_putstr("X' X' `X X. ,X `X X' X ,X");96 ee_ goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6);97 ee_putstr("X X X `XXXX XXXX' `XXXX XXXX'");88 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2, 89 "XXXX. .XXXX X X .XXXX .XXXX XXXX."); 90 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3, 91 "X `X X' X X X X' X' X `X"); 92 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4, 93 "XXXX' XXXXX X X `XXX XXXX X X"); 94 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5, 95 "X' X' `X X. ,X `X X' X ,X"); 96 ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6, 97 "X X X `XXXX XXXX' `XXXX XXXX'"); 98 98 } 99 99 -
libcaca/trunk/src/overlay.c
r109 r147 34 34 /* Draw life jauge */ 35 35 ee_color(EE_GRAY); 36 ee_goto(4, 1); 37 ee_putstr(dots30); 36 ee_putstr(4, 1, dots30); 38 37 39 38 if(g->p->life > MAX_LIFE * 7 / 10) … … 50 49 } 51 50 52 ee_goto(4, 1); 53 ee_putstr(dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); 51 ee_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); 54 52 55 53 ee_color(EE_WHITE); 56 ee_goto(1, 1); 57 ee_putstr("L |"); 58 ee_goto(34, 1); 59 ee_putstr("|"); 54 ee_putstr(1, 1, "L |"); 55 ee_putstr(34, 1, "|"); 60 56 61 57 /* Draw weapon jauge */ 62 58 ee_color(EE_GRAY); 63 ee_goto(42, 1); 64 ee_putstr(dots30 + 10); 59 ee_putstr(42, 1, dots30 + 10); 65 60 66 61 if(g->p->special > MAX_SPECIAL * 9 / 10) … … 77 72 } 78 73 79 ee_ goto(42, 1);80 ee_putstr(dashes30 + 10+ (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL);74 ee_putstr(42, 1, dashes30 + 10 75 + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); 81 76 82 77 ee_color(EE_WHITE); 83 ee_goto(39, 1); 84 ee_putstr("S |"); 85 ee_goto(62, 1); 86 ee_putstr("|"); 78 ee_putstr(39, 1, "S |"); 79 ee_putstr(62, 1, "|"); 87 80 } 88 81 -
libcaca/trunk/src/player.c
r109 r147 56 56 } 57 57 58 ee_goto(p->x + 2, p->y - 2);59 58 ee_color(EE_GREEN); 60 ee_putstr("/\\"); 61 ee_goto(p->x + 1, p->y - 1); 62 ee_putchar('('); 59 ee_putstr(p->x + 2, p->y - 2, "/\\"); 60 ee_putchar(p->x + 1, p->y - 1, '('); 61 ee_putchar(p->x + 4, p->y - 1, ')'); 62 ee_putstr(p->x, p->y, "I<__>I"); 63 63 ee_color(EE_YELLOW); 64 ee_putstr("()"); 65 ee_color(EE_GREEN); 66 ee_putchar(')'); 67 ee_goto(p->x, p->y); 68 ee_color(EE_GREEN); 69 ee_putstr("I<__>I"); 64 ee_putstr(p->x + 2, p->y - 1, "()"); 70 65 } 71 66 -
libcaca/trunk/src/starfield.c
r109 r147 55 55 { 56 56 ee_color(s[i].c); 57 ee_goto(s[i].x, s[i].y); 58 ee_putchar(s[i].ch); 57 ee_putchar(s[i].x, s[i].y, s[i].ch); 59 58 } 60 59 } -
libcaca/trunk/src/tunnel.c
r109 r147 78 78 { 79 79 if(t->left[i] <= -10) 80 {81 80 continue; 82 }83 81 84 82 if(i + 1 == g->h || t->left[i] > t->left[i+1]) 85 {86 83 c = (i == 0 || t->left[i] > t->left[i-1]) ? '>' : '/'; 87 }88 84 else 89 {90 85 c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<'; 91 } 92 93 ee_goto(t->left[i] + 1, i); 94 ee_putchar(c); 86 87 ee_putchar(t->left[i] + 1, i, c); 95 88 96 89 if(i + 1 < g->h) 97 {98 90 for(j = 1; j < t->left[i+1] - t->left[i]; j++) 99 { 100 ee_goto(t->left[i] + j + 1, i); 101 ee_putchar('_'); 102 } 103 } 91 ee_putchar(t->left[i] + j + 1, i, '_'); 104 92 } 105 93 … … 108 96 { 109 97 if(t->right[i] >= g->w + 10) 110 {111 98 continue; 112 }113 99 114 100 if(i + 1 == g->h || t->right[i] > t->right[i+1]) 115 {116 101 c = (i == 0 || t->right[i] > t->right[i-1]) ? '>' : '/'; 117 }118 102 else 119 {120 103 c = (i == 0 || t->right[i] > t->right[i-1]) ? '\\' : '<'; 121 }122 104 123 105 if(i + 1 < g->h) 124 {125 106 for(j = 1; j < t->right[i] - t->right[i+1]; j++) 126 { 127 ee_goto(t->right[i+1] + j - 1, i); 128 ee_putchar('_'); 129 } 130 } 131 132 ee_goto(t->right[i] - 1, i); 133 ee_putchar(c); 107 ee_putchar(t->right[i+1] + j - 1, i, '_'); 108 109 ee_putchar(t->right[i] - 1, i, c); 134 110 } 135 111 … … 138 114 /* Left concrete */ 139 115 for(i = 0; i < g->h ; i++) 140 {141 116 for(j = 0 ; j <= t->left[i]; j++) 142 { 143 ee_goto(j, i); 144 ee_putchar('#'); 145 } 146 } 117 ee_putchar(j, i, '#'); 147 118 148 119 /* Right concrete */ 149 120 for(i = 0; i < g->h ; i++) 150 {151 121 for(j = t->right[i] ; j < g->w ; j++) 152 { 153 ee_goto(j, i); 154 ee_putchar('#'); 155 } 156 } 122 ee_putchar(j, i, '#'); 157 123 } 158 124 -
libcaca/trunk/src/weapons.c
r143 r147 58 58 case WEAPON_LASER: 59 59 ee_color(EE_WHITE); 60 ee_goto(wp->x[i] >> 4, wp->y[i] >> 4); 61 ee_putchar('|'); 60 ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|'); 62 61 ee_color(EE_CYAN); 63 ee_goto(wp->x[i] >> 4, (wp->y[i] >> 4) + 1); 64 ee_putchar('|'); 62 ee_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); 65 63 break; 66 64 case WEAPON_SEEKER: 67 65 ee_color(EE_CYAN); 68 ee_goto(wp->x3[i] >> 4, wp->y3[i] >> 4); 69 ee_putchar('.'); 70 ee_goto(wp->x2[i] >> 4, wp->y2[i] >> 4); 71 ee_putchar('o'); 66 ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); 67 ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); 72 68 ee_color(EE_WHITE); 73 ee_goto(wp->x[i] >> 4, wp->y[i] >> 4); 74 ee_putchar('@'); 69 ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@'); 75 70 break; 76 71 case WEAPON_BOMB: 77 72 ee_color(EE_GRAY); 78 ee_goto((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4); 79 ee_putchar('.'); 80 ee_goto((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4); 81 ee_putchar('.'); 82 ee_goto((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4); 83 ee_putchar('.'); 84 ee_goto(wp->x3[i] >> 4, wp->y3[i] >> 4); 85 ee_putchar('.'); 86 ee_goto(wp->x2[i] >> 4, wp->y2[i] >> 4); 87 ee_putchar('.'); 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, '.'); 88 78 draw_bomb(wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]); 89 79 break; … … 368 358 case 24: 369 359 ee_color(EE_WHITE); 370 ee_goto(x, y-3); 371 ee_putstr("__"); 372 ee_goto(x-1, y-2); 373 ee_putchar('\''); 374 ee_goto(x+2, y-2); 375 ee_putchar('`'); 360 ee_putstr(x, y-3, "__"); 361 ee_putchar(x-1, y-2, '\''); 362 ee_putchar(x+2, y-2, '`'); 376 363 break; 377 364 case 23: 378 365 ee_color(EE_CYAN); 379 ee_goto(x, y-3); 380 ee_putstr("__"); 381 ee_color(EE_WHITE); 382 ee_goto(x-2, y-2); 383 ee_putstr("-'"); 384 ee_goto(x+2, y-2); 385 ee_putstr("`-"); 366 ee_putstr(x, y-3, "__"); 367 ee_color(EE_WHITE); 368 ee_putstr(x-2, y-2, "-'"); 369 ee_putstr(x+2, y-2, "`-"); 386 370 break; 387 371 case 22: 388 372 ee_color(EE_CYAN); 389 ee_goto(x, y-3); 390 ee_putstr("__"); 391 ee_goto(x-1, y-2); 392 ee_putchar('\''); 393 ee_goto(x+2, y-2); 394 ee_putchar('`'); 395 ee_color(EE_WHITE); 396 ee_goto(x-3, y-2); 397 ee_putstr(",-"); 398 ee_goto(x+3, y-2); 399 ee_putstr("-."); 373 ee_putstr(x, y-3, "__"); 374 ee_putchar(x-1, y-2, '\''); 375 ee_putchar(x+2, y-2, '`'); 376 ee_color(EE_WHITE); 377 ee_putstr(x-3, y-2, ",-"); 378 ee_putstr(x+3, y-2, "-."); 400 379 break; 401 380 case 21: 402 381 ee_color(EE_CYAN); 403 ee_goto(x-1, y-3); 404 ee_putstr("____"); 405 ee_goto(x-2, y-2); 406 ee_putchar('\''); 407 ee_goto(x+3, y-2); 408 ee_putchar('`'); 409 ee_color(EE_WHITE); 410 ee_goto(x-4, y-2); 411 ee_putstr(",-"); 412 ee_goto(x+4, y-2); 413 ee_putstr("-."); 382 ee_putstr(x-1, y-3, "____"); 383 ee_putchar(x-2, y-2, '\''); 384 ee_putchar(x+3, y-2, '`'); 385 ee_color(EE_WHITE); 386 ee_putstr(x-4, y-2, ",-"); 387 ee_putstr(x+4, y-2, "-."); 414 388 break; 415 389 case 20: 416 390 ee_color(EE_WHITE); 417 ee_goto(x, y-3); 418 ee_putstr("%%"); 419 ee_goto(x-4, y-2); 420 ee_putchar(','); 421 ee_goto(x+5, y-2); 422 ee_putchar('.'); 423 ee_color(EE_CYAN); 424 ee_goto(x-1, y-3); 425 ee_putchar(':'); 426 ee_goto(x+2, y-3); 427 ee_putchar(':'); 428 ee_goto(x-3, y-2); 429 ee_putstr("-'"); 430 ee_goto(x+3, y-2); 431 ee_putstr("`-"); 391 ee_putstr(x, y-3, "%%"); 392 ee_putchar(x-4, y-2, ','); 393 ee_putchar(x+5, y-2, '.'); 394 ee_color(EE_CYAN); 395 ee_putchar(x-1, y-3, ':'); 396 ee_putchar(x+2, y-3, ':'); 397 ee_putstr(x-3, y-2, "-'"); 398 ee_putstr(x+3, y-2, "`-"); 432 399 break; 433 400 case 19: 434 401 ee_color(EE_WHITE); 435 ee_goto(x, y-4); 436 ee_putstr("%%"); 437 ee_goto(x, y-3); 438 ee_putstr("##"); 439 ee_color(EE_CYAN); 440 ee_goto(x-1, y-4); 441 ee_putchar(':'); 442 ee_goto(x+2, y-4); 443 ee_putchar(':'); 444 ee_goto(x-1, y-3); 445 ee_putchar('%'); 446 ee_goto(x+2, y-3); 447 ee_putchar('%'); 448 ee_goto(x-4, y-2); 449 ee_putstr(",-'"); 450 ee_goto(x+3, y-2); 451 ee_putstr("`-."); 402 ee_putstr(x, y-4, "%%"); 403 ee_putstr(x, y-3, "##"); 404 ee_color(EE_CYAN); 405 ee_putchar(x-1, y-4, ':'); 406 ee_putchar(x+2, y-4, ':'); 407 ee_putchar(x-1, y-3, '%'); 408 ee_putchar(x+2, y-3, '%'); 409 ee_putstr(x-4, y-2, ",-'"); 410 ee_putstr(x+3, y-2, "`-."); 452 411 ee_color(EE_BLUE); 453 ee_goto(x-2, y-3); 454 ee_putchar(':'); 455 ee_goto(x+3, y-3); 456 ee_putchar(':'); 412 ee_putchar(x-2, y-3, ':'); 413 ee_putchar(x+3, y-3, ':'); 457 414 break; 458 415 case 18: … … 460 417 r = (18 - frame) * (18 - frame); 461 418 ee_color(EE_WHITE); 462 ee_goto(x-1, y-5-r); 463 ee_putstr(":%%:"); 464 ee_goto(x-1, y-4-r); 465 ee_putstr("%##%"); 466 ee_color(EE_CYAN); 467 ee_goto(x-2, y-4-r); 468 ee_putchar(':'); 469 ee_goto(x+3, y-4-r); 470 ee_putchar(':'); 471 ee_goto(x-2, y-2); 472 ee_putchar('\''); 473 ee_goto(x+3, y-2); 474 ee_putchar('`'); 419 ee_putstr(x-1, y-5-r, ":%%:"); 420 ee_putstr(x-1, y-4-r, "%##%"); 421 ee_color(EE_CYAN); 422 ee_putchar(x-2, y-4-r, ':'); 423 ee_putchar(x+3, y-4-r, ':'); 424 ee_putchar(x-2, y-2, '\''); 425 ee_putchar(x+3, y-2, '`'); 475 426 ee_color(EE_BLUE); 476 ee_goto(x-3, y-2); 477 ee_putchar(':'); 478 ee_goto(x+4, y-2); 479 ee_putchar(':'); 427 ee_putchar(x-3, y-2, ':'); 428 ee_putchar(x+4, y-2, ':'); 480 429 for(i = 0; i <= r; i++) 481 430 { 482 431 ee_color(EE_WHITE); 483 ee_goto(x-1, y-3-i); 484 ee_putstr((i+frame) % 5 ? "####" : "%%%%"); 432 ee_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); 485 433 ee_color(EE_CYAN); 486 ee_goto(x-2, y-3-i); 487 ee_putchar('%'); 488 ee_goto(x+3, y-3-i); 489 ee_putchar('%'); 434 ee_putchar(x-2, y-3-i, '%'); 435 ee_putchar(x+3, y-3-i, '%'); 490 436 ee_color(EE_BLUE); 491 ee_goto(x-3, y-3-i); 492 ee_putchar(':'); 493 ee_goto(x+4, y-3-i); 494 ee_putchar(':'); 437 ee_putchar(x-3, y-3-i, ':'); 438 ee_putchar(x+4, y-3-i, ':'); 495 439 } 496 440 break; -
libcaca/trunk/test/demo.c
r133 r147 139 139 ee_draw_line(1, 1, xo, 1, '.'); 140 140 141 ee_goto((xo - strlen("libee demo")) / 2, 3); 142 ee_putstr("libee demo"); 143 ee_goto((xo - strlen("============")) / 2, 4); 144 ee_putstr("============"); 145 146 ee_goto(4, 6); 147 ee_putstr("0: complete demo"); 148 ee_goto(4, 7); 149 ee_putstr("1: dots demo"); 150 ee_goto(4, 8); 151 ee_putstr("2: lines demo"); 152 ee_goto(4, 9); 153 ee_putstr("3: thin lines demo"); 154 ee_goto(4, 10); 155 ee_putstr("4: circles demo"); 156 ee_goto(4, 11); 157 ee_putstr("5: ellipses demo"); 158 ee_goto(4, 12); 159 ee_putstr("6: triangles demo"); 160 ee_goto(4, 13); 161 ee_putstr("7: outlined triangles demo"); 162 ee_goto(4, 14); 163 ee_putstr("8: sprites demo"); 164 165 ee_goto(4, yo - 2); 166 ee_putstr("q: quit"); 141 ee_putstr((xo - strlen("libee demo")) / 2, 3, "libee demo"); 142 ee_putstr((xo - strlen("============")) / 2, 4, "============"); 143 144 ee_putstr(4, 6, "0: complete demo"); 145 ee_putstr(4, 7, "1: dots demo"); 146 ee_putstr(4, 8, "2: lines demo"); 147 ee_putstr(4, 9, "3: thin lines demo"); 148 ee_putstr(4, 10, "4: circles demo"); 149 ee_putstr(4, 11, "5: ellipses demo"); 150 ee_putstr(4, 12, "6: triangles demo"); 151 ee_putstr(4, 13, "7: outlined triangles demo"); 152 ee_putstr(4, 14, "8: sprites demo"); 153 154 ee_putstr(4, yo - 2, "q: quit"); 167 155 168 156 ee_refresh(); … … 266 254 int delta = ee_rand(-5, 5); 267 255 ee_color(ee_rand(1, 10)); 268 ee_ goto(ee_get_width() / 2269 + cos(0.02*j) * (delta + ee_get_width() / 4),270 ee_get_height() / 2271 + sin(0.02*j) * (delta + ee_get_height() / 3));272 ee_putchar('#');256 ee_putchar(ee_get_width() / 2 257 + cos(0.02*j) * (delta + ee_get_width() / 4), 258 ee_get_height() / 2 259 + sin(0.02*j) * (delta + ee_get_height() / 3), 260 '#'); 273 261 } 274 262 … … 291 279 /* Putpixel */ 292 280 ee_color(ee_rand(1, 10)); 293 ee_goto(ee_rand(0, xmax), ee_rand(0, ymax)); 294 ee_putchar('#'); 281 ee_putchar(ee_rand(0, xmax), ee_rand(0, ymax), '#'); 295 282 } 296 283 ee_refresh();
Note: See TracChangeset
for help on using the changeset viewer.