Преглед изворни кода

* 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.


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@365 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam пре 21 година
родитељ
комит
7dde414836
10 измењених фајлова са 77 додато и 99 уклоњено
  1. +13
    -34
      configure.ac
  2. +2
    -10
      src/Makefile.am
  3. +3
    -3
      src/box.c
  4. +2
    -1
      src/ceo.c
  5. +5
    -5
      src/intro.c
  6. +4
    -2
      src/main.c
  7. +10
    -10
      src/overlay.c
  8. +1
    -1
      src/starfield.c
  9. +2
    -2
      src/tunnel.c
  10. +35
    -31
      src/weapons.c

+ 13
- 34
configure.ac Прегледај датотеку

@@ -12,47 +12,26 @@ AM_CONFIG_HEADER(config.h)

AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_RANLIB

dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
dnl now otherwise it might be set in an obscure if statement.
AC_EGREP_CPP(foo,foo)

AC_ARG_ENABLE(slang,
[ --enable-slang slang graphics support (default enabled)])
AC_ARG_ENABLE(ncurses,
[ --enable-ncurses ncurses graphics support (default disabled)])
AC_ARG_ENABLE(conio,
[ --enable-conio DOS conio.h graphics support (default disabled)])

USE_SLANG=false
USE_NCURSES=false
USE_CONIO=false
if test "${enable_conio}" = "yes"; then
AC_CHECK_HEADER(conio.h,:,AC_MSG_ERROR([cannot find conio.h header]))
AC_MSG_CHECKING(for ScreenUpdate in pc.h)
AC_EGREP_HEADER(ScreenUpdate,pc.h,[
AC_MSG_RESULT(yes)
AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
Define if <pc.h> defines ScreenUpdate.)],[
AC_MSG_RESULT(no)])
AC_DEFINE(USE_CONIO, 1, Define if the backend driver is conio.h)
USE_CONIO=:
elif test "${enable_ncurses}" = "yes"; then
AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers]))
AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library]))
AC_DEFINE(USE_NCURSES, 1, Define if the backend driver is ncurses)
USE_NCURSES=:
elif test "${enable_slang}" != "no"; then
AC_CHECK_HEADER(slang.h,:,AC_MSG_ERROR([cannot find slang headers]))
AC_CHECK_LIB(slang,SLkp_init,:,AC_MSG_ERROR([cannot find slang library]))
AC_DEFINE(USE_SLANG, 1, Define if the backend driver is slang)
USE_SLANG=:
AC_MSG_CHECKING(for libcaca support)
video_caca=no
AC_TRY_COMPILE([
#include <caca.h>
],[ ],[video_caca=yes])
AC_MSG_RESULT($video_caca)
if test "$video_caca" = "yes"; then
CACA_CFLAGS="${CFLAGS} `caca-config --cflags`"
CACA_LIBS="${LIBS} `caca-config --libs`"
AC_SUBST(CACA_CFLAGS)
AC_SUBST(CACA_LIBS)
else
AC_MSG_ERROR([cannot find libcaca])
fi

AM_CONDITIONAL(USE_SLANG, ${USE_SLANG})
AM_CONDITIONAL(USE_NCURSES, ${USE_NCURSES})

# Optimizations
CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
# Code qui fait des warnings == code de porc == deux baffes dans ta gueule


+ 2
- 10
src/Makefile.am Прегледај датотеку

@@ -2,15 +2,6 @@
# Automake targets and declarations for ttyvaders
###############################################################################

AM_CPPFLAGS = -I$(top_srcdir)/../libcaca/src

if USE_SLANG
LDFLAGS_slang = -lslang
endif
if USE_NCURSES
LDFLAGS_ncurses = -lncurses
endif

bin_PROGRAMS = ttyvaders

ttyvaders_SOURCES = \
@@ -29,5 +20,6 @@ ttyvaders_SOURCES = \
tunnel.c \
weapons.c \
$(NULL)
ttyvaders_LDADD = ../../libcaca/src/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm
ttyvaders_CFLAGS = @CACA_CFLAGS@
ttyvaders_LDADD = @CACA_LIBS@ -lm


+ 3
- 3
src/box.c Прегледај датотеку

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

caca_set_color(CACA_COLOR_YELLOW);
caca_set_color(CACA_COLOR_YELLOW, CACA_COLOR_BLACK);

/* Draw the thin horizontal line */
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,
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X');

caca_set_color(CACA_COLOR_BLACK);
caca_set_color(CACA_COLOR_BLACK, CACA_COLOR_BLACK);

for(j = b->y - b->h * (frame - 8) / 8 + 1;
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 */
caca_set_color(CACA_COLOR_YELLOW);
caca_set_color(CACA_COLOR_YELLOW, CACA_COLOR_BLACK);

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


+ 2
- 1
src/ceo.c Прегледај датотеку

@@ -35,7 +35,8 @@ void ceo_alert(game *g)
{
caca_clear();

if(caca_get_key() == '\t')
if(caca_get_event(CACA_EVENT_KEY_PRESS)
== (CACA_EVENT_KEY_PRESS | '\t'))
{
end = 1;
}


+ 5
- 5
src/intro.c Прегледај датотеку

@@ -36,7 +36,7 @@ void intro(void)

int frame = 0;

while(caca_get_key() == 0)
while(caca_get_event(CACA_EVENT_KEY_PRESS) == 0)
{
int i, xo, yo, x[5], y[5];

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

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

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

caca_set_color(CACA_COLOR_BLACK);
caca_set_color(CACA_COLOR_BLACK, 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[3], y[3], x[2], y[2], ' ');
caca_draw_line(x[0], y[0], x[2], y[2], ' ');
caca_set_color(CACA_COLOR_GREEN);
caca_set_color(CACA_COLOR_GREEN, CACA_COLOR_BLACK);
caca_draw_thin_polyline(x, y, 4);

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


+ 4
- 2
src/main.c Прегледај датотеку

@@ -98,10 +98,12 @@ static void start_game (game *g)

while(!quit)
{
char key;
int event, key;

while((key = caca_get_key()))
while((event = caca_get_event(CACA_EVENT_KEY_PRESS)))
{
key = event & 0xffffff;

switch(key)
{
case 'q':


+ 10
- 10
src/overlay.c Прегледај датотеку

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

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

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

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

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

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

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

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

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


+ 1
- 1
src/starfield.c Прегледај датотеку

@@ -55,7 +55,7 @@ void draw_starfield(game *g, starfield *s)
{
if(s[i].x >= 0)
{
caca_set_color(s[i].c);
caca_set_color(s[i].c, CACA_COLOR_BLACK);
caca_putchar(s[i].x, s[i].y, s[i].ch);
}
}


+ 2
- 2
src/tunnel.c Прегледај датотеку

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

caca_set_color(CACA_COLOR_GREEN);
caca_set_color(CACA_COLOR_RED, CACA_COLOR_BLACK);

/* Left border */
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_set_color(CACA_COLOR_RED);
caca_set_color(CACA_COLOR_LIGHTRED, CACA_COLOR_RED);

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


+ 35
- 31
src/weapons.c Прегледај датотеку

@@ -56,20 +56,20 @@ void draw_weapons(game *g, weapons *wp)
switch(wp->type[i])
{
case WEAPON_LASER:
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|');
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|');
break;
case WEAPON_SEEKER:
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.');
caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o');
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@');
break;
case WEAPON_BOMB:
caca_set_color(CACA_COLOR_DARKGRAY);
caca_set_color(CACA_COLOR_DARKGRAY, CACA_COLOR_BLACK);
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->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)
{
case 24:
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x, y-3, "__");
caca_putchar(x-1, y-2, '\'');
caca_putchar(x+2, y-2, '`');
break;
case 23:
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putstr(x, y-3, "__");
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x-2, y-2, "-'");
caca_putstr(x+2, y-2, "`-");
break;
case 22:
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putstr(x, y-3, "__");
caca_putchar(x-1, y-2, '\'');
caca_putchar(x+2, y-2, '`');
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x-3, y-2, ",-");
caca_putstr(x+3, y-2, "-.");
break;
case 21:
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putstr(x-1, y-3, "____");
caca_putchar(x-2, y-2, '\'');
caca_putchar(x+3, y-2, '`');
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x-4, y-2, ",-");
caca_putstr(x+4, y-2, "-.");
break;
case 20:
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x, y-3, "%%");
caca_putchar(x-4, y-2, ',');
caca_putchar(x+5, y-2, '.');
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putchar(x-1, y-3, ':');
caca_putchar(x+2, y-3, ':');
caca_putstr(x-3, y-2, "-'");
caca_putstr(x+3, y-2, "`-");
break;
case 19:
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x, y-4, "%%");
caca_putstr(x, y-3, "##");
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putchar(x-1, y-4, ':');
caca_putchar(x+2, y-4, ':');
caca_putchar(x-1, y-3, '%');
caca_putchar(x+2, y-3, '%');
caca_putstr(x-4, y-2, ",-'");
caca_putstr(x+3, y-2, "`-.");
caca_set_color(CACA_COLOR_BLUE);
caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
caca_putchar(x-2, y-3, ':');
caca_putchar(x+3, y-3, ':');
break;
case 18:
default:
r = (18 - frame) * (18 - frame);
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x-1, y-5-r, ":%%:");
caca_putstr(x-1, y-4-r, "%##%");
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putchar(x-2, y-4-r, ':');
caca_putchar(x+3, y-4-r, ':');
caca_putchar(x-2, y-2, '\'');
caca_putchar(x+3, y-2, '`');
caca_set_color(CACA_COLOR_BLUE);
caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
caca_putchar(x-3, y-2, ':');
caca_putchar(x+4, y-2, ':');
for(i = 0; i <= r; i++)
{
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLACK);
caca_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%");
caca_set_color(CACA_COLOR_CYAN);
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_BLACK);
caca_putchar(x-2, y-3-i, '%');
caca_putchar(x+3, y-3-i, '%');
caca_set_color(CACA_COLOR_BLUE);
caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
caca_putchar(x-3, y-3-i, ':');
caca_putchar(x+4, y-3-i, ':');
}
@@ -444,16 +444,20 @@ static void draw_nuke(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(CACA_COLOR_BLUE);
caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_BLACK);
caca_draw_ellipse(x, y, r, r / 2, ':');
caca_draw_ellipse(x, y, r + 1, r / 2, ':');
caca_draw_ellipse(x, y, r + 2, r / 2, ':');
caca_set_color(CACA_COLOR_CYAN);
caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '%');
caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '%');
caca_set_color(CACA_COLOR_WHITE);
caca_set_color(CACA_COLOR_LIGHTBLUE, CACA_COLOR_BLUE);
caca_draw_ellipse(x, y, r + 1, r / 2, '#');
caca_set_color(CACA_COLOR_BLUE, CACA_COLOR_LIGHTBLUE);
caca_draw_ellipse(x, y, r + 2, r / 2, '#');
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_LIGHTBLUE);
caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '#');
caca_set_color(CACA_COLOR_LIGHTBLUE, CACA_COLOR_CYAN);
caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '#');
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_CYAN);
caca_draw_ellipse(x, y, r + 3, r / 2 + 2, '#');
caca_set_color(CACA_COLOR_CYAN, CACA_COLOR_WHITE);
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…
Откажи
Сачувај