Ignore:
Timestamp:
Oct 18, 2008, 11:42:24 PM (11 years ago)
Author:
Sam Hocevar
Message:

Port ttyvaders to the unified libcaca 0.99.beta15 API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/src/weapons.c

    r1460 r2990  
    2525static void draw_fragbomb(game *g, int x, int y, int frame);
    2626
    27 cucul_canvas_t *bomb_sprite;
    28 cucul_canvas_t *fragbomb_sprite;
     27caca_canvas_t *bomb_sprite;
     28caca_canvas_t *fragbomb_sprite;
    2929
    3030void init_weapons(game *g, weapons *wp)
    3131{
    32     cucul_buffer_t *b;
     32    caca_buffer_t *b;
    3333    int i;
    3434
     
    3838    }
    3939
    40     b = cucul_load_file("data/wpnbomb.caca");
    41     bomb_sprite = cucul_import_canvas(b, "");
    42     cucul_free_buffer(b);
    43 
    44     b = cucul_load_file("data/wpnfrag.caca");
    45     bomb_sprite = cucul_import_canvas(b, "");
    46     cucul_free_buffer(b);
     40    b = caca_load_file("data/wpnbomb.caca");
     41    bomb_sprite = caca_import_canvas(b, "");
     42    caca_free_buffer(b);
     43
     44    b = caca_load_file("data/wpnfrag.caca");
     45    bomb_sprite = caca_import_canvas(b, "");
     46    caca_free_buffer(b);
    4747}
    4848
     
    5656        {
    5757            case WEAPON_LASER:
    58                 cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    59                 cucul_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '|');
    60                 cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    61                 cucul_putchar(g->cv, wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
     58                caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     59                caca_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '|');
     60                caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     61                caca_putchar(g->cv, wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
    6262                break;
    6363            case WEAPON_SEEKER:
    64                 cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    65                 cucul_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
    66                 cucul_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
    67                 cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    68                 cucul_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '@');
     64                caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     65                caca_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
     66                caca_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
     67                caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     68                caca_putchar(g->cv, wp->x[i] >> 4, wp->y[i] >> 4, '@');
    6969                break;
    7070            case WEAPON_BOMB:
    71                 cucul_set_color(g->cv, CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_BLACK);
    72                 cucul_putchar(g->cv, (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
    73                 cucul_putchar(g->cv, (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
    74                 cucul_putchar(g->cv, (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');
    75                 cucul_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
    76                 cucul_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, '.');
     71                caca_set_color(g->cv, CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK);
     72                caca_putchar(g->cv, (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
     73                caca_putchar(g->cv, (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
     74                caca_putchar(g->cv, (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.');
     75                caca_putchar(g->cv, wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
     76                caca_putchar(g->cv, wp->x2[i] >> 4, wp->y2[i] >> 4, '.');
    7777                draw_bomb(g, wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]);
    7878                break;
     
    334334    }
    335335
    336     cucul_set_canvas_frame(bomb_sprite, frame);
    337     cucul_blit(g->cv, x, y, bomb_sprite, NULL);
     336    caca_set_canvas_frame(bomb_sprite, frame);
     337    caca_blit(g->cv, x, y, bomb_sprite, NULL);
    338338}
    339339
     
    341341{
    342342    /* Draw the head */
    343     cucul_set_canvas_frame(fragbomb_sprite, frame & 1);
    344     cucul_blit(g->cv, x, y, fragbomb_sprite, NULL);
     343    caca_set_canvas_frame(fragbomb_sprite, frame & 1);
     344    caca_blit(g->cv, x, y, fragbomb_sprite, NULL);
    345345
    346346    /* Draw the tail */
    347     cucul_set_canvas_frame(fragbomb_sprite, 2 + (frame % 4));
    348     cucul_blit(g->cv, x, y, fragbomb_sprite, NULL);
     347    caca_set_canvas_frame(fragbomb_sprite, 2 + (frame % 4));
     348    caca_blit(g->cv, x, y, fragbomb_sprite, NULL);
    349349}
    350350
     
    357357    {
    358358        case 24:
    359             cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    360             cucul_putstr(g->cv, x, y-3, "__");
    361             cucul_putchar(g->cv, x-1, y-2, '\'');
    362             cucul_putchar(g->cv, x+2, y-2, '`');
     359            caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     360            caca_putstr(g->cv, x, y-3, "__");
     361            caca_putchar(g->cv, x-1, y-2, '\'');
     362            caca_putchar(g->cv, x+2, y-2, '`');
    363363            break;
    364364        case 23:
    365             cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    366             cucul_putstr(g->cv, x, y-3, "__");
    367             cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    368             cucul_putstr(g->cv, x-2, y-2, "-'");
    369             cucul_putstr(g->cv, x+2, y-2, "`-");
     365            caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     366            caca_putstr(g->cv, x, y-3, "__");
     367            caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     368            caca_putstr(g->cv, x-2, y-2, "-'");
     369            caca_putstr(g->cv, x+2, y-2, "`-");
    370370            break;
    371371        case 22:
    372             cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    373             cucul_putstr(g->cv, x, y-3, "__");
    374             cucul_putchar(g->cv, x-1, y-2, '\'');
    375             cucul_putchar(g->cv, x+2, y-2, '`');
    376             cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    377             cucul_putstr(g->cv, x-3, y-2, ",-");
    378             cucul_putstr(g->cv, x+3, y-2, "-.");
     372            caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     373            caca_putstr(g->cv, x, y-3, "__");
     374            caca_putchar(g->cv, x-1, y-2, '\'');
     375            caca_putchar(g->cv, x+2, y-2, '`');
     376            caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     377            caca_putstr(g->cv, x-3, y-2, ",-");
     378            caca_putstr(g->cv, x+3, y-2, "-.");
    379379            break;
    380380        case 21:
    381             cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    382             cucul_putstr(g->cv, x-1, y-3, "____");
    383             cucul_putchar(g->cv, x-2, y-2, '\'');
    384             cucul_putchar(g->cv, x+3, y-2, '`');
    385             cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    386             cucul_putstr(g->cv, x-4, y-2, ",-");
    387             cucul_putstr(g->cv, x+4, y-2, "-.");
     381            caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     382            caca_putstr(g->cv, x-1, y-3, "____");
     383            caca_putchar(g->cv, x-2, y-2, '\'');
     384            caca_putchar(g->cv, x+3, y-2, '`');
     385            caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     386            caca_putstr(g->cv, x-4, y-2, ",-");
     387            caca_putstr(g->cv, x+4, y-2, "-.");
    388388            break;
    389389        case 20:
    390             cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    391             cucul_putstr(g->cv, x, y-3, "%%");
    392             cucul_putchar(g->cv, x-4, y-2, ',');
    393             cucul_putchar(g->cv, x+5, y-2, '.');
    394             cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    395             cucul_putchar(g->cv, x-1, y-3, ':');
    396             cucul_putchar(g->cv, x+2, y-3, ':');
    397             cucul_putstr(g->cv, x-3, y-2, "-'");
    398             cucul_putstr(g->cv, x+3, y-2, "`-");
     390            caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     391            caca_putstr(g->cv, x, y-3, "%%");
     392            caca_putchar(g->cv, x-4, y-2, ',');
     393            caca_putchar(g->cv, x+5, y-2, '.');
     394            caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     395            caca_putchar(g->cv, x-1, y-3, ':');
     396            caca_putchar(g->cv, x+2, y-3, ':');
     397            caca_putstr(g->cv, x-3, y-2, "-'");
     398            caca_putstr(g->cv, x+3, y-2, "`-");
    399399            break;
    400400        case 19:
    401             cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    402             cucul_putstr(g->cv, x, y-4, "%%");
    403             cucul_putstr(g->cv, x, y-3, "##");
    404             cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    405             cucul_putchar(g->cv, x-1, y-4, ':');
    406             cucul_putchar(g->cv, x+2, y-4, ':');
    407             cucul_putchar(g->cv, x-1, y-3, '%');
    408             cucul_putchar(g->cv, x+2, y-3, '%');
    409             cucul_putstr(g->cv, x-4, y-2, ",-'");
    410             cucul_putstr(g->cv, x+3, y-2, "`-.");
    411             cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
    412             cucul_putchar(g->cv, x-2, y-3, ':');
    413             cucul_putchar(g->cv, x+3, y-3, ':');
     401            caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     402            caca_putstr(g->cv, x, y-4, "%%");
     403            caca_putstr(g->cv, x, y-3, "##");
     404            caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     405            caca_putchar(g->cv, x-1, y-4, ':');
     406            caca_putchar(g->cv, x+2, y-4, ':');
     407            caca_putchar(g->cv, x-1, y-3, '%');
     408            caca_putchar(g->cv, x+2, y-3, '%');
     409            caca_putstr(g->cv, x-4, y-2, ",-'");
     410            caca_putstr(g->cv, x+3, y-2, "`-.");
     411            caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK);
     412            caca_putchar(g->cv, x-2, y-3, ':');
     413            caca_putchar(g->cv, x+3, y-3, ':');
    414414            break;
    415415        case 18:
    416416        default:
    417417            r = (18 - frame) * (18 - frame);
    418             cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    419             cucul_putstr(g->cv, x-1, y-5-r, ":%%:");
    420             cucul_putstr(g->cv, x-1, y-4-r, "%##%");
    421             cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    422             cucul_putchar(g->cv, x-2, y-4-r, ':');
    423             cucul_putchar(g->cv, x+3, y-4-r, ':');
    424             cucul_putchar(g->cv, x-2, y-2, '\'');
    425             cucul_putchar(g->cv, x+3, y-2, '`');
    426             cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
    427             cucul_putchar(g->cv, x-3, y-2, ':');
    428             cucul_putchar(g->cv, x+4, y-2, ':');
     418            caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     419            caca_putstr(g->cv, x-1, y-5-r, ":%%:");
     420            caca_putstr(g->cv, x-1, y-4-r, "%##%");
     421            caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     422            caca_putchar(g->cv, x-2, y-4-r, ':');
     423            caca_putchar(g->cv, x+3, y-4-r, ':');
     424            caca_putchar(g->cv, x-2, y-2, '\'');
     425            caca_putchar(g->cv, x+3, y-2, '`');
     426            caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK);
     427            caca_putchar(g->cv, x-3, y-2, ':');
     428            caca_putchar(g->cv, x+4, y-2, ':');
    429429            for(i = 0; i <= r; i++)
    430430            {
    431                 cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
    432                 cucul_putstr(g->cv, x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
    433                 cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_BLACK);
    434                 cucul_putchar(g->cv, x-2, y-3-i, '%');
    435                 cucul_putchar(g->cv, x+3, y-3-i, '%');
    436                 cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
    437                 cucul_putchar(g->cv, x-3, y-3-i, ':');
    438                 cucul_putchar(g->cv, x+4, y-3-i, ':');
     431                caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_BLACK);
     432                caca_putstr(g->cv, x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
     433                caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_BLACK);
     434                caca_putchar(g->cv, x-2, y-3-i, '%');
     435                caca_putchar(g->cv, x+3, y-3-i, '%');
     436                caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK);
     437                caca_putchar(g->cv, x-3, y-3-i, ':');
     438                caca_putchar(g->cv, x+4, y-3-i, ':');
    439439            }
    440440            break;
     
    447447
    448448    /* Lots of duplicate pixels, but we don't care */
    449     cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_BLACK);
    450     cucul_draw_ellipse(g->cv, x, y, r, r / 2, ":");
    451     cucul_set_color(g->cv, CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_BLUE);
    452     cucul_draw_ellipse(g->cv, x, y, r + 1, r / 2, "#");
    453     cucul_set_color(g->cv, CUCUL_COLOR_BLUE, CUCUL_COLOR_LIGHTBLUE);
    454     cucul_draw_ellipse(g->cv, x, y, r + 2, r / 2, "#");
    455     cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_LIGHTBLUE);
    456     cucul_draw_ellipse(g->cv, x, y, r + 2, r / 2 + 1, "#");
    457     cucul_set_color(g->cv, CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_CYAN);
    458     cucul_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 1, "#");
    459     cucul_set_color(g->cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_CYAN);
    460     cucul_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 2, "#");
    461     cucul_set_color(g->cv, CUCUL_COLOR_CYAN, CUCUL_COLOR_WHITE);
    462     cucul_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 2, "#");
    463     cucul_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 3, " ");
    464 }
    465 
     449    caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_BLACK);
     450    caca_draw_ellipse(g->cv, x, y, r, r / 2, ":");
     451    caca_set_color(g->cv, CACA_COLOR_LIGHTBLUE, CACA_COLOR_BLUE);
     452    caca_draw_ellipse(g->cv, x, y, r + 1, r / 2, "#");
     453    caca_set_color(g->cv, CACA_COLOR_BLUE, CACA_COLOR_LIGHTBLUE);
     454    caca_draw_ellipse(g->cv, x, y, r + 2, r / 2, "#");
     455    caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_LIGHTBLUE);
     456    caca_draw_ellipse(g->cv, x, y, r + 2, r / 2 + 1, "#");
     457    caca_set_color(g->cv, CACA_COLOR_LIGHTBLUE, CACA_COLOR_CYAN);
     458    caca_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 1, "#");
     459    caca_set_color(g->cv, CACA_COLOR_WHITE, CACA_COLOR_CYAN);
     460    caca_draw_ellipse(g->cv, x, y, r + 3, r / 2 + 2, "#");
     461    caca_set_color(g->cv, CACA_COLOR_CYAN, CACA_COLOR_WHITE);
     462    caca_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 2, "#");
     463    caca_draw_ellipse(g->cv, x, y, r + 4, r / 2 + 3, " ");
     464}
     465
Note: See TracChangeset for help on using the changeset viewer.