Changeset 365 for ttyvaders


Ignore:
Timestamp:
Feb 17, 2004, 2:53:14 PM (19 years ago)
Author:
Sam Hocevar
Message:
  • configure.ac: + No longer check for ncurses etc., we use caca-config.
  • src/*: + Updated to new libcaca API, mainly caca_get_event() and caca_set_color()

calls.

Location:
ttyvaders/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/configure.ac

    r191 r365  
    1313AM_PROG_CC_C_O
    1414AC_PROG_CPP
    15 AC_PROG_RANLIB
    1615
    1716dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
     
    1918AC_EGREP_CPP(foo,foo)
    2019
    21 AC_ARG_ENABLE(slang,
    22   [  --enable-slang          slang graphics support (default enabled)])
    23 AC_ARG_ENABLE(ncurses,
    24   [  --enable-ncurses        ncurses graphics support (default disabled)])
    25 AC_ARG_ENABLE(conio,
    26   [  --enable-conio          DOS conio.h graphics support (default disabled)])
    27 
    28 USE_SLANG=false
    29 USE_NCURSES=false
    30 USE_CONIO=false
    31 if test "${enable_conio}" = "yes"; then
    32   AC_CHECK_HEADER(conio.h,:,AC_MSG_ERROR([cannot find conio.h header]))
    33   AC_MSG_CHECKING(for ScreenUpdate in pc.h)
    34   AC_EGREP_HEADER(ScreenUpdate,pc.h,[
    35     AC_MSG_RESULT(yes)
    36     AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
    37               Define if <pc.h> defines ScreenUpdate.)],[
    38     AC_MSG_RESULT(no)])
    39   AC_DEFINE(USE_CONIO, 1, Define if the backend driver is conio.h)
    40   USE_CONIO=:
    41 elif test "${enable_ncurses}" = "yes"; then
    42   AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers]))
    43   AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library]))
    44   AC_DEFINE(USE_NCURSES, 1, Define if the backend driver is ncurses)
    45   USE_NCURSES=:
    46 elif test "${enable_slang}" != "no"; then
    47   AC_CHECK_HEADER(slang.h,:,AC_MSG_ERROR([cannot find slang headers]))
    48   AC_CHECK_LIB(slang,SLkp_init,:,AC_MSG_ERROR([cannot find slang library]))
    49   AC_DEFINE(USE_SLANG, 1, Define if the backend driver is slang)
    50   USE_SLANG=:
     20AC_MSG_CHECKING(for libcaca support)
     21video_caca=no
     22AC_TRY_COMPILE([
     23  #include <caca.h>
     24],[ ],[video_caca=yes])
     25AC_MSG_RESULT($video_caca)
     26if test "$video_caca" = "yes"; then
     27  CACA_CFLAGS="${CFLAGS} `caca-config --cflags`"
     28  CACA_LIBS="${LIBS} `caca-config --libs`"
     29  AC_SUBST(CACA_CFLAGS)
     30  AC_SUBST(CACA_LIBS)
     31else
     32  AC_MSG_ERROR([cannot find libcaca])
    5133fi
    52 
    53 AM_CONDITIONAL(USE_SLANG, ${USE_SLANG})
    54 AM_CONDITIONAL(USE_NCURSES, ${USE_NCURSES})
    5534
    5635# Optimizations
  • ttyvaders/trunk/src/Makefile.am

    r191 r365  
    22# Automake targets and declarations for ttyvaders
    33###############################################################################
    4 
    5 AM_CPPFLAGS = -I$(top_srcdir)/../libcaca/src
    6 
    7 if USE_SLANG
    8 LDFLAGS_slang = -lslang
    9 endif
    10 if USE_NCURSES
    11 LDFLAGS_ncurses = -lncurses
    12 endif
    134
    145bin_PROGRAMS = ttyvaders
     
    3021        weapons.c \
    3122        $(NULL)
    32 ttyvaders_LDADD = ../../libcaca/src/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm
     23ttyvaders_CFLAGS = @CACA_CFLAGS@
     24ttyvaders_LDADD = @CACA_LIBS@ -lm
    3325
  • ttyvaders/trunk/src/box.c

    r194 r365  
    4646    int j, frame;
    4747
    48     caca_set_color(CACA_COLOR_YELLOW);
     48    caca_set_color(CACA_COLOR_YELLOW, CACA_COLOR_BLACK);
    4949
    5050    /* Draw the thin horizontal line */
     
    6969                 b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X');
    7070
    71     caca_set_color(CACA_COLOR_BLACK);
     71    caca_set_color(CACA_COLOR_BLACK, CACA_COLOR_BLACK);
    7272
    7373    for(j = b->y - b->h * (frame - 8) / 8 + 1;
     
    8585
    8686    /* Draw the text inside the frame */
    87     caca_set_color(CACA_COLOR_YELLOW);
     87    caca_set_color(CACA_COLOR_YELLOW, CACA_COLOR_BLACK);
    8888
    8989    /* FIXME: use a font */
  • ttyvaders/trunk/src/ceo.c

    r186 r365  
    3636        caca_clear();
    3737
    38         if(caca_get_key() == '\t')
     38        if(caca_get_event(CACA_EVENT_KEY_PRESS)
     39            == (CACA_EVENT_KEY_PRESS | '\t'))
    3940        {
    4041            end = 1;
  • ttyvaders/trunk/src/intro.c

    r194 r365  
    3737    int frame = 0;
    3838
    39     while(caca_get_key() == 0)
     39    while(caca_get_event(CACA_EVENT_KEY_PRESS) == 0)
    4040    {
    4141        int i, xo, yo, x[5], y[5];
     
    4848        yo = caca_get_height() / 2;
    4949
    50         caca_set_color(CACA_COLOR_RED);
     50        caca_set_color(CACA_COLOR_RED, CACA_COLOR_BLACK);
    5151        caca_fill_ellipse(xo, yo, 16, 8, '#');
    52         caca_set_color(CACA_COLOR_GREEN);
     52        caca_set_color(CACA_COLOR_GREEN, CACA_COLOR_BLACK);
    5353        caca_draw_thin_ellipse(xo, yo, 16, 8);
    5454
     
    6161        y[4] = y[0];
    6262
    63         caca_set_color(CACA_COLOR_BLACK);
     63        caca_set_color(CACA_COLOR_BLACK, CACA_COLOR_BLACK);
    6464        caca_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' ');
    6565        caca_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' ');
    6666        caca_draw_line(x[0], y[0], x[2], y[2], ' ');
    67         caca_set_color(CACA_COLOR_GREEN);
     67        caca_set_color(CACA_COLOR_GREEN, CACA_COLOR_BLACK);
    6868        caca_draw_thin_polyline(x, y, 4);
    6969
  • ttyvaders/trunk/src/main.c

    r194 r365  
    9999    while(!quit)
    100100    {
    101         char key;
    102 
    103         while((key = caca_get_key()))
     101        int event, key;
     102
     103        while((event = caca_get_event(CACA_EVENT_KEY_PRESS)))
    104104        {
     105            key = event & 0xffffff;
     106
    105107            switch(key)
    106108            {
  • ttyvaders/trunk/src/overlay.c

    r194 r365  
    3333
    3434    /* Draw life jauge */
    35     caca_set_color(CACA_COLOR_DARKGRAY);
     35    caca_set_color(CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK);
    3636    caca_putstr(4, 1, dots30);
    3737
    3838    if(g->p->life > MAX_LIFE * 7 / 10)
    3939    {
    40         caca_set_color(CACA_COLOR_GREEN);
     40        caca_set_color(CACA_COLOR_GREEN, CACA_COLOR_BLACK);
    4141    }
    4242    else if(g->p->life > MAX_LIFE * 3 / 10)
    4343    {
    44         caca_set_color(CACA_COLOR_YELLOW);
     44        caca_set_color(CACA_COLOR_YELLOW, CACA_COLOR_BLACK);
    4545    }
    4646    else
    4747    {
    48         caca_set_color(CACA_COLOR_RED);
     48        caca_set_color(CACA_COLOR_RED, CACA_COLOR_BLACK);
    4949    }
    5050
    5151    caca_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);
    5252
    53     caca_set_color(CACA_COLOR_WHITE);
     53    caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    5454    caca_putstr(1, 1, "L |");
    5555    caca_putstr(34, 1, "|");
    5656
    5757    /* Draw weapon jauge */
    58     caca_set_color(CACA_COLOR_DARKGRAY);
     58    caca_set_color(CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK);
    5959    caca_putstr(42, 1, dots30 + 10);
    6060
    6161    if(g->p->special > MAX_SPECIAL * 9 / 10)
    6262    {
    63         caca_set_color(CACA_COLOR_WHITE);
     63        caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    6464    }
    6565    else if(g->p->special > MAX_SPECIAL * 3 / 10)
    6666    {
    67         caca_set_color(CACA_COLOR_CYAN);
     67        caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    6868    }
    6969    else
    7070    {
    71         caca_set_color(CACA_COLOR_BLUE);
     71        caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
    7272    }
    7373
     
    7575                       + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL);
    7676
    77     caca_set_color(CACA_COLOR_WHITE);
     77    caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    7878    caca_putstr(39, 1, "S |");
    7979    caca_putstr(62, 1, "|");
  • ttyvaders/trunk/src/starfield.c

    r194 r365  
    5656        if(s[i].x >= 0)
    5757        {
    58             caca_set_color(s[i].c);
     58            caca_set_color(s[i].c, CACA_COLOR_BLACK);
    5959            caca_putchar(s[i].x, s[i].y, s[i].ch);
    6060        }
  • ttyvaders/trunk/src/tunnel.c

    r194 r365  
    7878    char c;
    7979
    80     caca_set_color(CACA_COLOR_GREEN);
     80    caca_set_color(CACA_COLOR_RED, CACA_COLOR_BLACK);
    8181
    8282    /* Left border */
     
    116116    }
    117117
    118     caca_set_color(CACA_COLOR_RED);
     118    caca_set_color(CACA_COLOR_LIGHTRED, CACA_COLOR_RED);
    119119
    120120    /* Left concrete */
  • ttyvaders/trunk/src/weapons.c

    r194 r365  
    5757        {
    5858            case WEAPON_LASER:
    59                 caca_set_color(CACA_COLOR_WHITE);
     59                caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    6060                caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|');
    61                 caca_set_color(CACA_COLOR_CYAN);
     61                caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    6262                caca_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
    6363                break;
    6464            case WEAPON_SEEKER:
    65                 caca_set_color(CACA_COLOR_CYAN);
     65                caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    6666                caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
    6767                caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
    68                 caca_set_color(CACA_COLOR_WHITE);
     68                caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    6969                caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@');
    7070                break;
    7171            case WEAPON_BOMB:
    72                 caca_set_color(CACA_COLOR_DARKGRAY);
     72                caca_set_color(CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK);
    7373                caca_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.');
    7474                caca_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.');
     
    355355    {
    356356        case 24:
    357             caca_set_color(CACA_COLOR_WHITE);
     357            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    358358            caca_putstr(x, y-3, "__");
    359359            caca_putchar(x-1, y-2, '\'');
     
    361361            break;
    362362        case 23:
    363             caca_set_color(CACA_COLOR_CYAN);
     363            caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    364364            caca_putstr(x, y-3, "__");
    365             caca_set_color(CACA_COLOR_WHITE);
     365            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    366366            caca_putstr(x-2, y-2, "-'");
    367367            caca_putstr(x+2, y-2, "`-");
    368368            break;
    369369        case 22:
    370             caca_set_color(CACA_COLOR_CYAN);
     370            caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    371371            caca_putstr(x, y-3, "__");
    372372            caca_putchar(x-1, y-2, '\'');
    373373            caca_putchar(x+2, y-2, '`');
    374             caca_set_color(CACA_COLOR_WHITE);
     374            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    375375            caca_putstr(x-3, y-2, ",-");
    376376            caca_putstr(x+3, y-2, "-.");
    377377            break;
    378378        case 21:
    379             caca_set_color(CACA_COLOR_CYAN);
     379            caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    380380            caca_putstr(x-1, y-3, "____");
    381381            caca_putchar(x-2, y-2, '\'');
    382382            caca_putchar(x+3, y-2, '`');
    383             caca_set_color(CACA_COLOR_WHITE);
     383            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    384384            caca_putstr(x-4, y-2, ",-");
    385385            caca_putstr(x+4, y-2, "-.");
    386386            break;
    387387        case 20:
    388             caca_set_color(CACA_COLOR_WHITE);
     388            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    389389            caca_putstr(x, y-3, "%%");
    390390            caca_putchar(x-4, y-2, ',');
    391391            caca_putchar(x+5, y-2, '.');
    392             caca_set_color(CACA_COLOR_CYAN);
     392            caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    393393            caca_putchar(x-1, y-3, ':');
    394394            caca_putchar(x+2, y-3, ':');
     
    397397            break;
    398398        case 19:
    399             caca_set_color(CACA_COLOR_WHITE);
     399            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    400400            caca_putstr(x, y-4, "%%");
    401401            caca_putstr(x, y-3, "##");
    402             caca_set_color(CACA_COLOR_CYAN);
     402            caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    403403            caca_putchar(x-1, y-4, ':');
    404404            caca_putchar(x+2, y-4, ':');
     
    407407            caca_putstr(x-4, y-2, ",-'");
    408408            caca_putstr(x+3, y-2, "`-.");
    409             caca_set_color(CACA_COLOR_BLUE);
     409            caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
    410410            caca_putchar(x-2, y-3, ':');
    411411            caca_putchar(x+3, y-3, ':');
     
    414414        default:
    415415            r = (18 - frame) * (18 - frame);
    416             caca_set_color(CACA_COLOR_WHITE);
     416            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    417417            caca_putstr(x-1, y-5-r, ":%%:");
    418418            caca_putstr(x-1, y-4-r, "%##%");
    419             caca_set_color(CACA_COLOR_CYAN);
     419            caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    420420            caca_putchar(x-2, y-4-r, ':');
    421421            caca_putchar(x+3, y-4-r, ':');
    422422            caca_putchar(x-2, y-2, '\'');
    423423            caca_putchar(x+3, y-2, '`');
    424             caca_set_color(CACA_COLOR_BLUE);
     424            caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
    425425            caca_putchar(x-3, y-2, ':');
    426426            caca_putchar(x+4, y-2, ':');
    427427            for(i = 0; i <= r; i++)
    428428            {
    429                 caca_set_color(CACA_COLOR_WHITE);
     429                caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
    430430                caca_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
    431                 caca_set_color(CACA_COLOR_CYAN);
     431                caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
    432432                caca_putchar(x-2, y-3-i, '%');
    433433                caca_putchar(x+3, y-3-i, '%');
    434                 caca_set_color(CACA_COLOR_BLUE);
     434                caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
    435435                caca_putchar(x-3, y-3-i, ':');
    436436                caca_putchar(x+4, y-3-i, ':');
     
    445445
    446446    /* Lots of duplicate pixels, but we don't care */
    447     caca_set_color(CACA_COLOR_BLUE);
     447    caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
    448448    caca_draw_ellipse(x, y, r, r / 2, ':');
    449     caca_draw_ellipse(x, y, r + 1, r / 2, ':');
    450     caca_draw_ellipse(x, y, r + 2, r / 2, ':');
    451     caca_set_color(CACA_COLOR_CYAN);
    452     caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '%');
    453     caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '%');
    454     caca_set_color(CACA_COLOR_WHITE);
     449    caca_set_color(CACA_COLOR_LIGHTBLUE, CACA_COLOR_BLUE);
     450    caca_draw_ellipse(x, y, r + 1, r / 2, '#');
     451    caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_LIGHTBLUE);
     452    caca_draw_ellipse(x, y, r + 2, r / 2, '#');
     453    caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_LIGHTBLUE);
     454    caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '#');
     455    caca_set_color(CACA_COLOR_LIGHTBLUE, CACA_COLOR_CYAN);
     456    caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '#');
     457    caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_CYAN);
    455458    caca_draw_ellipse(x, y, r + 3, r / 2 + 2, '#');
     459    caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_WHITE);
    456460    caca_draw_ellipse(x, y, r + 4, r / 2 + 2, '#');
    457     caca_draw_ellipse(x, y, r + 4, r / 2 + 3, '#');
    458 }
    459 
     461    caca_draw_ellipse(x, y, r + 4, r / 2 + 3, ' ');
     462}
     463
Note: See TracChangeset for help on using the changeset viewer.