diff --git a/src/aliens.c b/src/aliens.c index e6954e3..072bf77 100644 --- a/src/aliens.c +++ b/src/aliens.c @@ -24,7 +24,6 @@ caca_canvas_t *baz_sprite; void init_aliens(game *g, aliens *al) { - caca_buffer_t *b; int i; for(i = 0; i < ALIENS; i++) @@ -32,17 +31,14 @@ void init_aliens(game *g, aliens *al) al->type[i] = ALIEN_NONE; } - b = caca_load_file("data/foofight.caca"); - foo_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + foo_sprite = caca_create_canvas(0, 0); + caca_import_file(foo_sprite, "data/foofight.txt", "utf8"); - b = caca_load_file("data/barfight.caca"); - bar_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + bar_sprite = caca_create_canvas(0, 0); + caca_import_file(bar_sprite, "data/barfight.txt", "utf8"); - b = caca_load_file("data/bazfight.caca"); - baz_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + baz_sprite = caca_create_canvas(0, 0); + caca_import_file(baz_sprite, "data/bazfight.txt", "utf8"); } void draw_aliens(game *g, aliens *al) @@ -54,15 +50,15 @@ void draw_aliens(game *g, aliens *al) switch(al->type[i]) { case ALIEN_FOO: - caca_set_canvas_frame(foo_sprite, al->img[i] % 5); + caca_set_frame(foo_sprite, al->img[i] % 5); caca_blit(g->cv, al->x[i], al->y[i], foo_sprite, NULL); break; case ALIEN_BAR: - caca_set_canvas_frame(bar_sprite, al->img[i] % 2); + caca_set_frame(bar_sprite, al->img[i] % 2); caca_blit(g->cv, al->x[i], al->y[i], bar_sprite, NULL); break; case ALIEN_BAZ: - caca_set_canvas_frame(baz_sprite, al->img[i] % 4); + caca_set_frame(baz_sprite, al->img[i] % 4); caca_blit(g->cv, al->x[i], al->y[i], baz_sprite, NULL); break; case ALIEN_NONE: diff --git a/src/bonus.c b/src/bonus.c index 121477b..795a650 100644 --- a/src/bonus.c +++ b/src/bonus.c @@ -23,7 +23,6 @@ caca_canvas_t *gem_sprite; void init_bonus(game *g, bonus *bo) { - caca_buffer_t *b; int i; for(i = 0; i < BONUS; i++) @@ -31,13 +30,11 @@ void init_bonus(game *g, bonus *bo) bo->type[i] = BONUS_NONE; } - b = caca_load_file("data/bonheart.caca"); - heart_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + heart_sprite = caca_create_canvas(0, 0); + caca_import_file(heart_sprite, "data/bonheart.txt", "utf8"); - b = caca_load_file("data/bongem.caca"); - gem_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + gem_sprite = caca_create_canvas(0, 0); + caca_import_file(gem_sprite, "data/bongem.txt", "utf8"); } void draw_bonus(game *g, bonus *bo) @@ -49,11 +46,11 @@ void draw_bonus(game *g, bonus *bo) switch(bo->type[i]) { case BONUS_GREEN: - caca_set_canvas_frame(gem_sprite, (bo->n[i]/2 % 3) ? 0 : 1); + caca_set_frame(gem_sprite, (bo->n[i]/2 % 3) ? 0 : 1); caca_blit(g->cv, bo->x[i], bo->y[i], gem_sprite, NULL); break; case BONUS_LIFE: - caca_set_canvas_frame(heart_sprite, (bo->n[i] % 3) ? 0 : 1); + caca_set_frame(heart_sprite, (bo->n[i] % 3) ? 0 : 1); caca_blit(g->cv, bo->x[i], bo->y[i], heart_sprite, NULL); break; case BONUS_NONE: diff --git a/src/box.c b/src/box.c index 94607d8..c7bbd05 100644 --- a/src/box.c +++ b/src/box.c @@ -37,13 +37,13 @@ void draw_box(game *g, box *b) { int j, frame; - caca_set_color(g->cv, CACA_COLOR_YELLOW, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_YELLOW, CACA_BLACK); /* Draw the thin horizontal line */ if(b->frame < 8) { caca_draw_line(g->cv, b->x - b->w * b->frame / 16, b->y, - b->x + b->w * b->frame / 16 - 1, b->y, "X"); + b->x + b->w * b->frame / 16 - 1, b->y, 'X'); return; } @@ -51,23 +51,23 @@ void draw_box(game *g, box *b) frame = b->frame < 12 ? b->frame : 12; caca_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"); + b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 'X'); caca_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"); + b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, 'X'); caca_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"); + b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, 'X'); caca_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"); + b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X'); - caca_set_color(g->cv, CACA_COLOR_BLACK, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_BLACK, CACA_BLACK); for(j = b->y - b->h * (frame - 8) / 8 + 1; j < b->y + b->h * (frame - 8) / 8; j++) { caca_draw_line(g->cv, b->x - b->w / 2 + 1, j, - b->x + b->w / 2 - 2, j, "X"); + b->x + b->w / 2 - 2, j, 'X'); } if(b->frame < 12) @@ -76,18 +76,18 @@ void draw_box(game *g, box *b) } /* Draw the text inside the frame */ - caca_set_color(g->cv, CACA_COLOR_YELLOW, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_YELLOW, CACA_BLACK); /* FIXME: use a font */ - caca_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 2, + caca_put_str(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 2, "XXXX. .XXXX X X .XXXX .XXXX XXXX."); - caca_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 3, + caca_put_str(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 3, "X `X X' X X X X' X' X `X"); - caca_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 4, + caca_put_str(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 4, "XXXX' XXXXX X X `XXX XXXX X X"); - caca_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 5, + caca_put_str(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 5, "X' X' `X X. ,X `X X' X ,X"); - caca_putstr(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 6, + caca_put_str(g->cv, b->x - b->w / 2 + 12, b->y - b->h / 2 + 6, "X X X `XXXX XXXX' `XXXX XXXX'"); } diff --git a/src/ceo.c b/src/ceo.c index bd343a9..a0ed85d 100644 --- a/src/ceo.c +++ b/src/ceo.c @@ -15,7 +15,7 @@ #include "config.h" #include -#include +//#include #include "common.h" @@ -37,8 +37,8 @@ void ceo_alert(game *g) fprintf(stderr, "foo\n"); - caca_refresh_display(g->cv); + caca_refresh_display(g->dp); - usleep(40000); + //usleep(40000); } } diff --git a/src/explosions.c b/src/explosions.c index 94e580a..6256321 100644 --- a/src/explosions.c +++ b/src/explosions.c @@ -23,7 +23,6 @@ caca_canvas_t *small_sprite; void init_explosions(game *g, explosions *ex) { - caca_buffer_t *b; int i; for(i = 0; i < EXPLOSIONS; i++) @@ -31,13 +30,11 @@ void init_explosions(game *g, explosions *ex) ex->type[i] = EXPLOSION_NONE; } - b = caca_load_file("data/xplmed.caca"); - medium_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + medium_sprite = caca_create_canvas(0, 0); + caca_import_file(medium_sprite, "data/xplmed.txt", "utf8"); - b = caca_load_file("data/xplsmall.caca"); - small_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + small_sprite = caca_create_canvas(0, 0); + caca_import_file(small_sprite, "data/xplsmall.txt", "utf8"); } void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type) @@ -74,7 +71,7 @@ void draw_explosions(game *g, explosions *ex) for(i = 0; i < EXPLOSIONS; i++) { #if 0 - caca_set_fg_color(g->cv, CACA_COLOR_GREEN); + caca_set_fg_color(g->cv, CACA_GREEN); caca_goto(g->cv, ex->x[i] + 3, ex->y[i]); switch(caca_rand(0,2)) { @@ -101,11 +98,11 @@ void draw_explosions(game *g, explosions *ex) switch(ex->type[i]) { case EXPLOSION_MEDIUM: - caca_set_canvas_frame(medium_sprite, 10 - ex->n[i]); + caca_set_frame(medium_sprite, 10 - ex->n[i]); caca_blit(g->cv, ex->x[i], ex->y[i], medium_sprite, NULL); break; case EXPLOSION_SMALL: - caca_set_canvas_frame(small_sprite, 6 - ex->n[i]); + caca_set_frame(small_sprite, 6 - ex->n[i]); caca_blit(g->cv, ex->x[i], ex->y[i], small_sprite, NULL); break; case EXPLOSION_NONE: diff --git a/src/intro.c b/src/intro.c index 827c5c5..6847a53 100644 --- a/src/intro.c +++ b/src/intro.c @@ -16,7 +16,10 @@ #include #include -#include +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif +//#include #include "common.h" @@ -26,20 +29,16 @@ void intro(game *g) caca_canvas_t *foo_sprite; caca_canvas_t *bar_sprite; caca_canvas_t *baz_sprite; - caca_buffer_t *b; int frame = 0; - b = caca_load_file("data/foofight.caca"); - foo_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + foo_sprite = caca_create_canvas(0, 0); + caca_import_file(foo_sprite, "data/foofight.txt", "utf8"); - b = caca_load_file("data/barfight.caca"); - bar_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + bar_sprite = caca_create_canvas(0, 0); + caca_import_file(bar_sprite, "data/barfight.txt", "utf8"); - b = caca_load_file("data/bazfight.caca"); - baz_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + baz_sprite = caca_create_canvas(0, 0); + caca_import_file(baz_sprite, "data/bazfight.txt", "utf8"); while(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0) == 0) { @@ -52,9 +51,9 @@ void intro(game *g) xo = caca_get_canvas_width(g->cv) / 2; yo = caca_get_canvas_height(g->cv) / 2; - caca_set_color(g->cv, CACA_COLOR_RED, CACA_COLOR_BLACK); - caca_fill_ellipse(g->cv, xo, yo, 16, 8, "#"); - caca_set_color(g->cv, CACA_COLOR_GREEN, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_RED, CACA_BLACK); + caca_fill_ellipse(g->cv, xo, yo, 16, 8, '#'); + caca_set_color_ansi(g->cv, CACA_GREEN, CACA_BLACK); caca_draw_thin_ellipse(g->cv, xo, yo, 16, 8); for(i = 0; i < 4; i ++) @@ -65,19 +64,19 @@ void intro(game *g) x[4] = x[0]; y[4] = y[0]; - caca_set_color(g->cv, CACA_COLOR_BLACK, CACA_COLOR_BLACK); - caca_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], " "); - caca_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], " "); - caca_draw_line(g->cv, x[0], y[0], x[2], y[2], " "); - caca_set_color(g->cv, CACA_COLOR_GREEN, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_BLACK, CACA_BLACK); + caca_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], ' '); + caca_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], ' '); + caca_draw_line(g->cv, x[0], y[0], x[2], y[2], ' '); + caca_set_color_ansi(g->cv, CACA_GREEN, CACA_BLACK); caca_draw_thin_polyline(g->cv, x, y, 4); - caca_set_canvas_frame(foo_sprite, frame % 5); + caca_set_frame(foo_sprite, frame % 5); caca_blit(g->cv, xo, yo, foo_sprite, NULL); caca_refresh_display(g->dp); - usleep(40000); + //usleep(40000); } } diff --git a/src/main.c b/src/main.c index 1d0cae2..21c8082 100644 --- a/src/main.c +++ b/src/main.c @@ -16,16 +16,14 @@ #include #include - #include - #include #include "common.h" static void start_game (game *); -int _main (int argc, char **argv) +int main (int argc, char **argv) { game *g = malloc(sizeof(game)); if(g == NULL) @@ -33,7 +31,7 @@ int _main (int argc, char **argv) srand(time(NULL)); - g->cv = caca_create_canvas(0, 0); + g->cv = caca_create_canvas(80, 50); if(!g->cv) return 1; diff --git a/src/overlay.c b/src/overlay.c index a8f3f1a..b632887 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -24,50 +24,50 @@ void draw_status(game *g) static char dashes30[] = "=============================="; /* Draw life jauge */ - caca_set_color(g->cv, CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK); - caca_putstr(g->cv, 4, 1, dots30); + caca_set_color_ansi(g->cv, CACA_DARKGRAY, CACA_BLACK); + caca_put_str(g->cv, 4, 1, dots30); if(g->p->life > MAX_LIFE * 7 / 10) { - caca_set_color(g->cv, CACA_COLOR_GREEN, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_GREEN, CACA_BLACK); } else if(g->p->life > MAX_LIFE * 3 / 10) { - caca_set_color(g->cv, CACA_COLOR_YELLOW, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_YELLOW, CACA_BLACK); } else { - caca_set_color(g->cv, CACA_COLOR_RED, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_RED, CACA_BLACK); } - caca_putstr(g->cv, 4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); + caca_put_str(g->cv, 4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, 1, 1, "L |"); - caca_putstr(g->cv, 34, 1, "|"); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, 1, 1, "L |"); + caca_put_str(g->cv, 34, 1, "|"); /* Draw weapon jauge */ - caca_set_color(g->cv, CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK); - caca_putstr(g->cv, 42, 1, dots30 + 10); + caca_set_color_ansi(g->cv, CACA_DARKGRAY, CACA_BLACK); + caca_put_str(g->cv, 42, 1, dots30 + 10); if(g->p->special > MAX_SPECIAL * 9 / 10) { - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); } else if(g->p->special > MAX_SPECIAL * 3 / 10) { - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); } else { - caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_BLUE, CACA_BLACK); } - caca_putstr(g->cv, 42, 1, dashes30 + 10 - + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); + caca_put_str(g->cv, 42, 1, dashes30 + 10 + + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, 39, 1, "S |"); - caca_putstr(g->cv, 62, 1, "|"); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, 39, 1, "S |"); + caca_put_str(g->cv, 62, 1, "|"); } diff --git a/src/player.c b/src/player.c index 77bbf99..ed53d8e 100644 --- a/src/player.c +++ b/src/player.c @@ -23,8 +23,6 @@ caca_canvas_t *ship_sprite; /* Init tunnel */ player * create_player(game *g) { - caca_buffer_t *b; - player *p = malloc(sizeof(player)); if(p == NULL) exit(1); @@ -38,9 +36,8 @@ player * create_player(game *g) p->life = MAX_LIFE; p->dead = 0; - b = caca_load_file("data/ship.caca"); - ship_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + ship_sprite = caca_create_canvas(0, 0); + caca_import_file(ship_sprite, "data/ship.txt", "utf8"); return p; } @@ -55,7 +52,7 @@ void draw_player(game *g, player *p) if(p->dead) return; - caca_set_canvas_frame(ship_sprite, 0); + caca_set_frame(ship_sprite, 0); caca_blit(g->cv, p->x, p->y, ship_sprite, NULL); } diff --git a/src/starfield.c b/src/starfield.c index 9f6c06f..cd5ffbd 100644 --- a/src/starfield.c +++ b/src/starfield.c @@ -32,7 +32,7 @@ starfield * create_starfield(game *g) s[i].x = caca_rand(0, g->w - 1); s[i].y = caca_rand(0, g->h - 1); s[i].z = caca_rand(1, 3); - s[i].c = caca_rand(0, 1) ? CACA_COLOR_LIGHTGRAY : CACA_COLOR_DARKGRAY; + s[i].c = caca_rand(0, 1) ? CACA_LIGHTGRAY : CACA_DARKGRAY; s[i].ch = caca_rand(0, 1) ? '.' : '\''; } @@ -47,8 +47,8 @@ void draw_starfield(game *g, starfield *s) { if(s[i].x >= 0) { - caca_set_color(g->cv, s[i].c, CACA_COLOR_BLACK); - caca_putchar(g->cv, s[i].x, s[i].y, s[i].ch); + caca_set_color_ansi(g->cv, s[i].c, CACA_BLACK); + caca_put_char(g->cv, s[i].x, s[i].y, s[i].ch); } } } @@ -64,7 +64,7 @@ void update_starfield(game *g, starfield *s) s[i].x = caca_rand(0, g->w - 1); s[i].y = 0; s[i].z = caca_rand(1, 2); - s[i].c = caca_rand(0, 1) ? CACA_COLOR_LIGHTGRAY : CACA_COLOR_DARKGRAY; + s[i].c = caca_rand(0, 1) ? CACA_LIGHTGRAY : CACA_DARKGRAY; s[i].ch = caca_rand(0, 1) ? '.' : '\''; } else if(s[i].y < g->h-1) diff --git a/src/tunnel.c b/src/tunnel.c index d8303f7..ddb2ed6 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -69,7 +69,7 @@ void draw_tunnel(game *g, tunnel *t) int i, j; char c; - caca_set_color(g->cv, CACA_COLOR_RED, CACA_COLOR_BLACK); + caca_set_color_ansi(g->cv, CACA_RED, CACA_BLACK); /* Left border */ for(i = 0; i < g->h ; i++) @@ -82,11 +82,11 @@ void draw_tunnel(game *g, tunnel *t) else c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<'; - caca_putchar(g->cv, t->left[i] + 1, i, c); + caca_put_char(g->cv, t->left[i] + 1, i, c); if(i + 1 < g->h) for(j = 1; j < t->left[i+1] - t->left[i]; j++) - caca_putchar(g->cv, t->left[i] + j + 1, i, '_'); + caca_put_char(g->cv, t->left[i] + j + 1, i, '_'); } /* Right border */ @@ -102,22 +102,22 @@ void draw_tunnel(game *g, tunnel *t) if(i + 1 < g->h) for(j = 1; j < t->right[i] - t->right[i+1]; j++) - caca_putchar(g->cv, t->right[i+1] + j - 1, i, '_'); + caca_put_char(g->cv, t->right[i+1] + j - 1, i, '_'); - caca_putchar(g->cv, t->right[i] - 1, i, c); + caca_put_char(g->cv, t->right[i] - 1, i, c); } - caca_set_color(g->cv, CACA_COLOR_LIGHTRED, CACA_COLOR_RED); + caca_set_color_ansi(g->cv, CACA_LIGHTRED, CACA_RED); /* Left concrete */ for(i = 0; i < g->h ; i++) for(j = 0 ; j <= t->left[i]; j++) - caca_putchar(g->cv, j, i, '#'); + caca_put_char(g->cv, j, i, '#'); /* Right concrete */ for(i = 0; i < g->h ; i++) for(j = t->right[i] ; j < g->w ; j++) - caca_putchar(g->cv, j, i, '#'); + caca_put_char(g->cv, j, i, '#'); } void update_tunnel(game *g, tunnel *t) diff --git a/src/weapons.c b/src/weapons.c index 46e76ec..fa9e62c 100644 --- a/src/weapons.c +++ b/src/weapons.c @@ -29,7 +29,6 @@ caca_canvas_t *fragbomb_sprite; void init_weapons(game *g, weapons *wp) { - caca_buffer_t *b; int i; for(i = 0; i < WEAPONS; i++) @@ -37,13 +36,11 @@ void init_weapons(game *g, weapons *wp) wp->type[i] = WEAPON_NONE; } - b = caca_load_file("data/wpnbomb.caca"); - bomb_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + bomb_sprite = caca_create_canvas(0, 0); + caca_import_file(bomb_sprite, "data/wpnbomb.txt", "utf8"); - b = caca_load_file("data/wpnfrag.caca"); - bomb_sprite = caca_import_canvas(b, ""); - caca_free_buffer(b); + fragbomb_sprite = caca_create_canvas(0, 0); + caca_import_file(fragbomb_sprite, "data/wpnfrag.txt", "utf8"); } void draw_weapons(game *g, weapons *wp) @@ -55,25 +52,25 @@ void draw_weapons(game *g, weapons *wp) switch(wp->type[i]) { case WEAPON_LASER: - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '|'); - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putchar(g->cv, wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_char(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '|'); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_char(g->cv, wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); break; case WEAPON_SEEKER: - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); - caca_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '@'); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_char(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); + caca_put_char(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_char(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '@'); break; case WEAPON_BOMB: - caca_set_color(g->cv, CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK); - caca_putchar(g->cv, (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); - caca_putchar(g->cv, (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); - caca_putchar(g->cv, (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.'); - caca_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); - caca_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, '.'); + caca_set_color_ansi(g->cv, CACA_DARKGRAY, CACA_BLACK); + caca_put_char(g->cv, (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); + caca_put_char(g->cv, (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); + caca_put_char(g->cv, (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.'); + caca_put_char(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); + caca_put_char(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]); break; case WEAPON_FRAGBOMB: @@ -333,18 +330,18 @@ static void draw_bomb(game *g, int x, int y, int vx, int vy) } } - caca_set_canvas_frame(bomb_sprite, frame); + caca_set_frame(bomb_sprite, frame); caca_blit(g->cv, x, y, bomb_sprite, NULL); } static void draw_fragbomb(game *g, int x, int y, int frame) { /* Draw the head */ - caca_set_canvas_frame(fragbomb_sprite, frame & 1); + caca_set_frame(fragbomb_sprite, frame & 1); caca_blit(g->cv, x, y, fragbomb_sprite, NULL); /* Draw the tail */ - caca_set_canvas_frame(fragbomb_sprite, 2 + (frame % 4)); + caca_set_frame(fragbomb_sprite, 2 + (frame % 4)); caca_blit(g->cv, x, y, fragbomb_sprite, NULL); } @@ -356,86 +353,86 @@ static void draw_beam(game *g, int x, int y, int frame) switch(frame) { case 24: - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x, y-3, "__"); - caca_putchar(g->cv, x-1, y-2, '\''); - caca_putchar(g->cv, x+2, y-2, '`'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x, y-3, "__"); + caca_put_char(g->cv, x-1, y-2, '\''); + caca_put_char(g->cv, x+2, y-2, '`'); break; case 23: - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putstr(g->cv, x, y-3, "__"); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x-2, y-2, "-'"); - caca_putstr(g->cv, x+2, y-2, "`-"); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_str(g->cv, x, y-3, "__"); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x-2, y-2, "-'"); + caca_put_str(g->cv, x+2, y-2, "`-"); break; case 22: - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putstr(g->cv, x, y-3, "__"); - caca_putchar(g->cv, x-1, y-2, '\''); - caca_putchar(g->cv, x+2, y-2, '`'); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x-3, y-2, ",-"); - caca_putstr(g->cv, x+3, y-2, "-."); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_str(g->cv, x, y-3, "__"); + caca_put_char(g->cv, x-1, y-2, '\''); + caca_put_char(g->cv, x+2, y-2, '`'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x-3, y-2, ",-"); + caca_put_str(g->cv, x+3, y-2, "-."); break; case 21: - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putstr(g->cv, x-1, y-3, "____"); - caca_putchar(g->cv, x-2, y-2, '\''); - caca_putchar(g->cv, x+3, y-2, '`'); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x-4, y-2, ",-"); - caca_putstr(g->cv, x+4, y-2, "-."); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_str(g->cv, x-1, y-3, "____"); + caca_put_char(g->cv, x-2, y-2, '\''); + caca_put_char(g->cv, x+3, y-2, '`'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x-4, y-2, ",-"); + caca_put_str(g->cv, x+4, y-2, "-."); break; case 20: - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x, y-3, "%%"); - caca_putchar(g->cv, x-4, y-2, ','); - caca_putchar(g->cv, x+5, y-2, '.'); - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putchar(g->cv, x-1, y-3, ':'); - caca_putchar(g->cv, x+2, y-3, ':'); - caca_putstr(g->cv, x-3, y-2, "-'"); - caca_putstr(g->cv, x+3, y-2, "`-"); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x, y-3, "%%"); + caca_put_char(g->cv, x-4, y-2, ','); + caca_put_char(g->cv, x+5, y-2, '.'); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_char(g->cv, x-1, y-3, ':'); + caca_put_char(g->cv, x+2, y-3, ':'); + caca_put_str(g->cv, x-3, y-2, "-'"); + caca_put_str(g->cv, x+3, y-2, "`-"); break; case 19: - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x, y-4, "%%"); - caca_putstr(g->cv, x, y-3, "##"); - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putchar(g->cv, x-1, y-4, ':'); - caca_putchar(g->cv, x+2, y-4, ':'); - caca_putchar(g->cv, x-1, y-3, '%'); - caca_putchar(g->cv, x+2, y-3, '%'); - caca_putstr(g->cv, x-4, y-2, ",-'"); - caca_putstr(g->cv, x+3, y-2, "`-."); - caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK); - caca_putchar(g->cv, x-2, y-3, ':'); - caca_putchar(g->cv, x+3, y-3, ':'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x, y-4, "%%"); + caca_put_str(g->cv, x, y-3, "##"); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_char(g->cv, x-1, y-4, ':'); + caca_put_char(g->cv, x+2, y-4, ':'); + caca_put_char(g->cv, x-1, y-3, '%'); + caca_put_char(g->cv, x+2, y-3, '%'); + caca_put_str(g->cv, x-4, y-2, ",-'"); + caca_put_str(g->cv, x+3, y-2, "`-."); + caca_set_color_ansi(g->cv, CACA_BLUE, CACA_BLACK); + caca_put_char(g->cv, x-2, y-3, ':'); + caca_put_char(g->cv, x+3, y-3, ':'); break; case 18: default: r = (18 - frame) * (18 - frame); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x-1, y-5-r, ":%%:"); - caca_putstr(g->cv, x-1, y-4-r, "%##%"); - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putchar(g->cv, x-2, y-4-r, ':'); - caca_putchar(g->cv, x+3, y-4-r, ':'); - caca_putchar(g->cv, x-2, y-2, '\''); - caca_putchar(g->cv, x+3, y-2, '`'); - caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK); - caca_putchar(g->cv, x-3, y-2, ':'); - caca_putchar(g->cv, x+4, y-2, ':'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x-1, y-5-r, ":%%:"); + caca_put_str(g->cv, x-1, y-4-r, "%##%"); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_char(g->cv, x-2, y-4-r, ':'); + caca_put_char(g->cv, x+3, y-4-r, ':'); + caca_put_char(g->cv, x-2, y-2, '\''); + caca_put_char(g->cv, x+3, y-2, '`'); + caca_set_color_ansi(g->cv, CACA_BLUE, CACA_BLACK); + caca_put_char(g->cv, x-3, y-2, ':'); + caca_put_char(g->cv, x+4, y-2, ':'); for(i = 0; i <= r; i++) { - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK); - caca_putstr(g->cv, x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK); - caca_putchar(g->cv, x-2, y-3-i, '%'); - caca_putchar(g->cv, x+3, y-3-i, '%'); - caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK); - caca_putchar(g->cv, x-3, y-3-i, ':'); - caca_putchar(g->cv, x+4, y-3-i, ':'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_BLACK); + caca_put_str(g->cv, x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_BLACK); + caca_put_char(g->cv, x-2, y-3-i, '%'); + caca_put_char(g->cv, x+3, y-3-i, '%'); + caca_set_color_ansi(g->cv, CACA_BLUE, CACA_BLACK); + caca_put_char(g->cv, x-3, y-3-i, ':'); + caca_put_char(g->cv, x+4, y-3-i, ':'); } break; } @@ -446,20 +443,20 @@ static void draw_nuke(game *g, int x, int y, int frame) int r = (29 - frame) * (29 - frame) / 8; /* Lots of duplicate pixels, but we don't care */ - caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK); - caca_draw_ellipse(g->cv, x, y, r, r / 2, ":"); - caca_set_color(g->cv, CACA_COLOR_LIGHTBLUE, CACA_COLOR_BLUE); - caca_draw_ellipse(g->cv, x, y, r + 1, r / 2, "#"); - caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_LIGHTBLUE); - caca_draw_ellipse(g->cv, x, y, r + 2, r / 2, "#"); - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_LIGHTBLUE); - caca_draw_ellipse(g->cv, x, y, r + 2, r / 2 + 1, "#"); - caca_set_color(g->cv, CACA_COLOR_LIGHTBLUE, CACA_COLOR_CYAN); - caca_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 1, "#"); - caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_CYAN); - caca_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 2, "#"); - caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_WHITE); - caca_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 2, "#"); - caca_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 3, " "); + caca_set_color_ansi(g->cv, CACA_BLUE, CACA_BLACK); + caca_draw_ellipse(g->cv, x, y, r, r / 2, ':'); + caca_set_color_ansi(g->cv, CACA_LIGHTBLUE, CACA_BLUE); + caca_draw_ellipse(g->cv, x, y, r + 1, r / 2, '#'); + caca_set_color_ansi(g->cv, CACA_BLUE, CACA_LIGHTBLUE); + caca_draw_ellipse(g->cv, x, y, r + 2, r / 2, '#'); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_LIGHTBLUE); + caca_draw_ellipse(g->cv, x, y, r + 2, r / 2 + 1, '#'); + caca_set_color_ansi(g->cv, CACA_LIGHTBLUE, CACA_CYAN); + caca_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 1, '#'); + caca_set_color_ansi(g->cv, CACA_WHITE, CACA_CYAN); + caca_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 2, '#'); + caca_set_color_ansi(g->cv, CACA_CYAN, CACA_WHITE); + caca_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 2, '#'); + caca_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 3, ' '); } diff --git a/ttyvaders.sln b/ttyvaders.sln new file mode 100644 index 0000000..eaf2cea --- /dev/null +++ b/ttyvaders.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttyvaders", "ttyvaders.vcproj", "{633FC109-58D4-4676-858E-7222DE270E7A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {633FC109-58D4-4676-858E-7222DE270E7A}.Debug|Win32.ActiveCfg = Debug|Win32 + {633FC109-58D4-4676-858E-7222DE270E7A}.Debug|Win32.Build.0 = Debug|Win32 + {633FC109-58D4-4676-858E-7222DE270E7A}.Release|Win32.ActiveCfg = Release|Win32 + {633FC109-58D4-4676-858E-7222DE270E7A}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ttyvaders.vcproj b/ttyvaders.vcproj new file mode 100644 index 0000000..8aa8bce --- /dev/null +++ b/ttyvaders.vcproj @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/win32/config.h b/win32/config.h new file mode 100644 index 0000000..df85b85 --- /dev/null +++ b/win32/config.h @@ -0,0 +1,40 @@ +/* $Id: config.h 2965 2008-10-18 12:42:12Z sam $ */ + +/* #undef HAVE_ENDIAN_H */ +#define HAVE_ERRNO_H 1 +#define HAVE_GETENV 1 +/* #undef HAVE_GETTIMEOFDAY */ +/* #undef HAVE_INTTYPES_H */ +#define HAVE_MEMORY_H 1 +#define HAVE_PUTENV 1 +/* #undef HAVE_SIGNAL */ +/* #undef HAVE_SIGNAL_H */ +#define HAVE_SLEEP 1 +/* #undef HAVE_STDINT_H */ +#define HAVE_STDLIB_H 1 +/* #undef HAVE_STRCASECMP */ +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +/* #undef HAVE_SYS_IOCTL_H */ +#define HAVE_SYS_STAT_H 1 +/* #undef HAVE_SYS_TIME_H */ +#define HAVE_SYS_TYPES_H 1 +/* #undef HAVE_UNISTD_H */ +/* #undef HAVE_USLEEP */ +/* #undef HAVE_VSNPRINTF */ +#define HAVE_SNPRINTF 1 +/* #undef NO_MINUS_C_MINUS_O */ +#define PACKAGE_BUGREPORT "" +#define PACKAGE_NAME "ttyvaders" +#define PACKAGE_STRING "" +#define PACKAGE_TARNAME "" +#define PACKAGE_VERSION "0.0" +/* #undef RETSIGTYPE */ +/* #undef SCREENUPDATE_IN_PC_H */ +#define STDC_HEADERS 1 +/* #undef const */ +#ifndef __cplusplus +#define inline __inline +#endif +#define strcasecmp stricmp +#define snprintf _snprintf