Changeset 153
- Timestamp:
- Nov 12, 2003, 2:48:58 AM (20 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/data/foo_fighter
r121 r153 20 20 9 2 4 0 21 21 ,-oXo-. 22 ' V`22 ' `V' ` 23 23 ddededd 24 d dd24 d ddd d 25 25 7 2 3 0 26 26 ,oXo. 27 / V\27 / `V' \ 28 28 deded 29 d dd29 d ddd d -
libcaca/trunk/libee/box.c
r151 r153 68 68 ee_putchar(x, y1, '-'); 69 69 70 if(y2 < ymax)70 if(y2 <= ymax) 71 71 for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) 72 72 ee_putchar(x, y2, '-'); … … 76 76 ee_putchar(x1, y, '|'); 77 77 78 if(x2 < xmax)78 if(x2 <= xmax) 79 79 for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) 80 80 ee_putchar(x2, y, '|'); -
libcaca/trunk/libee/ee.h
r151 r153 20 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 21 */ 22 23 #ifndef __EE_H__ 24 #define __EE_H__ 25 26 #ifdef __cplusplus 27 extern "C" 28 { 29 #endif 22 30 23 31 /* … … 52 60 char ee_get_key(void); 53 61 54 void ee_color(int); 62 void ee_set_color(int); 63 int ee_get_color(void); 55 64 void ee_putchar(int, int, char); 56 65 void ee_putstr(int, int, char *); … … 58 67 59 68 void ee_draw_line(int, int, int, int, char); 69 void ee_draw_polyline(int[], int[], int, char); 60 70 void ee_draw_thin_line(int, int, int, int); 71 void ee_draw_thin_polyline(int[], int[], int); 61 72 62 73 void ee_draw_circle(int, int, int, char); … … 77 88 78 89 struct ee_sprite * ee_load_sprite(const char *); 79 void ee_set_sprite_frame(struct ee_sprite *, int); 80 int ee_get_sprite_frame(struct ee_sprite *); 81 void ee_draw_sprite(int, int, struct ee_sprite *); 90 int ee_get_sprite_frames(struct ee_sprite *); 91 int ee_get_sprite_width(struct ee_sprite *, int); 92 int ee_get_sprite_height(struct ee_sprite *, int); 93 int ee_get_sprite_dx(struct ee_sprite *, int); 94 int ee_get_sprite_dy(struct ee_sprite *, int); 95 void ee_draw_sprite(int, int, struct ee_sprite *, int); 82 96 void ee_free_sprite(struct ee_sprite *); 83 97 98 #ifdef __cplusplus 99 } 100 #endif 101 102 #endif /* __EE_H__ */ -
libcaca/trunk/libee/graphics.c
r147 r153 34 34 #include "ee.h" 35 35 36 void ee_color(int color) 36 static int ee_color = 0; 37 38 void ee_set_color(int color) 37 39 { 40 ee_color = color; 38 41 #ifdef USE_SLANG 39 42 SLsmg_set_color(color); … … 43 46 /* Use dummy driver */ 44 47 #endif 48 } 49 50 int ee_get_color(void) 51 { 52 return ee_color; 45 53 } 46 54 -
libcaca/trunk/libee/line.c
r147 r153 69 69 } 70 70 71 void ee_draw_polyline(int x[], int y[], int n, char c) 72 { 73 int i; 74 struct line s; 75 s.c = c; 76 s.draw = draw_solid_line; 77 78 for(i = 0; i < n; i++) 79 { 80 s.x1 = x[i]; 81 s.y1 = y[i]; 82 s.x2 = x[i+1]; 83 s.y2 = y[i+1]; 84 clip_line(&s); 85 } 86 } 87 71 88 /** 72 89 * \brief Draw a thin line on the screen, using ASCII art. … … 89 106 } 90 107 108 void ee_draw_thin_polyline(int x[], int y[], int n) 109 { 110 int i; 111 struct line s; 112 s.draw = draw_thin_line; 113 114 for(i = 0; i < n; i++) 115 { 116 s.x1 = x[i]; 117 s.y1 = y[i]; 118 s.x2 = x[i+1]; 119 s.y2 = y[i+1]; 120 clip_line(&s); 121 } 122 } 123 91 124 /* 92 125 * XXX: The following functions are local. -
libcaca/trunk/libee/sprite.c
r147 r153 45 45 struct ee_sprite 46 46 { 47 int f;48 47 int nf; 49 48 struct ee_frame *frames; … … 61 60 62 61 sprite = malloc(sizeof(struct ee_sprite)); 63 sprite->f = 0;64 62 sprite->nf = 0; 65 63 sprite->frames = NULL; … … 137 135 } 138 136 139 void ee_set_sprite_frame(struct ee_sprite *sprite, int f) 140 { 137 int ee_get_sprite_frames(struct ee_sprite *sprite) 138 { 139 if(sprite == NULL) 140 return 0; 141 142 return sprite->nf; 143 } 144 145 int ee_get_sprite_width(struct ee_sprite *sprite, int f) 146 { 147 if(sprite == NULL) 148 return 0; 149 150 if(f < 0 || f >= sprite->nf) 151 return 0; 152 153 return sprite->frames[f].w; 154 } 155 156 int ee_get_sprite_height(struct ee_sprite *sprite, int f) 157 { 158 if(sprite == NULL) 159 return 0; 160 161 if(f < 0 || f >= sprite->nf) 162 return 0; 163 164 return sprite->frames[f].h; 165 } 166 167 int ee_get_sprite_dx(struct ee_sprite *sprite, int f) 168 { 169 if(sprite == NULL) 170 return 0; 171 172 if(f < 0 || f >= sprite->nf) 173 return 0; 174 175 return sprite->frames[f].dx; 176 } 177 178 int ee_get_sprite_dy(struct ee_sprite *sprite, int f) 179 { 180 if(sprite == NULL) 181 return 0; 182 183 if(f < 0 || f >= sprite->nf) 184 return 0; 185 186 return sprite->frames[f].dy; 187 } 188 189 void ee_draw_sprite(int x, int y, struct ee_sprite *sprite, int f) 190 { 191 int i, j, oldcol; 192 struct ee_frame *frame; 193 141 194 if(sprite == NULL) 142 195 return; … … 145 198 return; 146 199 147 sprite->f = f; 148 } 149 150 int ee_get_sprite_frame(struct ee_sprite *sprite) 151 { 152 if(sprite == NULL) 153 return -1; 154 155 return sprite->f; 156 } 157 158 void ee_draw_sprite(int x, int y, struct ee_sprite *sprite) 159 { 160 int i, j; 161 struct ee_frame *frame; 162 163 if(sprite == NULL) 164 return; 165 166 frame = &sprite->frames[sprite->f]; 200 frame = &sprite->frames[f]; 201 202 oldcol = ee_get_color(); 167 203 168 204 for(j = 0; j < frame->h; j++) … … 173 209 if(col >= 0) 174 210 { 175 ee_ color(col);211 ee_set_color(col); 176 212 ee_putchar(x + i - frame->dx, y + j - frame->dy, 177 213 frame->chars[frame->w * j + i]); … … 179 215 } 180 216 } 217 218 ee_set_color(oldcol); 181 219 } 182 220 -
libcaca/trunk/src/Makefile.am
r145 r153 22 22 common.h \ 23 23 explosions.c \ 24 intro.c \ 24 25 main.c \ 25 26 overlay.c \ -
libcaca/trunk/src/aliens.c
r121 r153 27 27 #include "common.h" 28 28 29 static void draw_alien_foo(game *, int, int, int);30 static void draw_alien_bar(game *, int, int, int);31 static void draw_alien_baz(game *, int, int, int);32 33 29 struct ee_sprite *foo_sprite; 34 30 struct ee_sprite *bar_sprite; … … 58 54 { 59 55 case ALIEN_FOO: 60 draw_alien_foo(g, al->x[i], al->y[i], al->img[i] % 8);56 ee_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 8); 61 57 break; 62 58 case ALIEN_BAR: 63 draw_alien_bar(g, al->x[i], al->y[i], al->img[i] % 2);59 ee_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2); 64 60 break; 65 61 case ALIEN_BAZ: 66 draw_alien_baz(g, al->x[i], al->y[i], al->img[i] % 6);62 ee_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 6); 67 63 break; 68 64 case ALIEN_NONE: … … 139 135 } 140 136 141 static void draw_alien_bar(game *g, int x, int y, int frame)142 {143 ee_set_sprite_frame(bar_sprite, frame);144 ee_draw_sprite(x, y, bar_sprite);145 }146 147 static void draw_alien_baz(game *g, int x, int y, int frame)148 {149 ee_set_sprite_frame(baz_sprite, frame);150 ee_draw_sprite(x, y, baz_sprite);151 }152 153 static void draw_alien_foo(game *g, int x, int y, int frame)154 {155 ee_set_sprite_frame(foo_sprite, frame);156 ee_draw_sprite(x, y, foo_sprite);157 }158 159 -
libcaca/trunk/src/bonus.c
r121 r153 52 52 { 53 53 case BONUS_GREEN: 54 ee_ set_sprite_frame(gem_sprite, (bo->n[i]/2 % 3) ? 0 : 1);55 ee_draw_sprite(bo->x[i], bo->y[i], gem_sprite);54 ee_draw_sprite(bo->x[i], bo->y[i], gem_sprite, 55 (bo->n[i]/2 % 3) ? 0 : 1); 56 56 break; 57 57 case BONUS_LIFE: 58 ee_ set_sprite_frame(heart_sprite, (bo->n[i] % 3) ? 0 : 1);59 ee_draw_sprite(bo->x[i], bo->y[i], heart_sprite);58 ee_draw_sprite(bo->x[i], bo->y[i], heart_sprite, 59 (bo->n[i] % 3) ? 0 : 1); 60 60 break; 61 61 case BONUS_NONE: -
libcaca/trunk/src/box.c
r147 r153 44 44 int j, frame; 45 45 46 ee_ color(EE_YELLOW);46 ee_set_color(EE_YELLOW); 47 47 48 48 /* Draw the thin horizontal line */ … … 67 67 b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X'); 68 68 69 ee_ color(EE_BLACK);69 ee_set_color(EE_BLACK); 70 70 71 71 for(j = b->y - b->h * (frame - 8) / 8 + 1; … … 83 83 84 84 /* Draw the text inside the frame */ 85 ee_ color(EE_YELLOW);85 ee_set_color(EE_YELLOW); 86 86 87 87 /* FIXME: use a font */ -
libcaca/trunk/src/common.h
r89 r153 20 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 21 */ 22 23 void intro(void); 22 24 23 25 /* -
libcaca/trunk/src/explosions.c
r139 r153 26 26 27 27 #include "common.h" 28 29 static void draw_small_explosion(int x, int y, int frame);30 static void draw_medium_explosion(int x, int y, int frame);31 28 32 29 struct ee_sprite *medium_sprite; … … 80 77 { 81 78 #if 0 82 ee_ color(GREEN);79 ee_set_color(GREEN); 83 80 ee_goto(ex->x[i] + 3, ex->y[i]); 84 81 switch(ee_rand(0,2)) … … 107 104 { 108 105 case EXPLOSION_MEDIUM: 109 draw_medium_explosion(ex->x[i], ex->y[i], ex->n[i]); 106 ee_draw_sprite(ex->x[i], ex->y[i], medium_sprite, 107 10 - ex->n[i]); 110 108 break; 111 109 case EXPLOSION_SMALL: 112 draw_small_explosion(ex->x[i], ex->y[i], ex->n[i]); 110 ee_draw_sprite(ex->x[i], ex->y[i], small_sprite, 111 6 - ex->n[i]); 113 112 break; 114 113 case EXPLOSION_NONE: … … 142 141 } 143 142 144 static void draw_small_explosion(int x, int y, int frame)145 {146 ee_set_sprite_frame(small_sprite, 6 - frame);147 ee_draw_sprite(x, y, small_sprite);148 }149 150 static void draw_medium_explosion(int x, int y, int frame)151 {152 ee_set_sprite_frame(medium_sprite, 10 - frame);153 ee_draw_sprite(x, y, medium_sprite);154 }155 -
libcaca/trunk/src/main.c
r149 r153 48 48 g->w = ee_get_width(); 49 49 g->h = ee_get_height(); 50 51 intro(); 50 52 51 53 /* Go ! */ -
libcaca/trunk/src/overlay.c
r147 r153 33 33 34 34 /* Draw life jauge */ 35 ee_ color(EE_GRAY);35 ee_set_color(EE_GRAY); 36 36 ee_putstr(4, 1, dots30); 37 37 38 38 if(g->p->life > MAX_LIFE * 7 / 10) 39 39 { 40 ee_ color(EE_GREEN);40 ee_set_color(EE_GREEN); 41 41 } 42 42 else if(g->p->life > MAX_LIFE * 3 / 10) 43 43 { 44 ee_ color(EE_YELLOW);44 ee_set_color(EE_YELLOW); 45 45 } 46 46 else 47 47 { 48 ee_ color(EE_RED);48 ee_set_color(EE_RED); 49 49 } 50 50 51 51 ee_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); 52 52 53 ee_ color(EE_WHITE);53 ee_set_color(EE_WHITE); 54 54 ee_putstr(1, 1, "L |"); 55 55 ee_putstr(34, 1, "|"); 56 56 57 57 /* Draw weapon jauge */ 58 ee_ color(EE_GRAY);58 ee_set_color(EE_GRAY); 59 59 ee_putstr(42, 1, dots30 + 10); 60 60 61 61 if(g->p->special > MAX_SPECIAL * 9 / 10) 62 62 { 63 ee_ color(EE_WHITE);63 ee_set_color(EE_WHITE); 64 64 } 65 65 else if(g->p->special > MAX_SPECIAL * 3 / 10) 66 66 { 67 ee_ color(EE_CYAN);67 ee_set_color(EE_CYAN); 68 68 } 69 69 else 70 70 { 71 ee_ color(EE_BLUE);71 ee_set_color(EE_BLUE); 72 72 } 73 73 … … 75 75 + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); 76 76 77 ee_ color(EE_WHITE);77 ee_set_color(EE_WHITE); 78 78 ee_putstr(39, 1, "S |"); 79 79 ee_putstr(62, 1, "|"); -
libcaca/trunk/src/player.c
r149 r153 58 58 return; 59 59 60 ee_draw_sprite(p->x, p->y, ship_sprite );60 ee_draw_sprite(p->x, p->y, ship_sprite, 0); 61 61 } 62 62 -
libcaca/trunk/src/starfield.c
r147 r153 54 54 if(s[i].x >= 0) 55 55 { 56 ee_ color(s[i].c);56 ee_set_color(s[i].c); 57 57 ee_putchar(s[i].x, s[i].y, s[i].ch); 58 58 } -
libcaca/trunk/src/tunnel.c
r147 r153 72 72 char c; 73 73 74 ee_ color(EE_GREEN);74 ee_set_color(EE_GREEN); 75 75 76 76 /* Left border */ … … 110 110 } 111 111 112 ee_ color(EE_RED);112 ee_set_color(EE_RED); 113 113 114 114 /* Left concrete */ -
libcaca/trunk/src/weapons.c
r149 r153 57 57 { 58 58 case WEAPON_LASER: 59 ee_ color(EE_WHITE);59 ee_set_color(EE_WHITE); 60 60 ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|'); 61 ee_ color(EE_CYAN);61 ee_set_color(EE_CYAN); 62 62 ee_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); 63 63 break; 64 64 case WEAPON_SEEKER: 65 ee_ color(EE_CYAN);65 ee_set_color(EE_CYAN); 66 66 ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); 67 67 ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); 68 ee_ color(EE_WHITE);68 ee_set_color(EE_WHITE); 69 69 ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@'); 70 70 break; 71 71 case WEAPON_BOMB: 72 ee_ color(EE_GRAY);72 ee_set_color(EE_GRAY); 73 73 ee_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); 74 74 ee_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); … … 334 334 } 335 335 336 ee_set_sprite_frame(bomb_sprite, frame); 337 ee_draw_sprite(x, y, bomb_sprite); 336 ee_draw_sprite(x, y, bomb_sprite, frame); 338 337 } 339 338 … … 341 340 { 342 341 /* Draw the head */ 343 ee_set_sprite_frame(fragbomb_sprite, frame & 1); 344 ee_draw_sprite(x, y, fragbomb_sprite); 342 ee_draw_sprite(x, y, fragbomb_sprite, frame & 1); 345 343 346 344 /* Draw the tail */ 347 ee_set_sprite_frame(fragbomb_sprite, 2 + (frame % 4)); 348 ee_draw_sprite(x, y, fragbomb_sprite); 345 ee_draw_sprite(x, y, fragbomb_sprite, 2 + (frame % 4)); 349 346 } 350 347 … … 357 354 { 358 355 case 24: 359 ee_ color(EE_WHITE);356 ee_set_color(EE_WHITE); 360 357 ee_putstr(x, y-3, "__"); 361 358 ee_putchar(x-1, y-2, '\''); … … 363 360 break; 364 361 case 23: 365 ee_ color(EE_CYAN);362 ee_set_color(EE_CYAN); 366 363 ee_putstr(x, y-3, "__"); 367 ee_ color(EE_WHITE);364 ee_set_color(EE_WHITE); 368 365 ee_putstr(x-2, y-2, "-'"); 369 366 ee_putstr(x+2, y-2, "`-"); 370 367 break; 371 368 case 22: 372 ee_ color(EE_CYAN);369 ee_set_color(EE_CYAN); 373 370 ee_putstr(x, y-3, "__"); 374 371 ee_putchar(x-1, y-2, '\''); 375 372 ee_putchar(x+2, y-2, '`'); 376 ee_ color(EE_WHITE);373 ee_set_color(EE_WHITE); 377 374 ee_putstr(x-3, y-2, ",-"); 378 375 ee_putstr(x+3, y-2, "-."); 379 376 break; 380 377 case 21: 381 ee_ color(EE_CYAN);378 ee_set_color(EE_CYAN); 382 379 ee_putstr(x-1, y-3, "____"); 383 380 ee_putchar(x-2, y-2, '\''); 384 381 ee_putchar(x+3, y-2, '`'); 385 ee_ color(EE_WHITE);382 ee_set_color(EE_WHITE); 386 383 ee_putstr(x-4, y-2, ",-"); 387 384 ee_putstr(x+4, y-2, "-."); 388 385 break; 389 386 case 20: 390 ee_ color(EE_WHITE);387 ee_set_color(EE_WHITE); 391 388 ee_putstr(x, y-3, "%%"); 392 389 ee_putchar(x-4, y-2, ','); 393 390 ee_putchar(x+5, y-2, '.'); 394 ee_ color(EE_CYAN);391 ee_set_color(EE_CYAN); 395 392 ee_putchar(x-1, y-3, ':'); 396 393 ee_putchar(x+2, y-3, ':'); … … 399 396 break; 400 397 case 19: 401 ee_ color(EE_WHITE);398 ee_set_color(EE_WHITE); 402 399 ee_putstr(x, y-4, "%%"); 403 400 ee_putstr(x, y-3, "##"); 404 ee_ color(EE_CYAN);401 ee_set_color(EE_CYAN); 405 402 ee_putchar(x-1, y-4, ':'); 406 403 ee_putchar(x+2, y-4, ':'); … … 409 406 ee_putstr(x-4, y-2, ",-'"); 410 407 ee_putstr(x+3, y-2, "`-."); 411 ee_ color(EE_BLUE);408 ee_set_color(EE_BLUE); 412 409 ee_putchar(x-2, y-3, ':'); 413 410 ee_putchar(x+3, y-3, ':'); … … 416 413 default: 417 414 r = (18 - frame) * (18 - frame); 418 ee_ color(EE_WHITE);415 ee_set_color(EE_WHITE); 419 416 ee_putstr(x-1, y-5-r, ":%%:"); 420 417 ee_putstr(x-1, y-4-r, "%##%"); 421 ee_ color(EE_CYAN);418 ee_set_color(EE_CYAN); 422 419 ee_putchar(x-2, y-4-r, ':'); 423 420 ee_putchar(x+3, y-4-r, ':'); 424 421 ee_putchar(x-2, y-2, '\''); 425 422 ee_putchar(x+3, y-2, '`'); 426 ee_ color(EE_BLUE);423 ee_set_color(EE_BLUE); 427 424 ee_putchar(x-3, y-2, ':'); 428 425 ee_putchar(x+4, y-2, ':'); 429 426 for(i = 0; i <= r; i++) 430 427 { 431 ee_ color(EE_WHITE);428 ee_set_color(EE_WHITE); 432 429 ee_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); 433 ee_ color(EE_CYAN);430 ee_set_color(EE_CYAN); 434 431 ee_putchar(x-2, y-3-i, '%'); 435 432 ee_putchar(x+3, y-3-i, '%'); 436 ee_ color(EE_BLUE);433 ee_set_color(EE_BLUE); 437 434 ee_putchar(x-3, y-3-i, ':'); 438 435 ee_putchar(x+4, y-3-i, ':'); … … 447 444 448 445 /* Lots of duplicate pixels, but we don't care */ 449 ee_ color(EE_BLUE);446 ee_set_color(EE_BLUE); 450 447 ee_draw_ellipse(x, y, r, r / 2, ':'); 451 448 ee_draw_ellipse(x, y, r + 1, r / 2, ':'); 452 449 ee_draw_ellipse(x, y, r + 2, r / 2, ':'); 453 ee_ color(EE_CYAN);450 ee_set_color(EE_CYAN); 454 451 ee_draw_ellipse(x, y, r + 2, r / 2 + 1, '%'); 455 452 ee_draw_ellipse(x, y, r + 3, r / 2 + 1, '%'); 456 ee_ color(EE_WHITE);453 ee_set_color(EE_WHITE); 457 454 ee_draw_ellipse(x, y, r + 3, r / 2 + 2, '#'); 458 455 ee_draw_ellipse(x, y, r + 4, r / 2 + 2, '#'); -
libcaca/trunk/test/demo.c
r151 r153 143 143 144 144 ee_clear(); 145 ee_ color(EE_WHITE);145 ee_set_color(EE_WHITE); 146 146 ee_draw_line(xo, yo, 1, yo, '.'); 147 147 ee_draw_line(1, yo, 1, 1, ':'); … … 179 179 180 180 /* Draw the sun */ 181 ee_ color(EE_YELLOW);181 ee_set_color(EE_YELLOW); 182 182 xo = ee_get_width() / 4; 183 183 yo = ee_get_height() / 4 + 5 * sin(0.03*i); … … 191 191 192 192 j = 15 + sin(0.03*i) * 8; 193 ee_ color(EE_WHITE);193 ee_set_color(EE_WHITE); 194 194 ee_fill_ellipse(xo, yo, j, j / 2, '#'); 195 ee_ color(EE_YELLOW);195 ee_set_color(EE_YELLOW); 196 196 ee_draw_ellipse(xo, yo, j, j / 2, '#'); 197 197 … … 209 209 y3 = ee_get_height() * 3 / 4 + cos(0.02*i) * 5; 210 210 211 ee_ color(EE_GREEN);211 ee_set_color(EE_GREEN); 212 212 ee_fill_triangle(xo, yo, x2, y2, x1, y1, '%'); 213 ee_ color(EE_YELLOW);213 ee_set_color(EE_YELLOW); 214 214 ee_draw_thin_triangle(xo, yo, x2, y2, x1, y1); 215 215 216 ee_ color(EE_RED);216 ee_set_color(EE_RED); 217 217 ee_fill_triangle(x1, y1, x2, y2, x3, y3, '#'); 218 ee_ color(EE_YELLOW);218 ee_set_color(EE_YELLOW); 219 219 ee_draw_thin_triangle(x1, y1, x2, y2, x3, y3); 220 220 221 ee_ color(EE_BLUE);221 ee_set_color(EE_BLUE); 222 222 ee_fill_triangle(xo, yo, x2, y2, x3, y3, '%'); 223 ee_ color(EE_YELLOW);223 ee_set_color(EE_YELLOW); 224 224 ee_draw_thin_triangle(xo, yo, x2, y2, x3, y3); 225 225 … … 234 234 y3 = ee_get_height() - 3; 235 235 236 ee_ color(EE_CYAN);236 ee_set_color(EE_CYAN); 237 237 ee_draw_thin_triangle(x1, y1, x2, y2, x3, y3); 238 238 … … 245 245 246 246 /* Draw a sprite on the pyramid */ 247 ee_draw_sprite(xo, yo, sprite );247 ee_draw_sprite(xo, yo, sprite, 0); 248 248 249 249 /* Draw a trail behind the foreground sprite */ … … 251 251 { 252 252 int delta = ee_rand(-5, 5); 253 ee_ color(ee_rand(1, 10));253 ee_set_color(ee_rand(1, 10)); 254 254 ee_putchar(ee_get_width() / 2 255 255 + cos(0.02*j) * (delta + ee_get_width() / 4), … … 262 262 ee_draw_sprite(ee_get_width() / 2 + cos(0.02*i) * ee_get_width() / 4, 263 263 ee_get_height() / 2 + sin(0.02*i) * ee_get_height() / 3, 264 sprite );264 sprite, 0); 265 265 266 266 ee_refresh(); … … 276 276 { 277 277 /* Putpixel */ 278 ee_ color(ee_rand(1, 10));278 ee_set_color(ee_rand(1, 10)); 279 279 ee_putchar(ee_rand(0, xmax), ee_rand(0, ymax), '#'); 280 280 } … … 299 299 } 300 300 301 ee_ color(ee_rand(1, 10));301 ee_set_color(ee_rand(1, 10)); 302 302 if(thin) 303 303 ee_draw_thin_line(x1, y1, x2, y2); … … 325 325 } 326 326 327 ee_ color(ee_rand(1, 10));327 ee_set_color(ee_rand(1, 10)); 328 328 ee_fill_box(x1, y1, x2, y2, '#'); 329 329 330 330 if(outline) 331 331 { 332 ee_ color(ee_rand(1, 10));332 ee_set_color(ee_rand(1, 10)); 333 333 ee_draw_thin_box(x1, y1, x2, y2); 334 334 } … … 358 358 } 359 359 360 ee_ color(ee_rand(1, 10));360 ee_set_color(ee_rand(1, 10)); 361 361 ee_fill_ellipse(x, y, a, b, '#'); 362 362 363 363 if(outline) 364 364 { 365 ee_ color(ee_rand(1, 10));365 ee_set_color(ee_rand(1, 10)); 366 366 ee_draw_thin_ellipse(x, y, a, b); 367 367 } … … 390 390 } 391 391 392 ee_ color(ee_rand(1, 10));392 ee_set_color(ee_rand(1, 10)); 393 393 ee_fill_triangle(x1, y1, x2, y2, x3, y3, '#'); 394 394 395 395 if(outline) 396 396 { 397 ee_ color(ee_rand(1, 10));397 ee_set_color(ee_rand(1, 10)); 398 398 ee_draw_thin_triangle(x1, y1, x2, y2, x3, y3); 399 399 } … … 405 405 { 406 406 ee_draw_sprite(ee_rand(0, ee_get_width() - 1), 407 ee_rand(0, ee_get_height() - 1), sprite );408 ee_refresh(); 409 } 410 407 ee_rand(0, ee_get_height() - 1), sprite, 0); 408 ee_refresh(); 409 } 410 -
libcaca/trunk/test/spritedit.c
r145 r153 23 23 #include "config.h" 24 24 25 #include <math.h> 26 #include <string.h> 25 #include <stdio.h> 27 26 28 27 #include "ee.h" … … 31 30 { 32 31 int quit = 0; 32 struct ee_sprite *sprite; 33 int frame = 0; 34 35 if(argc < 2) 36 { 37 fprintf(stderr, "%s: missing argument (filename).\n", argv[0]); 38 return 1; 39 } 33 40 34 41 if(ee_init()) 42 return 1; 43 44 sprite = ee_load_sprite(argv[1]); 45 46 if(!sprite) 35 47 { 48 ee_end(); 49 fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]); 36 50 return 1; 37 51 } … … 40 54 while(!quit) 41 55 { 42 char key = ee_get_key(); 43 switch(key) 56 int xa, ya, xb, yb; 57 char buf[BUFSIZ]; 58 59 switch(ee_get_key()) 44 60 { 45 61 case 0: … … 48 64 quit = 1; 49 65 break; 66 case '-': 67 if(frame > 0) 68 frame--; 69 break; 70 case '+': 71 if(frame < ee_get_sprite_frames(sprite) - 1) 72 frame++; 73 break; 50 74 } 75 76 ee_clear(); 77 78 ee_set_color(EE_WHITE); 79 ee_draw_thin_box(0, 0, ee_get_width() - 1, ee_get_height() - 1); 80 81 ee_putstr(3, 0, "[ Sprite editor for libee ]"); 82 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); 87 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, '+'); 92 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); 103 104 /* Free sprite */ 105 ee_draw_sprite(20, 10, sprite, frame); 106 107 ee_refresh(); 51 108 } 52 109
Note: See TracChangeset
for help on using the changeset viewer.