Browse Source

* Bring the tree back in sync with the new libcaca API.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@1057 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 18 years ago
parent
commit
aa700f6caf
17 changed files with 311 additions and 243 deletions
  1. +4
    -0
      data/alien.ans
  2. +8
    -0
      data/roflcopter.ans
  3. +3
    -0
      data/ship.ans
  4. +21
    -9
      src/aliens.c
  5. +14
    -8
      src/bonus.c
  6. +20
    -20
      src/box.c
  7. +6
    -4
      src/ceo.c
  8. +3
    -3
      src/common.h
  9. +27
    -21
      src/explosions.c
  10. +34
    -20
      src/intro.c
  11. +16
    -18
      src/main.c
  12. +18
    -18
      src/overlay.c
  13. +8
    -3
      src/player.c
  14. +2
    -2
      src/starfield.c
  15. +6
    -6
      src/ttyvaders.c
  16. +8
    -8
      src/tunnel.c
  17. +113
    -103
      src/weapons.c

+ 4
- 0
data/alien.ans View File

@@ -0,0 +1,4 @@
____
/ \
(|_()|_)
\____/

+ 8
- 0
data/roflcopter.ans View File

@@ -0,0 +1,8 @@
ROFL:ROFL:LOL:ROFL:ROFL
^
L /--------
O === []\
L \ \
\_______ ]
I I
----------/

+ 3
- 0
data/ship.ans View File

@@ -0,0 +1,3 @@
_ rofl|rofl
\\___/v\
\______)

+ 21
- 9
src/aliens.c View File

@@ -26,12 +26,13 @@


#include "common.h" #include "common.h"


struct cucul_sprite *foo_sprite;
struct cucul_sprite *bar_sprite;
struct cucul_sprite *baz_sprite;
cucul_canvas_t *foo_sprite;
cucul_canvas_t *bar_sprite;
cucul_canvas_t *baz_sprite;


void init_aliens(game *g, aliens *al) void init_aliens(game *g, aliens *al)
{ {
cucul_buffer_t *b;
int i; int i;


for(i = 0; i < ALIENS; i++) for(i = 0; i < ALIENS; i++)
@@ -39,9 +40,17 @@ void init_aliens(game *g, aliens *al)
al->type[i] = ALIEN_NONE; al->type[i] = ALIEN_NONE;
} }


foo_sprite = cucul_load_sprite(g->qq, "data/foofight.txt");
bar_sprite = cucul_load_sprite(g->qq, "data/barfight.txt");
baz_sprite = cucul_load_sprite(g->qq, "data/bazfight.txt");
b = cucul_load_file("data/foofight.caca");
foo_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

b = cucul_load_file("data/barfight.caca");
bar_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

b = cucul_load_file("data/bazfight.caca");
baz_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);
} }


void draw_aliens(game *g, aliens *al) void draw_aliens(game *g, aliens *al)
@@ -53,13 +62,16 @@ void draw_aliens(game *g, aliens *al)
switch(al->type[i]) switch(al->type[i])
{ {
case ALIEN_FOO: case ALIEN_FOO:
cucul_draw_sprite(g->qq, al->x[i], al->y[i], foo_sprite, al->img[i] % 5);
cucul_set_canvas_frame(foo_sprite, al->img[i] % 5);
cucul_blit(g->cv, al->x[i], al->y[i], foo_sprite, NULL);
break; break;
case ALIEN_BAR: case ALIEN_BAR:
cucul_draw_sprite(g->qq, al->x[i], al->y[i], bar_sprite, al->img[i] % 2);
cucul_set_canvas_frame(bar_sprite, al->img[i] % 2);
cucul_blit(g->cv, al->x[i], al->y[i], bar_sprite, NULL);
break; break;
case ALIEN_BAZ: case ALIEN_BAZ:
cucul_draw_sprite(g->qq, al->x[i], al->y[i], baz_sprite, al->img[i] % 4);
cucul_set_canvas_frame(baz_sprite, al->img[i] % 4);
cucul_blit(g->cv, al->x[i], al->y[i], baz_sprite, NULL);
break; break;
case ALIEN_NONE: case ALIEN_NONE:
break; break;


+ 14
- 8
src/bonus.c View File

@@ -26,11 +26,12 @@


#include "common.h" #include "common.h"


struct cucul_sprite *heart_sprite;
struct cucul_sprite *gem_sprite;
cucul_canvas_t *heart_sprite;
cucul_canvas_t *gem_sprite;


void init_bonus(game *g, bonus *bo) void init_bonus(game *g, bonus *bo)
{ {
cucul_buffer_t *b;
int i; int i;


for(i = 0; i < BONUS; i++) for(i = 0; i < BONUS; i++)
@@ -38,8 +39,13 @@ void init_bonus(game *g, bonus *bo)
bo->type[i] = BONUS_NONE; bo->type[i] = BONUS_NONE;
} }


heart_sprite = cucul_load_sprite(g->qq, "data/bonheart.txt");
gem_sprite = cucul_load_sprite(g->qq, "data/bongem.txt");
b = cucul_load_file("data/bonheart.caca");
heart_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

b = cucul_load_file("data/bongem.caca");
gem_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);
} }


void draw_bonus(game *g, bonus *bo) void draw_bonus(game *g, bonus *bo)
@@ -51,12 +57,12 @@ void draw_bonus(game *g, bonus *bo)
switch(bo->type[i]) switch(bo->type[i])
{ {
case BONUS_GREEN: case BONUS_GREEN:
cucul_draw_sprite(g->qq, bo->x[i], bo->y[i], gem_sprite,
(bo->n[i]/2 % 3) ? 0 : 1);
cucul_set_canvas_frame(gem_sprite, (bo->n[i]/2 % 3) ? 0 : 1);
cucul_blit(g->cv, bo->x[i], bo->y[i], gem_sprite, NULL);
break; break;
case BONUS_LIFE: case BONUS_LIFE:
cucul_draw_sprite(g->qq, bo->x[i], bo->y[i], heart_sprite,
(bo->n[i] % 3) ? 0 : 1);
cucul_set_canvas_frame(heart_sprite, (bo->n[i] % 3) ? 0 : 1);
cucul_blit(g->cv, bo->x[i], bo->y[i], heart_sprite, NULL);
break; break;
case BONUS_NONE: case BONUS_NONE:
break; break;


+ 20
- 20
src/box.c View File

@@ -45,37 +45,37 @@ void draw_box(game *g, box *b)
{ {
int j, frame; int j, frame;


cucul_set_color(g->qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);


/* Draw the thin horizontal line */ /* Draw the thin horizontal line */
if(b->frame < 8) if(b->frame < 8)
{ {
cucul_draw_line(g->qq, b->x - b->w * b->frame / 16, b->y,
b->x + b->w * b->frame / 16 - 1, b->y, 'X');
cucul_draw_line(g->cv, b->x - b->w * b->frame / 16, b->y,
b->x + b->w * b->frame / 16 - 1, b->y, "X");
return; return;
} }


/* Draw the frame */ /* Draw the frame */
frame = b->frame < 12 ? b->frame : 12; frame = b->frame < 12 ? b->frame : 12;


cucul_draw_line(g->qq, b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 'X');
cucul_draw_line(g->qq, b->x - b->w / 2, b->y + b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, 'X');
cucul_draw_line(g->cv, b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, "X");
cucul_draw_line(g->cv, b->x - b->w / 2, b->y + b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, "X");


cucul_draw_line(g->qq, b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, 'X');
cucul_draw_line(g->qq, b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X');
cucul_draw_line(g->cv, b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, "X");
cucul_draw_line(g->cv, b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8,
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, "X");


cucul_set_color(g->qq, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK);


for(j = b->y - b->h * (frame - 8) / 8 + 1; for(j = b->y - b->h * (frame - 8) / 8 + 1;
j < b->y + b->h * (frame - 8) / 8; j < b->y + b->h * (frame - 8) / 8;
j++) j++)
{ {
cucul_draw_line(g->qq, b->x - b->w / 2 + 1, j,
b->x + b->w / 2 - 2, j, 'X');
cucul_draw_line(g->cv, b->x - b->w / 2 + 1, j,
b->x + b->w / 2 - 2, j, "X");
} }


if(b->frame < 12) if(b->frame < 12)
@@ -84,18 +84,18 @@ void draw_box(game *g, box *b)
} }


/* Draw the text inside the frame */ /* Draw the text inside the frame */
cucul_set_color(g->qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);


/* FIXME: use a font */ /* FIXME: use a font */
cucul_putstr(g->qq, b->x - b->w / 2 + 12, b->y - b->h / 2 + 2,
cucul_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 2,
"XXXX. .XXXX X X .XXXX .XXXX XXXX."); "XXXX. .XXXX X X .XXXX .XXXX XXXX.");
cucul_putstr(g->qq, b->x - b->w / 2 + 12, b->y - b->h / 2 + 3,
cucul_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 3,
"X `X X' X X X X' X' X `X"); "X `X X' X X X X' X' X `X");
cucul_putstr(g->qq, b->x - b->w / 2 + 12, b->y - b->h / 2 + 4,
cucul_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 4,
"XXXX' XXXXX X X `XXX XXXX X X"); "XXXX' XXXXX X X `XXX XXXX X X");
cucul_putstr(g->qq, b->x - b->w / 2 + 12, b->y - b->h / 2 + 5,
cucul_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 5,
"X' X' `X X. ,X `X X' X ,X"); "X' X' `X X. ,X `X X' X ,X");
cucul_putstr(g->qq, b->x - b->w / 2 + 12, b->y - b->h / 2 + 6,
cucul_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 6,
"X X X `XXXX XXXX' `XXXX XXXX'"); "X X X `XXXX XXXX' `XXXX XXXX'");
} }




+ 6
- 4
src/ceo.c View File

@@ -33,17 +33,19 @@ void ceo_alert(game *g)


while(!end) while(!end)
{ {
cucul_clear(g->qq);
caca_event_t ev;


if(caca_get_event(g->kk, CACA_EVENT_KEY_PRESS)
== (CACA_EVENT_KEY_PRESS | '\t'))
cucul_clear_canvas(g->cv);

if(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0)
&& ev.data.key.ch == '\t')
{ {
end = 1; end = 1;
} }


fprintf(stderr, "foo\n"); fprintf(stderr, "foo\n");


caca_display(g->qq);
caca_refresh_display(g->cv);


usleep(40000); usleep(40000);
} }


+ 3
- 3
src/common.h View File

@@ -42,7 +42,7 @@
/* /*
* Graphics primitives * Graphics primitives
*/ */
#include "caca.h"
#include <caca.h>


/* /*
* Useful macros * Useful macros
@@ -132,8 +132,8 @@ typedef struct
{ {
int w, h; int w, h;


cucul_t *qq;
caca_t *kk;
cucul_canvas_t *cv;
caca_display_t *dp;


starfield *sf; starfield *sf;
weapons *wp; weapons *wp;


+ 27
- 21
src/explosions.c View File

@@ -26,11 +26,12 @@


#include "common.h" #include "common.h"


struct cucul_sprite *medium_sprite;
struct cucul_sprite *small_sprite;
cucul_canvas_t *medium_sprite;
cucul_canvas_t *small_sprite;


void init_explosions(game *g, explosions *ex) void init_explosions(game *g, explosions *ex)
{ {
cucul_buffer_t *b;
int i; int i;


for(i = 0; i < EXPLOSIONS; i++) for(i = 0; i < EXPLOSIONS; i++)
@@ -38,8 +39,13 @@ void init_explosions(game *g, explosions *ex)
ex->type[i] = EXPLOSION_NONE; ex->type[i] = EXPLOSION_NONE;
} }


medium_sprite = cucul_load_sprite(g->qq, "data/xplmed.txt");
small_sprite = cucul_load_sprite(g->qq, "data/xplsmall.txt");
b = cucul_load_file("data/xplmed.caca");
medium_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

b = cucul_load_file("data/xplsmall.caca");
small_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);
} }


void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type) void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type)
@@ -76,39 +82,39 @@ void draw_explosions(game *g, explosions *ex)
for(i = 0; i < EXPLOSIONS; i++) for(i = 0; i < EXPLOSIONS; i++)
{ {
#if 0 #if 0
cucul_set_fg_color(g->qq, CACA_COLOR_GREEN);
cucul_goto(g->qq, ex->x[i] + 3, ex->y[i]);
cucul_set_fg_color(g->cv, CACA_COLOR_GREEN);
cucul_goto(g->cv, ex->x[i] + 3, ex->y[i]);
switch(cucul_rand(0,2)) switch(cucul_rand(0,2))
{ {
case 0: case 0:
cucul_putchar(g->qq, 'p');
cucul_putchar(g->qq, 'i');
cucul_putchar(g->qq, 'f');
cucul_putchar(g->cv, 'p');
cucul_putchar(g->cv, 'i');
cucul_putchar(g->cv, 'f');
break; break;
case 1: case 1:
cucul_putchar(g->qq, 'p');
cucul_putchar(g->qq, 'a');
cucul_putchar(g->qq, 'f');
cucul_putchar(g->cv, 'p');
cucul_putchar(g->cv, 'a');
cucul_putchar(g->cv, 'f');
break; break;
case 2: case 2:
cucul_putchar(g->qq, 'p');
cucul_putchar(g->qq, 'o');
cucul_putchar(g->qq, 'u');
cucul_putchar(g->qq, 'f');
cucul_putchar(g->cv, 'p');
cucul_putchar(g->cv, 'o');
cucul_putchar(g->cv, 'u');
cucul_putchar(g->cv, 'f');
break; break;
} }
cucul_putchar(g->qq, '!');
cucul_putchar(g->cv, '!');
#endif #endif


switch(ex->type[i]) switch(ex->type[i])
{ {
case EXPLOSION_MEDIUM: case EXPLOSION_MEDIUM:
cucul_draw_sprite(g->qq, ex->x[i], ex->y[i], medium_sprite,
10 - ex->n[i]);
cucul_set_canvas_frame(medium_sprite, 10 - ex->n[i]);
cucul_blit(g->cv, ex->x[i], ex->y[i], medium_sprite, NULL);
break; break;
case EXPLOSION_SMALL: case EXPLOSION_SMALL:
cucul_draw_sprite(g->qq, ex->x[i], ex->y[i], small_sprite,
6 - ex->n[i]);
cucul_set_canvas_frame(small_sprite, 6 - ex->n[i]);
cucul_blit(g->cv, ex->x[i], ex->y[i], small_sprite, NULL);
break; break;
case EXPLOSION_NONE: case EXPLOSION_NONE:
break; break;


+ 34
- 20
src/intro.c View File

@@ -30,27 +30,40 @@


void intro(game *g) void intro(game *g)
{ {
struct cucul_sprite *foo_sprite = cucul_load_sprite(g->qq, "data/foofight.txt");
struct cucul_sprite *bar_sprite = cucul_load_sprite(g->qq, "data/barfight.txt");
struct cucul_sprite *baz_sprite = cucul_load_sprite(g->qq, "data/bazfight.txt");

caca_event_t ev;
cucul_canvas_t *foo_sprite;
cucul_canvas_t *bar_sprite;
cucul_canvas_t *baz_sprite;
cucul_buffer_t *b;
int frame = 0; int frame = 0;


while(caca_get_event(g->kk, CACA_EVENT_KEY_PRESS) == 0)
b = cucul_load_file("data/foofight.caca");
foo_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

b = cucul_load_file("data/barfight.caca");
bar_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

b = cucul_load_file("data/bazfight.caca");
baz_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

while(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0) == 0)
{ {
int i, xo, yo, x[5], y[5]; int i, xo, yo, x[5], y[5];


frame++; frame++;


cucul_clear(g->qq);
cucul_clear_canvas(g->cv);


xo = cucul_get_width(g->qq) / 2;
yo = cucul_get_height(g->qq) / 2;
xo = cucul_get_canvas_width(g->cv) / 2;
yo = cucul_get_canvas_height(g->cv) / 2;


cucul_set_color(g->qq, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
cucul_fill_ellipse(g->qq, xo, yo, 16, 8, '#');
cucul_set_color(g->qq, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
cucul_draw_thin_ellipse(g->qq, xo, yo, 16, 8);
cucul_set_color(g->cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
cucul_fill_ellipse(g->cv, xo, yo, 16, 8, "#");
cucul_set_color(g->cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
cucul_draw_thin_ellipse(g->cv, xo, yo, 16, 8);


for(i = 0; i < 4; i ++) for(i = 0; i < 4; i ++)
{ {
@@ -60,16 +73,17 @@ void intro(game *g)
x[4] = x[0]; x[4] = x[0];
y[4] = y[0]; y[4] = y[0];


cucul_set_color(g->qq, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK);
cucul_fill_triangle(g->qq, x[0], y[0], x[1], y[1], x[2], y[2], ' ');
cucul_fill_triangle(g->qq, x[0], y[0], x[3], y[3], x[2], y[2], ' ');
cucul_draw_line(g->qq, x[0], y[0], x[2], y[2], ' ');
cucul_set_color(g->qq, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
cucul_draw_thin_polyline(g->qq, x, y, 4);
cucul_set_color(g->cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK);
cucul_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], " ");
cucul_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], " ");
cucul_draw_line(g->cv, x[0], y[0], x[2], y[2], " ");
cucul_set_color(g->cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
cucul_draw_thin_polyline(g->cv, x, y, 4);


cucul_draw_sprite(g->qq, xo, yo, foo_sprite, frame % 5);
cucul_set_canvas_frame(foo_sprite, frame % 5);
cucul_blit(g->cv, xo, yo, foo_sprite, NULL);


caca_display(g->kk);
caca_refresh_display(g->dp);


usleep(40000); usleep(40000);
} }


+ 16
- 18
src/main.c View File

@@ -33,7 +33,7 @@


static void start_game (game *); static void start_game (game *);


int main (int argc, char **argv)
int _main (int argc, char **argv)
{ {
game *g = malloc(sizeof(game)); game *g = malloc(sizeof(game));
if(g == NULL) if(g == NULL)
@@ -41,19 +41,19 @@ int main (int argc, char **argv)


srand(time(NULL)); srand(time(NULL));


g->qq = cucul_init();
if(!g->qq)
g->cv = cucul_create_canvas(0, 0);
if(!g->cv)
return 1; return 1;


g->kk = caca_attach(g->qq);
if(!g->kk)
g->dp = caca_create_display(g->cv);
if(!g->dp)
return 1; return 1;


caca_set_delay(g->kk, 40000);
caca_set_display_time(g->dp, 40000);


/* Initialize our program */ /* Initialize our program */
g->w = cucul_get_width(g->qq);
g->h = cucul_get_height(g->qq);
g->w = cucul_get_canvas_width(g->cv);
g->h = cucul_get_canvas_height(g->cv);


intro(g); intro(g);


@@ -61,8 +61,8 @@ intro(g);
start_game(g); start_game(g);


/* Clean up */ /* Clean up */
caca_detach(g->kk);
cucul_end(g->qq);
caca_free_display(g->dp);
cucul_free_canvas(g->cv);


return 0; return 0;
} }
@@ -102,13 +102,11 @@ static void start_game (game *g)


while(!quit) while(!quit)
{ {
int event, key;
caca_event_t ev;


while((event = caca_get_event(g->kk, CACA_EVENT_KEY_PRESS)))
while(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0))
{ {
key = event & 0xffffff;

switch(key)
switch(ev.data.key.ch)
{ {
case 'q': case 'q':
quit = 1; quit = 1;
@@ -138,7 +136,7 @@ static void start_game (game *g)
break; break;
} }


switch(key)
switch(ev.data.key.ch)
{ {
case 'h': case 'h':
g->p->vx = -2; g->p->vx = -2;
@@ -237,7 +235,7 @@ static void start_game (game *g)
} }


/* Clear screen */ /* Clear screen */
cucul_clear(g->qq);
cucul_clear_canvas(g->cv);


/* Print starfield, tunnel, aliens, player and explosions */ /* Print starfield, tunnel, aliens, player and explosions */
draw_starfield(g, g->sf); draw_starfield(g, g->sf);
@@ -257,7 +255,7 @@ static void start_game (game *g)
} }


/* Refresh */ /* Refresh */
caca_display(g->kk);
caca_refresh_display(g->dp);


purcompteur++; purcompteur++;
} }


+ 18
- 18
src/overlay.c View File

@@ -32,50 +32,50 @@ void draw_status(game *g)
static char dashes30[] = "=============================="; static char dashes30[] = "==============================";


/* Draw life jauge */ /* Draw life jauge */
cucul_set_color(g->qq, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, 4, 1, dots30);
cucul_set_color(g->cv, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, 4, 1, dots30);


if(g->p->life > MAX_LIFE * 7 / 10) if(g->p->life > MAX_LIFE * 7 / 10)
{ {
cucul_set_color(g->qq, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
} }
else if(g->p->life > MAX_LIFE * 3 / 10) else if(g->p->life > MAX_LIFE * 3 / 10)
{ {
cucul_set_color(g->qq, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
} }
else else
{ {
cucul_set_color(g->qq, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
} }


cucul_putstr(g->qq, 4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);
cucul_putstr(g->cv, 4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);


cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, 1, 1, "L |");
cucul_putstr(g->qq, 34, 1, "|");
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, 1, 1, "L |");
cucul_putstr(g->cv, 34, 1, "|");


/* Draw weapon jauge */ /* Draw weapon jauge */
cucul_set_color(g->qq, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, 42, 1, dots30 + 10);
cucul_set_color(g->cv, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, 42, 1, dots30 + 10);


if(g->p->special > MAX_SPECIAL * 9 / 10) if(g->p->special > MAX_SPECIAL * 9 / 10)
{ {
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
} }
else if(g->p->special > MAX_SPECIAL * 3 / 10) else if(g->p->special > MAX_SPECIAL * 3 / 10)
{ {
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
} }
else else
{ {
cucul_set_color(g->qq, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
} }


cucul_putstr(g->qq, 42, 1, dashes30 + 10
cucul_putstr(g->cv, 42, 1, dashes30 + 10
+ (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL);


cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, 39, 1, "S |");
cucul_putstr(g->qq, 62, 1, "|");
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, 39, 1, "S |");
cucul_putstr(g->cv, 62, 1, "|");
} }



+ 8
- 3
src/player.c View File

@@ -26,11 +26,13 @@


#include "common.h" #include "common.h"


struct cucul_sprite *ship_sprite;
cucul_canvas_t *ship_sprite;


/* Init tunnel */ /* Init tunnel */
player * create_player(game *g) player * create_player(game *g)
{ {
cucul_buffer_t *b;

player *p = malloc(sizeof(player)); player *p = malloc(sizeof(player));
if(p == NULL) if(p == NULL)
exit(1); exit(1);
@@ -44,7 +46,9 @@ player * create_player(game *g)
p->life = MAX_LIFE; p->life = MAX_LIFE;
p->dead = 0; p->dead = 0;


ship_sprite = cucul_load_sprite(g->qq, "data/ship.txt");
b = cucul_load_file("data/ship.caca");
ship_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);


return p; return p;
} }
@@ -59,7 +63,8 @@ void draw_player(game *g, player *p)
if(p->dead) if(p->dead)
return; return;


cucul_draw_sprite(g->qq, p->x, p->y, ship_sprite, 0);
cucul_set_canvas_frame(ship_sprite, 0);
cucul_blit(g->cv, p->x, p->y, ship_sprite, NULL);
} }


void update_player(game *g, player *p) void update_player(game *g, player *p)


+ 2
- 2
src/starfield.c View File

@@ -55,8 +55,8 @@ void draw_starfield(game *g, starfield *s)
{ {
if(s[i].x >= 0) if(s[i].x >= 0)
{ {
cucul_set_color(g->qq, s[i].c, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, s[i].x, s[i].y, s[i].ch);
cucul_set_color(g->cv, s[i].c, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, s[i].x, s[i].y, s[i].ch);
} }
} }
} }


+ 6
- 6
src/ttyvaders.c View File

@@ -130,19 +130,19 @@ static void display_ground(void)
/* Draw the ground */ /* Draw the ground */
j = h - ground[i]; j = h - ground[i];
cucul_set_color(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTBLUE); cucul_set_color(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTBLUE);
if(i >= 4 && ground[i] == ground[i - 3]
&& ground[i] != ground[i - 4])
if(i >= 4 && ground[i] == ground[i - 6]
&& ground[i] != ground[i - 7])
{ {
cucul_putstr(cv, i - 3, j - 2, "||\\");
cucul_putstr(cv, i - 3, j - 1, "o--o");
cucul_putstr(cv, i - 3, j - 2, "Omm");
cucul_putstr(cv, i - 6, j - 1, "(/)-(/)");
} }
cucul_set_color(cv, CUCUL_COLOR_RED, CUCUL_COLOR_GREEN); cucul_set_color(cv, CUCUL_COLOR_RED, CUCUL_COLOR_GREEN);
if(ground[i + 1] > ground[i]) if(ground[i + 1] > ground[i])
cucul_putchar(cv, i, j++, 0x259f);
cucul_putchar(cv, i, j++, 0x2588); // UTF-8: 0x259f
else if(ground[i + 1] < ground[i]) else if(ground[i + 1] < ground[i])
{ {
j++; j++;
cucul_putchar(cv, i, j++, 0x2599);
cucul_putchar(cv, i, j++, 0x2588); // UTF-8: 0x2599
} }
else else
cucul_putchar(cv, i, j++, 0x2584); cucul_putchar(cv, i, j++, 0x2584);


+ 8
- 8
src/tunnel.c View File

@@ -77,7 +77,7 @@ void draw_tunnel(game *g, tunnel *t)
int i, j; int i, j;
char c; char c;


cucul_set_color(g->qq, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
cucul_set_color(g->cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);


/* Left border */ /* Left border */
for(i = 0; i < g->h ; i++) for(i = 0; i < g->h ; i++)
@@ -90,11 +90,11 @@ void draw_tunnel(game *g, tunnel *t)
else else
c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<'; c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<';


cucul_putchar(g->qq, t->left[i] + 1, i, c);
cucul_putchar(g->cv, t->left[i] + 1, i, c);


if(i + 1 < g->h) if(i + 1 < g->h)
for(j = 1; j < t->left[i+1] - t->left[i]; j++) for(j = 1; j < t->left[i+1] - t->left[i]; j++)
cucul_putchar(g->qq, t->left[i] + j + 1, i, '_');
cucul_putchar(g->cv, t->left[i] + j + 1, i, '_');
} }


/* Right border */ /* Right border */
@@ -110,22 +110,22 @@ void draw_tunnel(game *g, tunnel *t)


if(i + 1 < g->h) if(i + 1 < g->h)
for(j = 1; j < t->right[i] - t->right[i+1]; j++) for(j = 1; j < t->right[i] - t->right[i+1]; j++)
cucul_putchar(g->qq, t->right[i+1] + j - 1, i, '_');
cucul_putchar(g->cv, t->right[i+1] + j - 1, i, '_');


cucul_putchar(g->qq, t->right[i] - 1, i, c);
cucul_putchar(g->cv, t->right[i] - 1, i, c);
} }


cucul_set_color(g->qq, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_RED);
cucul_set_color(g->cv, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_RED);


/* Left concrete */ /* Left concrete */
for(i = 0; i < g->h ; i++) for(i = 0; i < g->h ; i++)
for(j = 0 ; j <= t->left[i]; j++) for(j = 0 ; j <= t->left[i]; j++)
cucul_putchar(g->qq, j, i, '#');
cucul_putchar(g->cv, j, i, '#');


/* Right concrete */ /* Right concrete */
for(i = 0; i < g->h ; i++) for(i = 0; i < g->h ; i++)
for(j = t->right[i] ; j < g->w ; j++) for(j = t->right[i] ; j < g->w ; j++)
cucul_putchar(g->qq, j, i, '#');
cucul_putchar(g->cv, j, i, '#');
} }


void update_tunnel(game *g, tunnel *t) void update_tunnel(game *g, tunnel *t)


+ 113
- 103
src/weapons.c View File

@@ -23,6 +23,7 @@
#include "config.h" #include "config.h"


#include <stdlib.h> #include <stdlib.h>
#include <math.h>


#include "common.h" #include "common.h"


@@ -31,11 +32,12 @@ static void draw_nuke(game *g, int x, int y, int frame);
static void draw_beam(game *g, int x, int y, int frame); static void draw_beam(game *g, int x, int y, int frame);
static void draw_fragbomb(game *g, int x, int y, int frame); static void draw_fragbomb(game *g, int x, int y, int frame);


struct cucul_sprite *bomb_sprite;
struct cucul_sprite *fragbomb_sprite;
cucul_canvas_t *bomb_sprite;
cucul_canvas_t *fragbomb_sprite;


void init_weapons(game *g, weapons *wp) void init_weapons(game *g, weapons *wp)
{ {
cucul_buffer_t *b;
int i; int i;


for(i = 0; i < WEAPONS; i++) for(i = 0; i < WEAPONS; i++)
@@ -43,8 +45,13 @@ void init_weapons(game *g, weapons *wp)
wp->type[i] = WEAPON_NONE; wp->type[i] = WEAPON_NONE;
} }


bomb_sprite = cucul_load_sprite(g->qq, "data/wpnbomb.txt");
fragbomb_sprite = cucul_load_sprite(g->qq, "data/wpnfrag.txt");
b = cucul_load_file("data/wpnbomb.caca");
bomb_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);

b = cucul_load_file("data/wpnfrag.caca");
bomb_sprite = cucul_import_canvas(b, "");
cucul_free_buffer(b);
} }


void draw_weapons(game *g, weapons *wp) void draw_weapons(game *g, weapons *wp)
@@ -56,25 +63,25 @@ void draw_weapons(game *g, weapons *wp)
switch(wp->type[i]) switch(wp->type[i])
{ {
case WEAPON_LASER: case WEAPON_LASER:
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, wp->x[i] >> 4, wp->y[i] >> 4, '|');
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '|');
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
break; break;
case WEAPON_SEEKER: case WEAPON_SEEKER:
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
cucul_putchar(g->qq, wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, wp->x[i] >> 4, wp->y[i] >> 4, '@');
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
cucul_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '@');
break; break;
case WEAPON_BOMB: case WEAPON_BOMB:
cucul_set_color(g->qq, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
cucul_putchar(g->qq, (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
cucul_putchar(g->qq, (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');
cucul_putchar(g->qq, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
cucul_putchar(g->qq, wp->x2[i] >> 4, wp->y2[i] >> 4, '.');
cucul_set_color(g->cv, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
cucul_putchar(g->cv, (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
cucul_putchar(g->cv, (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');
cucul_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
cucul_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, '.');
draw_bomb(g, wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]); draw_bomb(g, wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]);
break; break;
case WEAPON_FRAGBOMB: case WEAPON_FRAGBOMB:
@@ -170,7 +177,7 @@ void update_weapons(game *g, weapons *wp)
/* Normalize direction */ /* Normalize direction */
if(dx | dy) if(dx | dy)
{ {
unsigned int norm = cucul_sqrt(dx * dx + 4 * dy * dy);
unsigned int norm = (int)sqrt((double)(dx * dx + 4 * dy * dy));
dx = dx * 32 / norm; dx = dx * 32 / norm;
dy = dy * 32 / norm; dy = dy * 32 / norm;
} }
@@ -182,7 +189,7 @@ void update_weapons(game *g, weapons *wp)
/* Normalize speed */ /* Normalize speed */
if(dx | dy) if(dx | dy)
{ {
unsigned int norm = cucul_sqrt(dx * dx + 4 * dy * dy);
unsigned int norm = (int)sqrt((double)(dx * dx + 4 * dy * dy));
wp->vx[i] = dx * 32 / norm; wp->vx[i] = dx * 32 / norm;
wp->vy[i] = dy * 32 / norm; wp->vy[i] = dy * 32 / norm;
} }
@@ -334,16 +341,19 @@ static void draw_bomb(game *g, int x, int y, int vx, int vy)
} }
} }


cucul_draw_sprite(g->qq, x, y, bomb_sprite, frame);
cucul_set_canvas_frame(bomb_sprite, frame);
cucul_blit(g->cv, x, y, bomb_sprite, NULL);
} }


static void draw_fragbomb(game *g, int x, int y, int frame) static void draw_fragbomb(game *g, int x, int y, int frame)
{ {
/* Draw the head */ /* Draw the head */
cucul_draw_sprite(g->qq, x, y, fragbomb_sprite, frame & 1);
cucul_set_canvas_frame(fragbomb_sprite, frame & 1);
cucul_blit(g->cv, x, y, fragbomb_sprite, NULL);


/* Draw the tail */ /* Draw the tail */
cucul_draw_sprite(g->qq, x, y, fragbomb_sprite, 2 + (frame % 4));
cucul_set_canvas_frame(fragbomb_sprite, 2 + (frame % 4));
cucul_blit(g->cv, x, y, fragbomb_sprite, NULL);
} }


static void draw_beam(game *g, int x, int y, int frame) static void draw_beam(game *g, int x, int y, int frame)
@@ -354,86 +364,86 @@ static void draw_beam(game *g, int x, int y, int frame)
switch(frame) switch(frame)
{ {
case 24: case 24:
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x, y-3, "__");
cucul_putchar(g->qq, x-1, y-2, '\'');
cucul_putchar(g->qq, x+2, y-2, '`');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x, y-3, "__");
cucul_putchar(g->cv, x-1, y-2, '\'');
cucul_putchar(g->cv, x+2, y-2, '`');
break; break;
case 23: case 23:
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x, y-3, "__");
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x-2, y-2, "-'");
cucul_putstr(g->qq, x+2, y-2, "`-");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x, y-3, "__");
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x-2, y-2, "-'");
cucul_putstr(g->cv, x+2, y-2, "`-");
break; break;
case 22: case 22:
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x, y-3, "__");
cucul_putchar(g->qq, x-1, y-2, '\'');
cucul_putchar(g->qq, x+2, y-2, '`');
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x-3, y-2, ",-");
cucul_putstr(g->qq, x+3, y-2, "-.");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x, y-3, "__");
cucul_putchar(g->cv, x-1, y-2, '\'');
cucul_putchar(g->cv, x+2, y-2, '`');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x-3, y-2, ",-");
cucul_putstr(g->cv, x+3, y-2, "-.");
break; break;
case 21: case 21:
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x-1, y-3, "____");
cucul_putchar(g->qq, x-2, y-2, '\'');
cucul_putchar(g->qq, x+3, y-2, '`');
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x-4, y-2, ",-");
cucul_putstr(g->qq, x+4, y-2, "-.");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x-1, y-3, "____");
cucul_putchar(g->cv, x-2, y-2, '\'');
cucul_putchar(g->cv, x+3, y-2, '`');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x-4, y-2, ",-");
cucul_putstr(g->cv, x+4, y-2, "-.");
break; break;
case 20: case 20:
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x, y-3, "%%");
cucul_putchar(g->qq, x-4, y-2, ',');
cucul_putchar(g->qq, x+5, y-2, '.');
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, x-1, y-3, ':');
cucul_putchar(g->qq, x+2, y-3, ':');
cucul_putstr(g->qq, x-3, y-2, "-'");
cucul_putstr(g->qq, x+3, y-2, "`-");
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x, y-3, "%%");
cucul_putchar(g->cv, x-4, y-2, ',');
cucul_putchar(g->cv, x+5, y-2, '.');
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, x-1, y-3, ':');
cucul_putchar(g->cv, x+2, y-3, ':');
cucul_putstr(g->cv, x-3, y-2, "-'");
cucul_putstr(g->cv, x+3, y-2, "`-");
break; break;
case 19: case 19:
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x, y-4, "%%");
cucul_putstr(g->qq, x, y-3, "##");
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, x-1, y-4, ':');
cucul_putchar(g->qq, x+2, y-4, ':');
cucul_putchar(g->qq, x-1, y-3, '%');
cucul_putchar(g->qq, x+2, y-3, '%');
cucul_putstr(g->qq, x-4, y-2, ",-'");
cucul_putstr(g->qq, x+3, y-2, "`-.");
cucul_set_color(g->qq, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, x-2, y-3, ':');
cucul_putchar(g->qq, x+3, y-3, ':');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x, y-4, "%%");
cucul_putstr(g->cv, x, y-3, "##");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, x-1, y-4, ':');
cucul_putchar(g->cv, x+2, y-4, ':');
cucul_putchar(g->cv, x-1, y-3, '%');
cucul_putchar(g->cv, x+2, y-3, '%');
cucul_putstr(g->cv, x-4, y-2, ",-'");
cucul_putstr(g->cv, x+3, y-2, "`-.");
cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, x-2, y-3, ':');
cucul_putchar(g->cv, x+3, y-3, ':');
break; break;
case 18: case 18:
default: default:
r = (18 - frame) * (18 - frame); r = (18 - frame) * (18 - frame);
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x-1, y-5-r, ":%%:");
cucul_putstr(g->qq, x-1, y-4-r, "%##%");
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, x-2, y-4-r, ':');
cucul_putchar(g->qq, x+3, y-4-r, ':');
cucul_putchar(g->qq, x-2, y-2, '\'');
cucul_putchar(g->qq, x+3, y-2, '`');
cucul_set_color(g->qq, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, x-3, y-2, ':');
cucul_putchar(g->qq, x+4, y-2, ':');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x-1, y-5-r, ":%%:");
cucul_putstr(g->cv, x-1, y-4-r, "%##%");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, x-2, y-4-r, ':');
cucul_putchar(g->cv, x+3, y-4-r, ':');
cucul_putchar(g->cv, x-2, y-2, '\'');
cucul_putchar(g->cv, x+3, y-2, '`');
cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, x-3, y-2, ':');
cucul_putchar(g->cv, x+4, y-2, ':');
for(i = 0; i <= r; i++) for(i = 0; i <= r; i++)
{ {
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->qq, x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, x-2, y-3-i, '%');
cucul_putchar(g->qq, x+3, y-3-i, '%');
cucul_set_color(g->qq, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_putchar(g->qq, x-3, y-3-i, ':');
cucul_putchar(g->qq, x+4, y-3-i, ':');
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
cucul_putstr(g->cv, x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, x-2, y-3-i, '%');
cucul_putchar(g->cv, x+3, y-3-i, '%');
cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_putchar(g->cv, x-3, y-3-i, ':');
cucul_putchar(g->cv, x+4, y-3-i, ':');
} }
break; break;
} }
@@ -444,20 +454,20 @@ static void draw_nuke(game *g, int x, int y, int frame)
int r = (29 - frame) * (29 - frame) / 8; int r = (29 - frame) * (29 - frame) / 8;


/* Lots of duplicate pixels, but we don't care */ /* Lots of duplicate pixels, but we don't care */
cucul_set_color(g->qq, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_draw_ellipse(g->qq, x, y, r, r / 2, ':');
cucul_set_color(g->qq, CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_BLUE);
cucul_draw_ellipse(g->qq, x, y, r + 1, r / 2, '#');
cucul_set_color(g->qq, CUCUL_COLOR_BLUE, CUCUL_COLOR_LIGHTBLUE);
cucul_draw_ellipse(g->qq, x, y, r + 2, r / 2, '#');
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_LIGHTBLUE);
cucul_draw_ellipse(g->qq, x, y, r + 2, r / 2 + 1, '#');
cucul_set_color(g->qq, CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_CYAN);
cucul_draw_ellipse(g->qq, x, y, r + 3, r / 2 + 1, '#');
cucul_set_color(g->qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_CYAN);
cucul_draw_ellipse(g->qq, x, y, r + 3, r / 2 + 2, '#');
cucul_set_color(g->qq, CUCUL_COLOR_CYAN, CUCUL_COLOR_WHITE);
cucul_draw_ellipse(g->qq, x, y, r + 4, r / 2 + 2, '#');
cucul_draw_ellipse(g->qq, x, y, r + 4, r / 2 + 3, ' ');
cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
cucul_draw_ellipse(g->cv, x, y, r, r / 2, ":");
cucul_set_color(g->cv, CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_BLUE);
cucul_draw_ellipse(g->cv, x, y, r + 1, r / 2, "#");
cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_LIGHTBLUE);
cucul_draw_ellipse(g->cv, x, y, r + 2, r / 2, "#");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_LIGHTBLUE);
cucul_draw_ellipse(g->cv, x, y, r + 2, r / 2 + 1, "#");
cucul_set_color(g->cv, CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_CYAN);
cucul_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 1, "#");
cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_CYAN);
cucul_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 2, "#");
cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_WHITE);
cucul_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 2, "#");
cucul_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 3, " ");
} }



Loading…
Cancel
Save