Browse Source

* BUGS TODO:

+ Removed libcaca stuff.
  * data/bongem.txt:
    + Fixed sprite syntax.
  * src/:
    + Set framerate to 25fps instead of 10fps.
    + Updated code to latest libcaca changes.


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@194 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 21 years ago
parent
commit
0aabcc8fe7
11 changed files with 52 additions and 74 deletions
  1. +0
    -6
      BUGS
  2. +0
    -16
      TODO
  3. +2
    -2
      data/bongem.txt
  4. +2
    -2
      src/aliens.c
  5. +3
    -3
      src/box.c
  6. +4
    -4
      src/intro.c
  7. +1
    -1
      src/main.c
  8. +10
    -10
      src/overlay.c
  9. +2
    -2
      src/starfield.c
  10. +2
    -2
      src/tunnel.c
  11. +26
    -26
      src/weapons.c

+ 0
- 6
BUGS View File

@@ -1,8 +1,2 @@
$Id$ $Id$


Video rendering

o Slang's and ncurses' hashmap scrolling optimization code cause the
screen to occasionally flicker because it tries to optimize the
vertical scrolling.


+ 0
- 16
TODO View File

@@ -1,21 +1,5 @@
$Id$ $Id$


TODO for libcaca

o Sprite library

o Clip graphics

o Fix the thin ellipse rendering

o Write a Linux console output for the drawing library
See also BUGS as to why it's very slow in console mode

o DONE 12 Nov 2003: Port to conio.h


TODO for ttyvaders

o Let the ship pick up bonuses o Let the ship pick up bonuses


o Alien swarms, programmed behaviour o Alien swarms, programmed behaviour


+ 2
- 2
data/bongem.txt View File

@@ -1,11 +1,11 @@
3 2 1 1
3 3 1 1
_ _
/g\ /g\
\_/ \_/
c c
cpc cpc
ccc ccc
3 2 1 1
3 3 1 1
_ _
/g\ /g\
\_/ \_/


+ 2
- 2
src/aliens.c View File

@@ -53,13 +53,13 @@ void draw_aliens(game *g, aliens *al)
switch(al->type[i]) switch(al->type[i])
{ {
case ALIEN_FOO: case ALIEN_FOO:
caca_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 8);
caca_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 5);
break; break;
case ALIEN_BAR: case ALIEN_BAR:
caca_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2); caca_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2);
break; break;
case ALIEN_BAZ: case ALIEN_BAZ:
caca_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 6);
caca_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 4);
break; break;
case ALIEN_NONE: case ALIEN_NONE:
break; break;


+ 3
- 3
src/box.c View File

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


caca_set_color(EE_YELLOW);
caca_set_color(CACA_COLOR_YELLOW);


/* Draw the thin horizontal line */ /* Draw the thin horizontal line */
if(b->frame < 8) if(b->frame < 8)
@@ -68,7 +68,7 @@ void draw_box(game *g, box *b)
caca_draw_line(b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, caca_draw_line(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'); b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X');


caca_set_color(EE_BLACK);
caca_set_color(CACA_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;
@@ -84,7 +84,7 @@ void draw_box(game *g, box *b)
} }


/* Draw the text inside the frame */ /* Draw the text inside the frame */
caca_set_color(EE_YELLOW);
caca_set_color(CACA_COLOR_YELLOW);


/* FIXME: use a font */ /* FIXME: use a font */
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2, caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2,


+ 4
- 4
src/intro.c View File

@@ -47,9 +47,9 @@ void intro(void)
xo = caca_get_width() / 2; xo = caca_get_width() / 2;
yo = caca_get_height() / 2; yo = caca_get_height() / 2;


caca_set_color(EE_RED);
caca_set_color(CACA_COLOR_RED);
caca_fill_ellipse(xo, yo, 16, 8, '#'); caca_fill_ellipse(xo, yo, 16, 8, '#');
caca_set_color(EE_GREEN);
caca_set_color(CACA_COLOR_GREEN);
caca_draw_thin_ellipse(xo, yo, 16, 8); caca_draw_thin_ellipse(xo, yo, 16, 8);


for(i = 0; i < 4; i ++) for(i = 0; i < 4; i ++)
@@ -60,11 +60,11 @@ void intro(void)
x[4] = x[0]; x[4] = x[0];
y[4] = y[0]; y[4] = y[0];


caca_set_color(EE_BLACK);
caca_set_color(CACA_COLOR_BLACK);
caca_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' '); caca_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' ');
caca_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' '); caca_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' ');
caca_draw_line(x[0], y[0], x[2], y[2], ' '); caca_draw_line(x[0], y[0], x[2], y[2], ' ');
caca_set_color(EE_GREEN);
caca_set_color(CACA_COLOR_GREEN);
caca_draw_thin_polyline(x, y, 4); caca_draw_thin_polyline(x, y, 4);


caca_draw_sprite(xo, yo, foo_sprite, frame % 5); caca_draw_sprite(xo, yo, foo_sprite, frame % 5);


+ 1
- 1
src/main.c View File

@@ -46,7 +46,7 @@ int main (int argc, char **argv)
return 1; return 1;
} }


caca_set_delay(100000);
caca_set_delay(40000);


/* Initialize our program */ /* Initialize our program */
g->w = caca_get_width(); g->w = caca_get_width();


+ 10
- 10
src/overlay.c View File

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


/* Draw life jauge */ /* Draw life jauge */
caca_set_color(EE_DARKGRAY);
caca_set_color(CACA_COLOR_DARKGRAY);
caca_putstr(4, 1, dots30); caca_putstr(4, 1, dots30);


if(g->p->life > MAX_LIFE * 7 / 10) if(g->p->life > MAX_LIFE * 7 / 10)
{ {
caca_set_color(EE_GREEN);
caca_set_color(CACA_COLOR_GREEN);
} }
else if(g->p->life > MAX_LIFE * 3 / 10) else if(g->p->life > MAX_LIFE * 3 / 10)
{ {
caca_set_color(EE_YELLOW);
caca_set_color(CACA_COLOR_YELLOW);
} }
else else
{ {
caca_set_color(EE_RED);
caca_set_color(CACA_COLOR_RED);
} }


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


caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(1, 1, "L |"); caca_putstr(1, 1, "L |");
caca_putstr(34, 1, "|"); caca_putstr(34, 1, "|");


/* Draw weapon jauge */ /* Draw weapon jauge */
caca_set_color(EE_DARKGRAY);
caca_set_color(CACA_COLOR_DARKGRAY);
caca_putstr(42, 1, dots30 + 10); caca_putstr(42, 1, dots30 + 10);


if(g->p->special > MAX_SPECIAL * 9 / 10) if(g->p->special > MAX_SPECIAL * 9 / 10)
{ {
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
} }
else if(g->p->special > MAX_SPECIAL * 3 / 10) else if(g->p->special > MAX_SPECIAL * 3 / 10)
{ {
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
} }
else else
{ {
caca_set_color(EE_BLUE);
caca_set_color(CACA_COLOR_BLUE);
} }


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


caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(39, 1, "S |"); caca_putstr(39, 1, "S |");
caca_putstr(62, 1, "|"); caca_putstr(62, 1, "|");
} }


+ 2
- 2
src/starfield.c View File

@@ -40,7 +40,7 @@ starfield * create_starfield(game *g)
s[i].x = caca_rand(0, g->w - 1); s[i].x = caca_rand(0, g->w - 1);
s[i].y = caca_rand(0, g->h - 1); s[i].y = caca_rand(0, g->h - 1);
s[i].z = caca_rand(1, 3); s[i].z = caca_rand(1, 3);
s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY;
s[i].c = caca_rand(0, 1) ? CACA_COLOR_LIGHTGRAY : CACA_COLOR_DARKGRAY;
s[i].ch = caca_rand(0, 1) ? '.' : '\''; s[i].ch = caca_rand(0, 1) ? '.' : '\'';
} }


@@ -72,7 +72,7 @@ void update_starfield(game *g, starfield *s)
s[i].x = caca_rand(0, g->w - 1); s[i].x = caca_rand(0, g->w - 1);
s[i].y = 0; s[i].y = 0;
s[i].z = caca_rand(1, 2); s[i].z = caca_rand(1, 2);
s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY;
s[i].c = caca_rand(0, 1) ? CACA_COLOR_LIGHTGRAY : CACA_COLOR_DARKGRAY;
s[i].ch = caca_rand(0, 1) ? '.' : '\''; s[i].ch = caca_rand(0, 1) ? '.' : '\'';
} }
else if(s[i].y < g->h-1) else if(s[i].y < g->h-1)


+ 2
- 2
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;


caca_set_color(EE_GREEN);
caca_set_color(CACA_COLOR_GREEN);


/* Left border */ /* Left border */
for(i = 0; i < g->h ; i++) for(i = 0; i < g->h ; i++)
@@ -115,7 +115,7 @@ void draw_tunnel(game *g, tunnel *t)
caca_putchar(t->right[i] - 1, i, c); caca_putchar(t->right[i] - 1, i, c);
} }


caca_set_color(EE_RED);
caca_set_color(CACA_COLOR_RED);


/* Left concrete */ /* Left concrete */
for(i = 0; i < g->h ; i++) for(i = 0; i < g->h ; i++)


+ 26
- 26
src/weapons.c View File

@@ -56,20 +56,20 @@ void draw_weapons(game *g, weapons *wp)
switch(wp->type[i]) switch(wp->type[i])
{ {
case WEAPON_LASER: case WEAPON_LASER:
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|'); caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|');
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); caca_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
break; break;
case WEAPON_SEEKER: case WEAPON_SEEKER:
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@'); caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@');
break; break;
case WEAPON_BOMB: case WEAPON_BOMB:
caca_set_color(EE_DARKGRAY);
caca_set_color(CACA_COLOR_DARKGRAY);
caca_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); caca_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
caca_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); caca_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
caca_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.'); caca_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');
@@ -354,84 +354,84 @@ static void draw_beam(int x, int y, int frame)
switch(frame) switch(frame)
{ {
case 24: case 24:
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x, y-3, "__"); caca_putstr(x, y-3, "__");
caca_putchar(x-1, y-2, '\''); caca_putchar(x-1, y-2, '\'');
caca_putchar(x+2, y-2, '`'); caca_putchar(x+2, y-2, '`');
break; break;
case 23: case 23:
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putstr(x, y-3, "__"); caca_putstr(x, y-3, "__");
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x-2, y-2, "-'"); caca_putstr(x-2, y-2, "-'");
caca_putstr(x+2, y-2, "`-"); caca_putstr(x+2, y-2, "`-");
break; break;
case 22: case 22:
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putstr(x, y-3, "__"); caca_putstr(x, y-3, "__");
caca_putchar(x-1, y-2, '\''); caca_putchar(x-1, y-2, '\'');
caca_putchar(x+2, y-2, '`'); caca_putchar(x+2, y-2, '`');
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x-3, y-2, ",-"); caca_putstr(x-3, y-2, ",-");
caca_putstr(x+3, y-2, "-."); caca_putstr(x+3, y-2, "-.");
break; break;
case 21: case 21:
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putstr(x-1, y-3, "____"); caca_putstr(x-1, y-3, "____");
caca_putchar(x-2, y-2, '\''); caca_putchar(x-2, y-2, '\'');
caca_putchar(x+3, y-2, '`'); caca_putchar(x+3, y-2, '`');
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x-4, y-2, ",-"); caca_putstr(x-4, y-2, ",-");
caca_putstr(x+4, y-2, "-."); caca_putstr(x+4, y-2, "-.");
break; break;
case 20: case 20:
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x, y-3, "%%"); caca_putstr(x, y-3, "%%");
caca_putchar(x-4, y-2, ','); caca_putchar(x-4, y-2, ',');
caca_putchar(x+5, y-2, '.'); caca_putchar(x+5, y-2, '.');
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putchar(x-1, y-3, ':'); caca_putchar(x-1, y-3, ':');
caca_putchar(x+2, y-3, ':'); caca_putchar(x+2, y-3, ':');
caca_putstr(x-3, y-2, "-'"); caca_putstr(x-3, y-2, "-'");
caca_putstr(x+3, y-2, "`-"); caca_putstr(x+3, y-2, "`-");
break; break;
case 19: case 19:
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x, y-4, "%%"); caca_putstr(x, y-4, "%%");
caca_putstr(x, y-3, "##"); caca_putstr(x, y-3, "##");
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putchar(x-1, y-4, ':'); caca_putchar(x-1, y-4, ':');
caca_putchar(x+2, y-4, ':'); caca_putchar(x+2, y-4, ':');
caca_putchar(x-1, y-3, '%'); caca_putchar(x-1, y-3, '%');
caca_putchar(x+2, y-3, '%'); caca_putchar(x+2, y-3, '%');
caca_putstr(x-4, y-2, ",-'"); caca_putstr(x-4, y-2, ",-'");
caca_putstr(x+3, y-2, "`-."); caca_putstr(x+3, y-2, "`-.");
caca_set_color(EE_BLUE);
caca_set_color(CACA_COLOR_BLUE);
caca_putchar(x-2, y-3, ':'); caca_putchar(x-2, y-3, ':');
caca_putchar(x+3, y-3, ':'); caca_putchar(x+3, y-3, ':');
break; break;
case 18: case 18:
default: default:
r = (18 - frame) * (18 - frame); r = (18 - frame) * (18 - frame);
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x-1, y-5-r, ":%%:"); caca_putstr(x-1, y-5-r, ":%%:");
caca_putstr(x-1, y-4-r, "%##%"); caca_putstr(x-1, y-4-r, "%##%");
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putchar(x-2, y-4-r, ':'); caca_putchar(x-2, y-4-r, ':');
caca_putchar(x+3, y-4-r, ':'); caca_putchar(x+3, y-4-r, ':');
caca_putchar(x-2, y-2, '\''); caca_putchar(x-2, y-2, '\'');
caca_putchar(x+3, y-2, '`'); caca_putchar(x+3, y-2, '`');
caca_set_color(EE_BLUE);
caca_set_color(CACA_COLOR_BLUE);
caca_putchar(x-3, y-2, ':'); caca_putchar(x-3, y-2, ':');
caca_putchar(x+4, y-2, ':'); caca_putchar(x+4, y-2, ':');
for(i = 0; i <= r; i++) for(i = 0; i <= r; i++)
{ {
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); caca_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_putchar(x-2, y-3-i, '%'); caca_putchar(x-2, y-3-i, '%');
caca_putchar(x+3, y-3-i, '%'); caca_putchar(x+3, y-3-i, '%');
caca_set_color(EE_BLUE);
caca_set_color(CACA_COLOR_BLUE);
caca_putchar(x-3, y-3-i, ':'); caca_putchar(x-3, y-3-i, ':');
caca_putchar(x+4, y-3-i, ':'); caca_putchar(x+4, y-3-i, ':');
} }
@@ -444,14 +444,14 @@ static void draw_nuke(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 */
caca_set_color(EE_BLUE);
caca_set_color(CACA_COLOR_BLUE);
caca_draw_ellipse(x, y, r, r / 2, ':'); caca_draw_ellipse(x, y, r, r / 2, ':');
caca_draw_ellipse(x, y, r + 1, r / 2, ':'); caca_draw_ellipse(x, y, r + 1, r / 2, ':');
caca_draw_ellipse(x, y, r + 2, r / 2, ':'); caca_draw_ellipse(x, y, r + 2, r / 2, ':');
caca_set_color(EE_CYAN);
caca_set_color(CACA_COLOR_CYAN);
caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '%'); caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '%');
caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '%'); caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '%');
caca_set_color(EE_WHITE);
caca_set_color(CACA_COLOR_WHITE);
caca_draw_ellipse(x, y, r + 3, r / 2 + 2, '#'); caca_draw_ellipse(x, y, r + 3, r / 2 + 2, '#');
caca_draw_ellipse(x, y, r + 4, r / 2 + 2, '#'); caca_draw_ellipse(x, y, r + 4, r / 2 + 2, '#');
caca_draw_ellipse(x, y, r + 4, r / 2 + 3, '#'); caca_draw_ellipse(x, y, r + 4, r / 2 + 3, '#');


Loading…
Cancel
Save