浏览代码

* libee is now standalone.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@80 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 21 年前
父节点
当前提交
e0ce033c79
共有 16 个文件被更改,包括 771 次插入738 次删除
  1. +2
    -2
      libee/Makefile.am
  2. +82
    -82
      libee/ee.c
  3. +74
    -0
      libee/ee.h
  4. +1
    -1
      src/Makefile.am
  5. +75
    -75
      src/aliens.c
  6. +23
    -23
      src/bonus.c
  7. +26
    -26
      src/box.c
  8. +3
    -3
      src/ceo.c
  9. +1
    -43
      src/common.h
  10. +88
    -88
      src/explosions.c
  11. +7
    -6
      src/main.c
  12. +27
    -27
      src/overlay.c
  13. +13
    -13
      src/player.c
  14. +4
    -4
      src/starfield.c
  15. +15
    -15
      src/tunnel.c
  16. +330
    -330
      src/weapons.c

+ 2
- 2
libee/Makefile.am 查看文件

@@ -6,6 +6,6 @@ CPPFLAGS_ncurses = -DUSE_NCURSES
endif

lib_LIBRARIES = libee.a
libee_a_SOURCES = ee.c
libee_a_CPPFLAGS = -I../src $(CPPFLAGS_slang) $(CPPFLAGS_ncurses)
libee_a_SOURCES = ee.c ee.h
libee_a_CPPFLAGS = $(CPPFLAGS_slang) $(CPPFLAGS_ncurses)


+ 82
- 82
libee/ee.c 查看文件

@@ -1,6 +1,6 @@
/*
* ttyvaders Textmode shoot'em up
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* libee ASCII-Art library
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
@@ -27,34 +27,44 @@
#include <sys/time.h>
#include <time.h>

#include "common.h"
#include "ee.h"

int init_graphics( void )
int ee_init(void)
{
#ifdef USE_SLANG
static char * colors[] = { "black", "green", "yellow", "white",
"red", "gray", "lightgray", "blue", "cyan", "magenta", NULL };
int i;

/* Initialize slang library */
SLsig_block_signals();
SLtt_get_terminfo();

if( SLkp_init() == -1 )
if(SLkp_init() == -1)
{
SLsig_unblock_signals();
return 1;
return -1;
}

SLang_init_tty (-1, 0, 1);
SLang_init_tty(-1, 0, 1);

if( SLsmg_init_smg() == -1 )
if(SLsmg_init_smg() == -1)
{
SLsig_unblock_signals();
return 1;
return -1;
}

SLsig_unblock_signals();

SLsmg_cls();
SLtt_set_cursor_visibility( 0 );
SLtt_set_cursor_visibility(0);
SLsmg_refresh();

for(i = 0; colors[i]; i++)
{
SLtt_set_color(i + 1, NULL, colors[i], "black");
}

#elif USE_NCURSES
/* Initialize ncurses library */
initscr();
@@ -63,99 +73,68 @@ int init_graphics( void )
cbreak();
noecho();
nodelay(stdscr, TRUE);
curs_set( 0 );
curs_set(0);

start_color();

init_pair(EE_BLACK, COLOR_BLACK, COLOR_BLACK);
init_pair(EE_GREEN, COLOR_GREEN, COLOR_BLACK);
init_pair(EE_YELLOW, COLOR_YELLOW, COLOR_BLACK);
init_pair(EE_WHITE, COLOR_WHITE, COLOR_BLACK);
init_pair(EE_RED, COLOR_RED, COLOR_BLACK);
init_pair(EE_GRAY, COLOR_WHITE, COLOR_BLACK); // XXX
init_pair(EE_LIGHTGRAY, COLOR_WHITE, COLOR_BLACK); // XXX
init_pair(EE_BLUE, COLOR_BLUE, COLOR_BLACK);
init_pair(EE_CYAN, COLOR_CYAN, COLOR_BLACK);
init_pair(EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);

#else
/* Dummy driver */

#endif

return 0;
}

void init_game( game *g )
int ee_get_width(void)
{
#ifdef USE_SLANG
static char * const colors[] =
{
"black", "green", "yellow", "white",
"red", "gray", "lightgray", "blue", "cyan", "magenta", NULL
};

int i;

for( i = 0; colors[i] ; i++ )
{
SLtt_set_color( i+1, NULL, colors[i], "black" );
}

g->w = SLtt_Screen_Cols;
g->h = SLtt_Screen_Rows;
return SLtt_Screen_Cols;
#elif USE_NCURSES
start_color();

init_pair( BLACK, COLOR_BLACK, COLOR_BLACK );
init_pair( GREEN, COLOR_GREEN, COLOR_BLACK );
init_pair( YELLOW, COLOR_YELLOW, COLOR_BLACK );
init_pair( WHITE, COLOR_WHITE, COLOR_BLACK );
init_pair( RED, COLOR_RED, COLOR_BLACK );
init_pair( GRAY, COLOR_WHITE, COLOR_BLACK ); // XXX
init_pair( LIGHTGRAY, COLOR_WHITE, COLOR_BLACK ); // XXX
init_pair( BLUE, COLOR_BLUE, COLOR_BLACK );
init_pair( CYAN, COLOR_CYAN, COLOR_BLACK );
init_pair( MAGENTA, COLOR_MAGENTA, COLOR_BLACK );

g->w = COLS;
g->h = LINES;
return COLS;
#else
/* Use dummy driver */
g->w = 80;
g->h = 25;
return 80;
#endif
}

char get_key( void )
int ee_get_height(void)
{
#ifdef USE_SLANG
if( SLang_input_pending (0) )
{
return SLang_getkey();
}
return SLtt_Screen_Rows;
#elif USE_NCURSES
char key;

if( ( key = getch() ) != ERR )
{
return key;
}
return LINES;
#else
/* Use dummy driver */
char key = GET_RAND(0,256);

if( key != 'q' && key != 'p' && key != '\t' )
{
return key;
}
return 25;
#endif

return 0;
}

void clear_graphics( game *g )
void ee_clear(void)
{
#ifdef USE_SLANG
//SLsmg_cls();
int y;
for( y = 0; y < g->h; y++ )
for(y = 0; y < ee_get_height(); y++)
{
gfx_goto( 0, y );
gfx_putstr( " " );
ee_goto(0, y);
ee_putstr(" ");
}
#elif USE_NCURSES
//clear();
int y;
for( y = 0; y < g->h; y++ )
for(y = 0; y < ee_get_height(); y++)
{
gfx_goto( 0, y );
gfx_putstr( " " );
ee_goto(0, y);
ee_putstr(" ");
}
#else
/* Use dummy driver */
@@ -175,21 +154,20 @@ static int64_t local_time(void)
}

#define DELAY 40000

void refresh_graphics( void )
void ee_refresh(void)
{
static int64_t local_clock = 0;
int64_t now;

gfx_goto( 0, 0 );
ee_goto(0, 0);

if( !local_clock )
if(!local_clock)
{
/* Initialize local_clock */
local_clock = local_time();
}

if( local_time() > local_clock + 10000 )
if(local_time() > local_clock + 10000)
{
/* If we are late, we shouldn't display anything */
}
@@ -204,25 +182,47 @@ void refresh_graphics( void )

now = local_time();

if( now < local_clock + DELAY - 10000 )
if(now < local_clock + DELAY - 10000)
{
usleep( local_clock + DELAY - 10000 - now );
usleep(local_clock + DELAY - 10000 - now);
}

local_clock += DELAY;
}

void end_graphics( void )
void ee_end(void)
{
#ifdef USE_SLANG
SLtt_set_cursor_visibility( 1 );
SLtt_set_cursor_visibility(1);
SLang_reset_tty();
SLsmg_reset_smg();
#elif USE_NCURSES
curs_set( 1 );
curs_set(1);
endwin();
#else
/* Use dummy driver */
#endif
}

char ee_get_key(void)
{
#ifdef USE_SLANG
if(SLang_input_pending(0))
{
return SLang_getkey();
}
#elif USE_NCURSES
char key = getch();

if(key != ERR)
{
return key;
}
#else
return 0;

#endif

return 0;
}


+ 74
- 0
libee/ee.h 查看文件

@@ -0,0 +1,74 @@
/*
* libee ASCII-Art library
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Graphics primitives
*/
#ifdef USE_SLANG
# include <slang.h>
# define ee_color(x) SLsmg_set_color(x)
# define ee_goto(x,y) SLsmg_gotorc(y,x)
# define ee_putchar(x) SLsmg_write_char(x)
# define ee_putstr(x) SLsmg_write_string(x)
#elif USE_NCURSES
# define box box_divert
# include <curses.h>
# undef box
# define ee_color(x) attrset(COLOR_PAIR(x))
# define ee_goto(x,y) move(y,x)
# define ee_putchar(x) addch(x)
# define ee_putstr(x) addstr(x)
#else
# define ee_color(x) (void)(x)
# define ee_goto(x,y) do{ (void)(x); (void)(y); } while(0)
# define ee_putchar(x) (void)(x)
# define ee_putstr(x) (void)(x)
#endif

#define ee_putcharTO(x,y,c) do{ ee_goto(x,y); ee_putchar(c); }while(0)

/*
* Colours
*/
#define EE_BLACK 1
#define EE_GREEN 2
#define EE_YELLOW 3
#define EE_WHITE 4
#define EE_RED 5
#define EE_GRAY 6
#define EE_LIGHTGRAY 7
#define EE_BLUE 8
#define EE_CYAN 9
#define EE_MAGENTA 10

/*
* Prototypes
*/
int ee_init(void);
int ee_get_width(void);
int ee_get_height(void);
void ee_clear(void);
void ee_refresh(void);
void ee_end(void);

char ee_get_key(void);


+ 1
- 1
src/Makefile.am 查看文件

@@ -35,6 +35,6 @@ ttyvaders_SOURCES = \
weapons.c \
$(NULL)

ttyvaders_CPPFLAGS = $(CPPFLAGS_slang) $(CPPFLAGS_ncurses)
ttyvaders_CPPFLAGS = -I../libee $(CPPFLAGS_slang) $(CPPFLAGS_ncurses)
ttyvaders_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses)


+ 75
- 75
src/aliens.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: aliens.c,v 1.8 2002/12/23 13:46:27 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -133,127 +133,127 @@ static void draw_alien_bar( game *g, int x, int y, int frame )
switch( frame )
{
case 0:
gfx_color( MAGENTA );
gfx_goto( x, y );
gfx_putstr( ",---." );
gfx_goto( x, y+1 );
gfx_putchar( '\\' );
gfx_color( WHITE );
gfx_putstr( "o O" );
gfx_color( MAGENTA );
gfx_putchar( '/' );
gfx_goto( x, y+2 );
gfx_putstr( "^^^^^" );
ee_color( EE_MAGENTA );
ee_goto( x, y );
ee_putstr( ",---." );
ee_goto( x, y+1 );
ee_putchar( '\\' );
ee_color( EE_WHITE );
ee_putstr( "o O" );
ee_color( EE_MAGENTA );
ee_putchar( '/' );
ee_goto( x, y+2 );
ee_putstr( "^^^^^" );
break;
case 1:
gfx_color( MAGENTA );
gfx_goto( x, y );
gfx_putstr( ",---." );
gfx_goto( x, y+1 );
gfx_putchar( '\\' );
gfx_color( WHITE );
gfx_putstr( "O o" );
gfx_color( MAGENTA );
gfx_putchar( '/' );
gfx_goto( x, y+2 );
gfx_putstr( "^^^^^" );
ee_color( EE_MAGENTA );
ee_goto( x, y );
ee_putstr( ",---." );
ee_goto( x, y+1 );
ee_putchar( '\\' );
ee_color( EE_WHITE );
ee_putstr( "O o" );
ee_color( EE_MAGENTA );
ee_putchar( '/' );
ee_goto( x, y+2 );
ee_putstr( "^^^^^" );
break;
}
}

static void draw_alien_baz( game *g, int x, int y, int frame )
{
gfx_color( GREEN );
gfx_goto( x, y-1 );
gfx_putstr( "__" );
ee_color( EE_GREEN );
ee_goto( x, y-1 );
ee_putstr( "__" );

gfx_goto( x-1, y );
gfx_putchar( '/' );
gfx_goto( x+2, y );
gfx_putchar( '\\' );
ee_goto( x-1, y );
ee_putchar( '/' );
ee_goto( x+2, y );
ee_putchar( '\\' );

switch( frame )
{
case 3:
gfx_goto( x-2, y+1 );
gfx_putstr( "//'`\\\\" );
ee_goto( x-2, y+1 );
ee_putstr( "//'`\\\\" );
break;
case 4:
case 2:
gfx_goto( x-2, y+1 );
gfx_putstr( "/(~~)\\" );
ee_goto( x-2, y+1 );
ee_putstr( "/(~~)\\" );
break;
case 5:
case 1:
gfx_goto( x-2, y+1 );
gfx_putstr( "((^^))" );
ee_goto( x-2, y+1 );
ee_putstr( "((^^))" );
break;
case 0:
gfx_goto( x-1, y+1 );
gfx_putstr( "\\\\//" );
ee_goto( x-1, y+1 );
ee_putstr( "\\\\//" );
break;
}

gfx_color( WHITE );
gfx_goto( x, y );
gfx_putstr( "oo" );
ee_color( EE_WHITE );
ee_goto( x, y );
ee_putstr( "oo" );
}

static void draw_alien_foo( game *g, int x, int y, int frame )
{
gfx_color( YELLOW );
ee_color( EE_YELLOW );

switch( frame )
{
case 0:
gfx_goto( x, y );
gfx_putchar( '.' );
gfx_goto( x+6, y );
gfx_putchar( ',' );
gfx_goto( x+1, y+1 );
gfx_putstr( "\\ X /" );
ee_goto( x, y );
ee_putchar( '.' );
ee_goto( x+6, y );
ee_putchar( ',' );
ee_goto( x+1, y+1 );
ee_putstr( "\\ X /" );
break;
case 7:
case 1:
gfx_goto( x-1, y );
gfx_putchar( '.' );
gfx_goto( x+7, y );
gfx_putchar( ',' );
gfx_goto( x, y+1 );
gfx_putstr( "`- X -'" );
ee_goto( x-1, y );
ee_putchar( '.' );
ee_goto( x+7, y );
ee_putchar( ',' );
ee_goto( x, y+1 );
ee_putstr( "`- X -'" );
break;
case 6:
case 2:
gfx_goto( x-1, y+1 );
gfx_putstr( "`-- X --'" );
ee_goto( x-1, y+1 );
ee_putstr( "`-- X --'" );
break;
case 5:
case 3:
gfx_goto( x, y+1 );
gfx_putstr( ",- X -." );
gfx_goto( x-1, y+2 );
gfx_putchar( '\'' );
gfx_goto( x+7, y+2 );
gfx_putchar( '`' );
ee_goto( x, y+1 );
ee_putstr( ",- X -." );
ee_goto( x-1, y+2 );
ee_putchar( '\'' );
ee_goto( x+7, y+2 );
ee_putchar( '`' );
break;
case 4:
gfx_goto( x+1, y+1 );
gfx_putstr( ", X ." );
gfx_goto( x, y+2 );
gfx_putchar( '/' );
gfx_goto( x+6, y+2 );
gfx_putchar( '\\' );
ee_goto( x+1, y+1 );
ee_putstr( ", X ." );
ee_goto( x, y+2 );
ee_putchar( '/' );
ee_goto( x+6, y+2 );
ee_putchar( '\\' );
break;
}

gfx_goto( x+2, y+2 );
gfx_putstr( "`V'" );
ee_goto( x+2, y+2 );
ee_putstr( "`V'" );

gfx_color( WHITE );
gfx_goto( x+2, y+1 );
gfx_putchar( 'o' );
gfx_goto( x+4, y+1 );
gfx_putchar( 'o' );
ee_color( EE_WHITE );
ee_goto( x+2, y+1 );
ee_putchar( 'o' );
ee_goto( x+4, y+1 );
ee_putchar( 'o' );
}



+ 23
- 23
src/bonus.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: bonus.c,v 1.3 2002/12/22 18:44:12 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,30 +43,30 @@ void draw_bonus( game *g, bonus *bo )
switch( bo->type[i] )
{
case BONUS_GREEN:
gfx_color( (bo->n[i]/2 % 3) ? GREEN : WHITE );
gfx_goto( bo->x[i]+1, bo->y[i]-1 );
gfx_putchar( '_' );
gfx_goto( bo->x[i], bo->y[i] );
gfx_putstr( "/ \\" );
gfx_goto( bo->x[i], bo->y[i]+1 );
gfx_putstr( "\\_/" );
gfx_color( WHITE );
gfx_goto( bo->x[i]+1, bo->y[i] );
gfx_putchar( 'g' );
ee_color( (bo->n[i]/2 % 3) ? EE_GREEN : EE_WHITE );
ee_goto( bo->x[i]+1, bo->y[i]-1 );
ee_putchar( '_' );
ee_goto( bo->x[i], bo->y[i] );
ee_putstr( "/ \\" );
ee_goto( bo->x[i], bo->y[i]+1 );
ee_putstr( "\\_/" );
ee_color( EE_WHITE );
ee_goto( bo->x[i]+1, bo->y[i] );
ee_putchar( 'g' );
break;
case BONUS_LIFE:
gfx_color( (bo->n[i] % 3) ? RED : WHITE );
gfx_goto( bo->x[i]+1, bo->y[i]-1 );
gfx_putchar( '_' );
gfx_goto( bo->x[i]+3, bo->y[i]-1 );
gfx_putchar( '_' );
gfx_goto( bo->x[i], bo->y[i] );
gfx_putstr( "( ' )" );
gfx_goto( bo->x[i]+1, bo->y[i]+1 );
gfx_putstr( "`v'" );
gfx_color( WHITE );
gfx_goto( bo->x[i]+3, bo->y[i] );
gfx_putchar( '^' );
ee_color( (bo->n[i] % 3) ? EE_RED : EE_WHITE );
ee_goto( bo->x[i]+1, bo->y[i]-1 );
ee_putchar( '_' );
ee_goto( bo->x[i]+3, bo->y[i]-1 );
ee_putchar( '_' );
ee_goto( bo->x[i], bo->y[i] );
ee_putstr( "( ' )" );
ee_goto( bo->x[i]+1, bo->y[i]+1 );
ee_putstr( "`v'" );
ee_color( EE_WHITE );
ee_goto( bo->x[i]+3, bo->y[i] );
ee_putchar( '^' );
break;
case BONUS_NONE:
break;


+ 26
- 26
src/box.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002-2003 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: box.c,v 1.1 2003/02/09 11:17:40 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@ void draw_box( game *g, box *b )
{
int i, j, frame;

gfx_color( YELLOW );
ee_color( EE_YELLOW );

/* Draw the thin horizontal line */
if( b->frame < 8 )
@@ -50,8 +50,8 @@ void draw_box( game *g, box *b )
i < b->x + b->w * b->frame / 16 ;
i++ )
{
gfx_goto( i, b->y );
gfx_putchar( 'X' );
ee_goto( i, b->y );
ee_putchar( 'X' );
}

return;
@@ -64,23 +64,23 @@ void draw_box( game *g, box *b )
i < b->x + b->w / 2 ;
i++ )
{
gfx_goto( i, b->y - b->h * (frame - 8) / 8 );
gfx_putchar( 'X' );
gfx_goto( i, b->y + b->h * (frame - 8) / 8 );
gfx_putchar( 'X' );
ee_goto( i, b->y - b->h * (frame - 8) / 8 );
ee_putchar( 'X' );
ee_goto( i, b->y + b->h * (frame - 8) / 8 );
ee_putchar( 'X' );
}

for( j = b->y - b->h * (frame - 8) / 8 ;
j < b->y + b->h * (frame - 8) / 8 ;
j++ )
{
gfx_goto( b->x - b->w / 2, j );
gfx_putchar( 'X' );
gfx_goto( b->x + b->w / 2 - 1, j );
gfx_putchar( 'X' );
ee_goto( b->x - b->w / 2, j );
ee_putchar( 'X' );
ee_goto( b->x + b->w / 2 - 1, j );
ee_putchar( 'X' );
}

gfx_color( BLACK );
ee_color( EE_BLACK );

for( j = b->y - b->h * (frame - 8) / 8 + 1 ;
j < b->y + b->h * (frame - 8) / 8 ;
@@ -90,8 +90,8 @@ void draw_box( game *g, box *b )
i < b->x + b->w / 2 - 1 ;
i++ )
{
gfx_goto( i, j );
gfx_putchar( 'X' );
ee_goto( i, j );
ee_putchar( 'X' );
}
}

@@ -101,19 +101,19 @@ void draw_box( game *g, box *b )
}

/* Draw the text inside the frame */
gfx_color( YELLOW );
ee_color( EE_YELLOW );

/* FIXME: use a font */
gfx_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 2 );
gfx_putstr( "XXXX. .XXXX X X .XXXX .XXXX XXXX." );
gfx_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 3 );
gfx_putstr( "X `X X' X X X X' X' X `X" );
gfx_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 4 );
gfx_putstr( "XXXX' XXXXX X X `XXX XXXX X X" );
gfx_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 5 );
gfx_putstr( "X' X' `X X. ,X `X X' X ,X" );
gfx_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 6 );
gfx_putstr( "X X X `XXXX XXXX' `XXXX XXXX'" );
ee_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 2 );
ee_putstr( "XXXX. .XXXX X X .XXXX .XXXX XXXX." );
ee_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 3 );
ee_putstr( "X `X X' X X X X' X' X `X" );
ee_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 4 );
ee_putstr( "XXXX' XXXXX X X `XXX XXXX X X" );
ee_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 5 );
ee_putstr( "X' X' `X X. ,X `X X' X ,X" );
ee_goto( b->x - b->w / 2 + 12, b->y - b->h / 2 + 6 );
ee_putstr( "X X X `XXXX XXXX' `XXXX XXXX'" );
}

void free_box( box *b )


+ 3
- 3
src/ceo.c 查看文件

@@ -33,16 +33,16 @@ void ceo_alert( game *g )

while( !end )
{
clear_graphics( g );
ee_clear();

if( get_key() == '\t' )
if( ee_get_key() == '\t' )
{
end = 1;
}

fprintf( stderr, "foo\n" );

refresh_graphics();
ee_refresh();

usleep( 40000 );
}


+ 1
- 43
src/common.h 查看文件

@@ -42,28 +42,7 @@
/*
* Graphics primitives
*/
#ifdef USE_SLANG
# include <slang.h>
# define gfx_color(x) SLsmg_set_color(x)
# define gfx_goto(x,y) SLsmg_gotorc(y,x)
# define gfx_putchar(x) SLsmg_write_char(x)
# define gfx_putstr(x) SLsmg_write_string(x)
#elif USE_NCURSES
#define box box_other
# include <curses.h>
#undef box
# define gfx_color(x) attrset(COLOR_PAIR(x))
# define gfx_goto(x,y) move(y,x)
# define gfx_putchar(x) addch(x)
# define gfx_putstr(x) addstr(x)
#else
# define gfx_color(x) (void)(x)
# define gfx_goto(x,y) do{ (void)(x); (void)(y); } while(0)
# define gfx_putchar(x) (void)(x)
# define gfx_putstr(x) (void)(x)
#endif

#define gfx_putcharTO(x,y,c) do{ gfx_goto(x,y); gfx_putchar(c); }while(0)
#include "ee.h"

/*
* Useful macros
@@ -164,17 +143,6 @@ typedef struct

} game;

#define BLACK 1
#define GREEN 2
#define YELLOW 3
#define WHITE 4
#define RED 5
#define GRAY 6
#define LIGHTGRAY 7
#define BLUE 8
#define CYAN 9
#define MAGENTA 10

/*
* From aliens.c
*/
@@ -218,16 +186,6 @@ void add_explosion( game *g, explosions *ex, int x, int y, int vx, int vy, int t
void draw_explosions( game *g, explosions *ex );
void update_explosions( game *g, explosions *ex );

/*
* From graphics.c
*/
int init_graphics( void );
void init_game( game *g );
char get_key( void );
void clear_graphics( game *g );
void refresh_graphics( void );
void end_graphics( void );

/*
* From math.c
*/


+ 88
- 88
src/explosions.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: explosions.c,v 1.4 2002/12/22 18:44:12 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -71,28 +71,28 @@ void draw_explosions( game *g, explosions *ex )
for( i = 0; i < EXPLOSIONS; i++ )
{
#if 0
gfx_color( GREEN );
gfx_goto( ex->x[i] + 3, ex->y[i] );
ee_color( GREEN );
ee_goto( ex->x[i] + 3, ex->y[i] );
switch( GET_RAND(0,3) )
{
case 0:
gfx_putchar( 'p' );
gfx_putchar( 'i' );
gfx_putchar( 'f' );
ee_putchar( 'p' );
ee_putchar( 'i' );
ee_putchar( 'f' );
break;
case 1:
gfx_putchar( 'p' );
gfx_putchar( 'a' );
gfx_putchar( 'f' );
ee_putchar( 'p' );
ee_putchar( 'a' );
ee_putchar( 'f' );
break;
case 2:
gfx_putchar( 'p' );
gfx_putchar( 'o' );
gfx_putchar( 'u' );
gfx_putchar( 'f' );
ee_putchar( 'p' );
ee_putchar( 'o' );
ee_putchar( 'u' );
ee_putchar( 'f' );
break;
}
gfx_putchar( '!' );
ee_putchar( '!' );
#endif

switch( ex->type[i] )
@@ -138,116 +138,116 @@ static void draw_small_explosion( int x, int y, int frame )
switch( frame )
{
case 6:
gfx_color( YELLOW );
gfx_goto( x, y );
gfx_putchar( '+' );
ee_color( EE_YELLOW );
ee_goto( x, y );
ee_putchar( '+' );
break;
case 5:
gfx_color( YELLOW );
gfx_goto( x, y );
gfx_putchar( 'o' );
ee_color( EE_YELLOW );
ee_goto( x, y );
ee_putchar( 'o' );
break;
case 4:
gfx_color( YELLOW );
gfx_goto( x, y-1 );
gfx_putchar( '_' );
gfx_goto( x-1, y );
gfx_putstr( ")_(" );
ee_color( EE_YELLOW );
ee_goto( x, y-1 );
ee_putchar( '_' );
ee_goto( x-1, y );
ee_putstr( ")_(" );
break;
case 3:
gfx_color( YELLOW );
gfx_goto( x-1, y-1 );
gfx_putstr( "._," );
gfx_goto( x-1, y );
gfx_putstr( ")_(" );
gfx_goto( x-1, y+1 );
gfx_putstr( "\' `" );
ee_color( EE_YELLOW );
ee_goto( x-1, y-1 );
ee_putstr( "._," );
ee_goto( x-1, y );
ee_putstr( ")_(" );
ee_goto( x-1, y+1 );
ee_putstr( "\' `" );
break;
case 2:
gfx_color( YELLOW );
gfx_goto( x-1, y-1 );
gfx_putstr( ".v," );
gfx_goto( x-1, y );
gfx_putstr( "> <" );
gfx_goto( x-1, y+1 );
gfx_putstr( "\'^`" );
ee_color( EE_YELLOW );
ee_goto( x-1, y-1 );
ee_putstr( ".v," );
ee_goto( x-1, y );
ee_putstr( "> <" );
ee_goto( x-1, y+1 );
ee_putstr( "\'^`" );
break;
case 1:
gfx_color( WHITE );
gfx_goto( x-1, y-1 );
gfx_putstr( ". ," );
gfx_goto( x-1, y );
gfx_putstr( " " );
gfx_goto( x-1, y+1 );
gfx_putstr( "\' `" );
ee_color( EE_WHITE );
ee_goto( x-1, y-1 );
ee_putstr( ". ," );
ee_goto( x-1, y );
ee_putstr( " " );
ee_goto( x-1, y+1 );
ee_putstr( "\' `" );
break;
}
}

static void draw_medium_explosion( int x, int y, int frame )
{
gfx_color( YELLOW );
ee_color( EE_YELLOW );

switch( frame )
{
case 10:
gfx_goto( x, y );
gfx_putchar( '+' );
ee_goto( x, y );
ee_putchar( '+' );
break;
case 9:
gfx_goto( x, y );
gfx_putchar( 'o' );
ee_goto( x, y );
ee_putchar( 'o' );
break;
case 8:
gfx_goto( x, y-1 );
gfx_putchar( '_' );
gfx_goto( x-1, y );
gfx_putstr( ")_(" );
ee_goto( x, y-1 );
ee_putchar( '_' );
ee_goto( x-1, y );
ee_putstr( ")_(" );
break;
case 7:
gfx_goto( x-1, y-1 );
gfx_putstr( "._," );
gfx_goto( x-1, y );
gfx_putstr( ")_(" );
gfx_goto( x-1, y+1 );
gfx_putstr( "\' `" );
ee_goto( x-1, y-1 );
ee_putstr( "._," );
ee_goto( x-1, y );
ee_putstr( ")_(" );
ee_goto( x-1, y+1 );
ee_putstr( "\' `" );
break;
case 6:
gfx_goto( x-1, y-1 );
gfx_putstr( ".v," );
gfx_goto( x-1, y );
gfx_putstr( "> <" );
gfx_goto( x-1, y+1 );
gfx_putstr( "\'^`" );
ee_goto( x-1, y-1 );
ee_putstr( ".v," );
ee_goto( x-1, y );
ee_putstr( "> <" );
ee_goto( x-1, y+1 );
ee_putstr( "\'^`" );
break;
case 5:
gfx_color( RED );
ee_color( EE_RED );
case 4:
gfx_goto( x-2, y-1 );
gfx_putstr( "_\\~/_" );
gfx_goto( x-2, y );
gfx_putstr( "> <" );
gfx_goto( x-2, y+1 );
gfx_putstr( "~/_\\~" );
ee_goto( x-2, y-1 );
ee_putstr( "_\\~/_" );
ee_goto( x-2, y );
ee_putstr( "> <" );
ee_goto( x-2, y+1 );
ee_putstr( "~/_\\~" );
break;
case 3:
gfx_color( RED );
ee_color( EE_RED );
case 2:
gfx_goto( x-2, y-1 );
gfx_putstr( "_\\ /_" );
gfx_goto( x-2, y );
gfx_putstr( "_ _" );
gfx_goto( x-2, y+1 );
gfx_putstr( " / \\ " );
ee_goto( x-2, y-1 );
ee_putstr( "_\\ /_" );
ee_goto( x-2, y );
ee_putstr( "_ _" );
ee_goto( x-2, y+1 );
ee_putstr( " / \\ " );
break;
case 1:
gfx_color( WHITE );
gfx_goto( x-2, y-1 );
gfx_putstr( ". \' ," );
gfx_goto( x-2, y );
gfx_putstr( " " );
gfx_goto( x-2, y+1 );
gfx_putstr( "\' . `" );
ee_color( EE_WHITE );
ee_goto( x-2, y-1 );
ee_putstr( ". \' ," );
ee_goto( x-2, y );
ee_putstr( " " );
ee_goto( x-2, y+1 );
ee_putstr( "\' . `" );
break;
}
}


+ 7
- 6
src/main.c 查看文件

@@ -37,19 +37,20 @@ int main (int argc, char **argv)

srand(time(NULL));

if( init_graphics() )
if( ee_init() )
{
return 1;
}

/* Initialize our program */
init_game(g);
g->w = ee_get_width();
g->h = ee_get_height();

/* Go ! */
start_game(g);

/* Clean up */
end_graphics();
ee_end();

return 0;
}
@@ -83,7 +84,7 @@ static void start_game (game *g)
{
char key;

while( ( key = get_key() ) )
while( ( key = ee_get_key() ) )
{
switch( key )
{
@@ -214,7 +215,7 @@ static void start_game (game *g)
}

/* Clear screen */
clear_graphics( g );
ee_clear();

/* Print starfield, tunnel, aliens, player and explosions */
draw_starfield( g, g->sf );
@@ -234,7 +235,7 @@ static void start_game (game *g)
}

/* Refresh */
refresh_graphics();
ee_refresh();

purcompteur++;
}


+ 27
- 27
src/overlay.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: overlay.c,v 1.3 2003/02/09 11:17:40 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,57 +30,57 @@ void draw_status( game *g )
static char dashes30[] = "==============================";

/* Draw life jauge */
gfx_color( GRAY );
gfx_goto( 4, 1 );
gfx_putstr( dots30 );
ee_color( EE_GRAY );
ee_goto( 4, 1 );
ee_putstr( dots30 );

if( g->p->life > MAX_LIFE * 7 / 10 )
{
gfx_color( GREEN );
ee_color( EE_GREEN );
}
else if( g->p->life > MAX_LIFE * 3 / 10 )
{
gfx_color( YELLOW );
ee_color( EE_YELLOW );
}
else
{
gfx_color( RED );
ee_color( EE_RED );
}

gfx_goto( 4, 1 );
gfx_putstr( dashes30 + ( MAX_LIFE - g->p->life ) * 30 / MAX_LIFE );
ee_goto( 4, 1 );
ee_putstr( dashes30 + ( MAX_LIFE - g->p->life ) * 30 / MAX_LIFE );

gfx_color( WHITE );
gfx_goto( 1, 1 );
gfx_putstr( "L |" );
gfx_goto( 34, 1 );
gfx_putstr( "|" );
ee_color( EE_WHITE );
ee_goto( 1, 1 );
ee_putstr( "L |" );
ee_goto( 34, 1 );
ee_putstr( "|" );

/* Draw weapon jauge */
gfx_color( GRAY );
gfx_goto( 42, 1 );
gfx_putstr( dots30 + 10 );
ee_color( EE_GRAY );
ee_goto( 42, 1 );
ee_putstr( dots30 + 10 );

if( g->p->special > MAX_SPECIAL * 9 / 10 )
{
gfx_color( WHITE );
ee_color( EE_WHITE );
}
else if( g->p->special > MAX_SPECIAL * 3 / 10 )
{
gfx_color( CYAN );
ee_color( EE_CYAN );
}
else
{
gfx_color( BLUE );
ee_color( EE_BLUE );
}

gfx_goto( 42, 1 );
gfx_putstr( dashes30 + 10 + ( MAX_SPECIAL - g->p->special ) * 20 / MAX_SPECIAL );
ee_goto( 42, 1 );
ee_putstr( dashes30 + 10 + ( MAX_SPECIAL - g->p->special ) * 20 / MAX_SPECIAL );

gfx_color( WHITE );
gfx_goto( 39, 1 );
gfx_putstr( "S |" );
gfx_goto( 62, 1 );
gfx_putstr( "|" );
ee_color( EE_WHITE );
ee_goto( 39, 1 );
ee_putstr( "S |" );
ee_goto( 62, 1 );
ee_putstr( "|" );
}


+ 13
- 13
src/player.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: player.c,v 1.8 2002/12/23 16:21:38 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,18 +53,18 @@ void draw_player( game *g, player *p )
return;
}

gfx_goto( p->x + 2, p->y - 2 );
gfx_color( GREEN );
gfx_putstr( "/\\" );
gfx_goto( p->x + 1, p->y - 1 );
gfx_putchar( '(' );
gfx_color( YELLOW );
gfx_putstr( "()" );
gfx_color( GREEN );
gfx_putchar( ')' );
gfx_goto( p->x, p->y );
gfx_color( GREEN );
gfx_putstr( "I<__>I" );
ee_goto( p->x + 2, p->y - 2 );
ee_color( EE_GREEN );
ee_putstr( "/\\" );
ee_goto( p->x + 1, p->y - 1 );
ee_putchar( '(' );
ee_color( EE_YELLOW );
ee_putstr( "()" );
ee_color( EE_GREEN );
ee_putchar( ')' );
ee_goto( p->x, p->y );
ee_color( EE_GREEN );
ee_putstr( "I<__>I" );
}

void update_player( game *g, player *p )


+ 4
- 4
src/starfield.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: starfield.c,v 1.5 2002/12/23 09:28:37 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -51,9 +51,9 @@ void draw_starfield( game *g, starfield *s )
{
if( s[i].x >= 0 )
{
gfx_color( s[i].c );
gfx_goto( s[i].x, s[i].y );
gfx_putchar( s[i].ch );
ee_color( s[i].c );
ee_goto( s[i].x, s[i].y );
ee_putchar( s[i].ch );
}
}
}


+ 15
- 15
src/tunnel.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: tunnel.c,v 1.8 2002/12/23 12:47:36 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -71,7 +71,7 @@ void draw_tunnel( game *g, tunnel *t )
int i, j;
char c;

gfx_color( GREEN );
ee_color( EE_GREEN );

/* Left border */
for( i = 0; i < g->h ; i++ )
@@ -90,15 +90,15 @@ void draw_tunnel( game *g, tunnel *t )
c = ( i == 0 || t->left[i] > t->left[i-1] ) ? '\\' : '<';
}

gfx_goto( t->left[i] + 1, i );
gfx_putchar( c );
ee_goto( t->left[i] + 1, i );
ee_putchar( c );

if( i + 1 < g->h )
{
for( j = 1; j < t->left[i+1] - t->left[i]; j++ )
{
gfx_goto( t->left[i] + j + 1, i );
gfx_putchar( '_' );
ee_goto( t->left[i] + j + 1, i );
ee_putchar( '_' );
}
}
}
@@ -124,24 +124,24 @@ void draw_tunnel( game *g, tunnel *t )
{
for( j = 1; j < t->right[i] - t->right[i+1]; j++ )
{
gfx_goto( t->right[i+1] + j - 1, i );
gfx_putchar( '_' );
ee_goto( t->right[i+1] + j - 1, i );
ee_putchar( '_' );
}
}

gfx_goto( t->right[i] - 1, i );
gfx_putchar( c );
ee_goto( t->right[i] - 1, i );
ee_putchar( c );
}

gfx_color( RED );
ee_color( EE_RED );

/* Left concrete */
for( i = 0; i < g->h ; i++ )
{
for( j = 0 ; j <= t->left[i]; j++ )
{
gfx_goto( j, i );
gfx_putchar( '#' );
ee_goto( j, i );
ee_putchar( '#' );
}
}

@@ -150,8 +150,8 @@ void draw_tunnel( game *g, tunnel *t )
{
for( j = t->right[i] ; j < g->w ; j++ )
{
gfx_goto( j, i );
gfx_putchar( '#' );
ee_goto( j, i );
ee_putchar( '#' );
}
}
}


+ 330
- 330
src/weapons.c 查看文件

@@ -3,7 +3,7 @@
* Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id: weapons.c,v 1.13 2002/12/23 16:44:28 sam Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,35 +49,35 @@ void draw_weapons( game *g, weapons *wp )
switch( wp->type[i] )
{
case WEAPON_LASER:
gfx_color( WHITE );
gfx_goto( wp->x[i] >> 4, wp->y[i] >> 4 );
gfx_putchar( '|' );
gfx_color( CYAN );
gfx_goto( wp->x[i] >> 4, (wp->y[i] >> 4) + 1 );
gfx_putchar( '|' );
ee_color( EE_WHITE );
ee_goto( wp->x[i] >> 4, wp->y[i] >> 4 );
ee_putchar( '|' );
ee_color( EE_CYAN );
ee_goto( wp->x[i] >> 4, (wp->y[i] >> 4) + 1 );
ee_putchar( '|' );
break;
case WEAPON_SEEKER:
gfx_color( CYAN );
gfx_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 );
gfx_putchar( '.' );
gfx_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 );
gfx_putchar( 'o' );
gfx_color( WHITE );
gfx_goto( wp->x[i] >> 4, wp->y[i] >> 4 );
gfx_putchar( '@' );
ee_color( EE_CYAN );
ee_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 );
ee_putchar( '.' );
ee_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 );
ee_putchar( 'o' );
ee_color( EE_WHITE );
ee_goto( wp->x[i] >> 4, wp->y[i] >> 4 );
ee_putchar( '@' );
break;
case WEAPON_BOMB:
gfx_color( GRAY );
gfx_goto( (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4 );
gfx_putchar( '.' );
gfx_goto( (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4 );
gfx_putchar( '.' );
gfx_goto( (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4 );
gfx_putchar( '.' );
gfx_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 );
gfx_putchar( '.' );
gfx_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 );
gfx_putchar( '.' );
ee_color( EE_GRAY );
ee_goto( (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4 );
ee_putchar( '.' );
ee_goto( (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4 );
ee_putchar( '.' );
ee_goto( (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4 );
ee_putchar( '.' );
ee_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 );
ee_putchar( '.' );
ee_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 );
ee_putchar( '.' );
draw_bomb( wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i] );
break;
case WEAPON_FRAGBOMB:
@@ -289,7 +289,7 @@ void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type )
static void draw_bomb( int x, int y, int vx, int vy )
{
vy *= 2;
gfx_color( CYAN );
ee_color( EE_CYAN );

if( vx > vy )
{
@@ -298,39 +298,39 @@ static void draw_bomb( int x, int y, int vx, int vy )
if( vy > vx/4 )
{
/* -1pi/6 */
gfx_goto( x-4, y-1 );
gfx_putstr( "/`-." );
gfx_goto( x-4, y );
gfx_putstr( "`-._\\" );
gfx_color( WHITE );
gfx_goto( x-1, y );
gfx_putstr( "_\\" );
gfx_goto( x, y+1 );
gfx_putchar( '`' );
ee_goto( x-4, y-1 );
ee_putstr( "/`-." );
ee_goto( x-4, y );
ee_putstr( "`-._\\" );
ee_color( EE_WHITE );
ee_goto( x-1, y );
ee_putstr( "_\\" );
ee_goto( x, y+1 );
ee_putchar( '`' );
}
else if( vy < -vx/4 )
{
/* 1pi/6 */
gfx_goto( x-4, y );
gfx_putstr( ",-' " );
gfx_goto( x-4, y+1 );
gfx_putstr( "\\,-'" );
gfx_color( WHITE );
gfx_goto( x-1, y-1 );
gfx_putstr( "_," );
gfx_goto( x, y );
gfx_putchar( '/' );
ee_goto( x-4, y );
ee_putstr( ",-' " );
ee_goto( x-4, y+1 );
ee_putstr( "\\,-'" );
ee_color( EE_WHITE );
ee_goto( x-1, y-1 );
ee_putstr( "_," );
ee_goto( x, y );
ee_putchar( '/' );
}
else
{
/* 0pi/6 */
gfx_goto( x-4, y-1 );
gfx_putstr( "____" );
gfx_goto( x-5, y );
gfx_putstr( "|____" );
gfx_color( WHITE );
gfx_goto( x, y );
gfx_putchar( '>' );
ee_goto( x-4, y-1 );
ee_putstr( "____" );
ee_goto( x-5, y );
ee_putstr( "|____" );
ee_color( EE_WHITE );
ee_goto( x, y );
ee_putchar( '>' );
}
}
else /* top quarter */
@@ -338,43 +338,43 @@ static void draw_bomb( int x, int y, int vx, int vy )
if( vx > -vy/4 )
{
/* 2pi/6 */
gfx_goto( x-2, y );
gfx_putstr( "/ " );
gfx_goto( x-3, y+1 );
gfx_putstr( "/ /" );
gfx_goto( x-3, y+2 );
gfx_putstr( "`'" );
gfx_color( WHITE );
gfx_goto( x-1, y-1 );
gfx_putstr( "_," );
gfx_goto( x, y );
gfx_putchar( '|' );
ee_goto( x-2, y );
ee_putstr( "/ " );
ee_goto( x-3, y+1 );
ee_putstr( "/ /" );
ee_goto( x-3, y+2 );
ee_putstr( "`'" );
ee_color( EE_WHITE );
ee_goto( x-1, y-1 );
ee_putstr( "_," );
ee_goto( x, y );
ee_putchar( '|' );
}
else if( vx < vy/4 )
{
/* 4pi/6 */
gfx_goto( x+1, y );
gfx_putstr( " \\" );
gfx_goto( x+1, y+1 );
gfx_putstr( "\\ \\" );
gfx_goto( x+2, y+2 );
gfx_putstr( "`'" );
gfx_color( WHITE );
gfx_goto( x, y-1 );
gfx_putstr( "._" );
gfx_goto( x, y );
gfx_putchar( '|' );
ee_goto( x+1, y );
ee_putstr( " \\" );
ee_goto( x+1, y+1 );
ee_putstr( "\\ \\" );
ee_goto( x+2, y+2 );
ee_putstr( "`'" );
ee_color( EE_WHITE );
ee_goto( x, y-1 );
ee_putstr( "._" );
ee_goto( x, y );
ee_putchar( '|' );
}
else
{
/* 3pi/6 */
gfx_goto( x-1, y+1 );
gfx_putstr( "| |" );
gfx_goto( x-1, y+2 );
gfx_putstr( "|_|" );
gfx_color( WHITE );
gfx_goto( x-1, y );
gfx_putstr( ",^." );
ee_goto( x-1, y+1 );
ee_putstr( "| |" );
ee_goto( x-1, y+2 );
ee_putstr( "|_|" );
ee_color( EE_WHITE );
ee_goto( x-1, y );
ee_putstr( ",^." );
}
}
}
@@ -385,41 +385,41 @@ static void draw_bomb( int x, int y, int vx, int vy )
if( vx > vy/4 )
{
/* -2pi/6 */
gfx_goto( x-2, y-2 );
gfx_putstr( ",." );
gfx_goto( x-2, y-1 );
gfx_putstr( "\\ \\" );
gfx_goto( x-1, y );
gfx_putchar( '\\' );
gfx_color( WHITE );
gfx_goto( x, y );
gfx_putstr( "_|" );
ee_goto( x-2, y-2 );
ee_putstr( ",." );
ee_goto( x-2, y-1 );
ee_putstr( "\\ \\" );
ee_goto( x-1, y );
ee_putchar( '\\' );
ee_color( EE_WHITE );
ee_goto( x, y );
ee_putstr( "_|" );
}
else if( vx < -vy/4 )
{
/* -4pi/6 */
gfx_goto( x+1, y-2 );
gfx_putstr( ",." );
gfx_goto( x, y-1 );
gfx_putstr( "/ /" );
gfx_goto( x+1, y );
gfx_putchar( '/' );
gfx_color( WHITE );
gfx_goto( x-1, y );
gfx_putstr( "|_/" );
ee_goto( x+1, y-2 );
ee_putstr( ",." );
ee_goto( x, y-1 );
ee_putstr( "/ /" );
ee_goto( x+1, y );
ee_putchar( '/' );
ee_color( EE_WHITE );
ee_goto( x-1, y );
ee_putstr( "|_/" );
}
else
{
/* -3pi/6 */
gfx_goto( x, y-3 );
gfx_putchar( '_' );
gfx_goto( x-1, y-2 );
gfx_putstr( "| |" );
gfx_goto( x-1, y-1 );
gfx_putstr( "| |" );
gfx_color( WHITE );
gfx_goto( x-1, y );
gfx_putstr( "`v'" );
ee_goto( x, y-3 );
ee_putchar( '_' );
ee_goto( x-1, y-2 );
ee_putstr( "| |" );
ee_goto( x-1, y-1 );
ee_putstr( "| |" );
ee_color( EE_WHITE );
ee_goto( x-1, y );
ee_putstr( "`v'" );
}
}
else /* left quarter */
@@ -427,39 +427,39 @@ static void draw_bomb( int x, int y, int vx, int vy )
if( vy > -vx/4 )
{
/* -5pi/6 */
gfx_goto( x+1, y-1 );
gfx_putstr( ",-'\\" );
gfx_goto( x+2, y );
gfx_putstr( ",-'" );
gfx_goto( x, y+1 );
gfx_putchar( '\'' );
gfx_color( WHITE );
gfx_goto( x, y );
gfx_putstr( "/_" );
ee_goto( x+1, y-1 );
ee_putstr( ",-'\\" );
ee_goto( x+2, y );
ee_putstr( ",-'" );
ee_goto( x, y+1 );
ee_putchar( '\'' );
ee_color( EE_WHITE );
ee_goto( x, y );
ee_putstr( "/_" );
}
else if( vy < vx/4 )
{
/* 5pi/6 */
gfx_goto( x+1, y );
gfx_putstr( " `-." );
gfx_goto( x+1, y+1 );
gfx_putstr( "`-./" );
gfx_color( WHITE );
gfx_goto( x, y-1 );
gfx_putstr( "._" );
gfx_goto( x, y );
gfx_putchar( '\\' );
ee_goto( x+1, y );
ee_putstr( " `-." );
ee_goto( x+1, y+1 );
ee_putstr( "`-./" );
ee_color( EE_WHITE );
ee_goto( x, y-1 );
ee_putstr( "._" );
ee_goto( x, y );
ee_putchar( '\\' );
}
else
{
/* 6pi/6 */
gfx_goto( x+1, y-1 );
gfx_putstr( "____" );
gfx_goto( x+1, y );
gfx_putstr( "____|" );
gfx_color( WHITE );
gfx_goto( x, y );
gfx_putchar( '<' );
ee_goto( x+1, y-1 );
ee_putstr( "____" );
ee_goto( x+1, y );
ee_putstr( "____|" );
ee_color( EE_WHITE );
ee_goto( x, y );
ee_putchar( '<' );
}
}
}
@@ -467,93 +467,93 @@ static void draw_bomb( int x, int y, int vx, int vy )

static void draw_fragbomb( int x, int y, int frame )
{
gfx_color( WHITE );
ee_color( EE_WHITE );

gfx_color( frame & 1 ? CYAN : WHITE );
gfx_goto( x-2, y );
gfx_putstr( "( )" );
gfx_goto( x-1, y+1 );
gfx_putstr( "`--'" );
ee_color( frame & 1 ? EE_CYAN : EE_WHITE );
ee_goto( x-2, y );
ee_putstr( "( )" );
ee_goto( x-1, y+1 );
ee_putstr( "`--'" );

gfx_color( frame & 1 ? WHITE : CYAN );
gfx_goto( x-1, y-1 );
gfx_putstr( ",--." );
gfx_goto( x, y );
gfx_putstr( "'," );
ee_color( frame & 1 ? EE_WHITE : EE_CYAN );
ee_goto( x-1, y-1 );
ee_putstr( ",--." );
ee_goto( x, y );
ee_putstr( "'," );

switch( frame % 4 )
{
case 0:
gfx_color( CYAN );
gfx_goto( x, y + 2 );
gfx_putchar( 'O' );
gfx_goto( x + 2, y + 2 );
gfx_putchar( 'o' );
gfx_goto( x + 1, y + 3 );
gfx_putchar( 'o' );
gfx_color( GRAY );
gfx_goto( x - 1, y + 3 );
gfx_putchar( ':' );
gfx_goto( x + 2, y + 4 );
gfx_putchar( ':' );
gfx_goto( x, y + 4 );
gfx_putchar( '.' );
gfx_goto( x + 1, y + 5 );
gfx_putchar( '.' );
ee_color( EE_CYAN );
ee_goto( x, y + 2 );
ee_putchar( 'O' );
ee_goto( x + 2, y + 2 );
ee_putchar( 'o' );
ee_goto( x + 1, y + 3 );
ee_putchar( 'o' );
ee_color( EE_GRAY );
ee_goto( x - 1, y + 3 );
ee_putchar( ':' );
ee_goto( x + 2, y + 4 );
ee_putchar( ':' );
ee_goto( x, y + 4 );
ee_putchar( '.' );
ee_goto( x + 1, y + 5 );
ee_putchar( '.' );
break;
case 1:
gfx_color( CYAN );
//gfx_goto( x, y + 1 );
//gfx_putchar( 'O' );
gfx_goto( x + 1, y + 2 );
gfx_putchar( 'O' );
gfx_goto( x, y + 3 );
gfx_putchar( 'o' );
gfx_color( GRAY );
gfx_goto( x + 2, y + 3 );
gfx_putchar( ':' );
gfx_goto( x + 1, y + 4 );
gfx_putchar( ':' );
gfx_goto( x - 1, y + 4 );
gfx_putchar( '.' );
gfx_goto( x + 2, y + 5 );
gfx_putchar( '.' );
ee_color( EE_CYAN );
//ee_goto( x, y + 1 );
//ee_putchar( 'O' );
ee_goto( x + 1, y + 2 );
ee_putchar( 'O' );
ee_goto( x, y + 3 );
ee_putchar( 'o' );
ee_color( EE_GRAY );
ee_goto( x + 2, y + 3 );
ee_putchar( ':' );
ee_goto( x + 1, y + 4 );
ee_putchar( ':' );
ee_goto( x - 1, y + 4 );
ee_putchar( '.' );
ee_goto( x + 2, y + 5 );
ee_putchar( '.' );
break;
case 2:
gfx_color( CYAN );
//gfx_goto( x - 1, y + 1 );
//gfx_putchar( 'O' );
gfx_goto( x + 2, y + 2 );
gfx_putchar( 'O' );
gfx_goto( x, y + 2 );
gfx_putchar( 'o' );
gfx_goto( x + 1, y + 3 );
gfx_putchar( 'o' );
gfx_color( GRAY );
gfx_goto( x, y + 4 );
gfx_putchar( ':' );
gfx_goto( x + 2, y + 4 );
gfx_putchar( '.' );
gfx_goto( x + 1, y + 5 );
gfx_putchar( '.' );
ee_color( EE_CYAN );
//ee_goto( x - 1, y + 1 );
//ee_putchar( 'O' );
ee_goto( x + 2, y + 2 );
ee_putchar( 'O' );
ee_goto( x, y + 2 );
ee_putchar( 'o' );
ee_goto( x + 1, y + 3 );
ee_putchar( 'o' );
ee_color( EE_GRAY );
ee_goto( x, y + 4 );
ee_putchar( ':' );
ee_goto( x + 2, y + 4 );
ee_putchar( '.' );
ee_goto( x + 1, y + 5 );
ee_putchar( '.' );
break;
case 3:
gfx_color( CYAN );
//gfx_goto( x + 2, y + 1 );
//gfx_putchar( 'O' );
gfx_goto( x + 1, y + 2 );
gfx_putchar( 'O' );
gfx_goto( x - 1, y + 2 );
gfx_putchar( 'o' );
gfx_goto( x + 2, y + 3 );
gfx_putchar( 'o' );
gfx_color( GRAY );
gfx_goto( x, y + 3 );
gfx_putchar( ':' );
gfx_goto( x + 1, y + 4 );
gfx_putchar( ':' );
gfx_goto( x, y + 5 );
gfx_putchar( '.' );
ee_color( EE_CYAN );
//ee_goto( x + 2, y + 1 );
//ee_putchar( 'O' );
ee_goto( x + 1, y + 2 );
ee_putchar( 'O' );
ee_goto( x - 1, y + 2 );
ee_putchar( 'o' );
ee_goto( x + 2, y + 3 );
ee_putchar( 'o' );
ee_color( EE_GRAY );
ee_goto( x, y + 3 );
ee_putchar( ':' );
ee_goto( x + 1, y + 4 );
ee_putchar( ':' );
ee_goto( x, y + 5 );
ee_putchar( '.' );
break;
}
}
@@ -566,132 +566,132 @@ static void draw_beam( int x, int y, int frame )
switch( frame )
{
case 24:
gfx_color( WHITE );
gfx_goto( x, y-3 );
gfx_putstr( "__" );
gfx_goto( x-1, y-2 );
gfx_putchar( '\'' );
gfx_goto( x+2, y-2 );
gfx_putchar( '`' );
ee_color( EE_WHITE );
ee_goto( x, y-3 );
ee_putstr( "__" );
ee_goto( x-1, y-2 );
ee_putchar( '\'' );
ee_goto( x+2, y-2 );
ee_putchar( '`' );
break;
case 23:
gfx_color( CYAN );
gfx_goto( x, y-3 );
gfx_putstr( "__" );
gfx_color( WHITE );
gfx_goto( x-2, y-2 );
gfx_putstr( "-'" );
gfx_goto( x+2, y-2 );
gfx_putstr( "`-" );
ee_color( EE_CYAN );
ee_goto( x, y-3 );
ee_putstr( "__" );
ee_color( EE_WHITE );
ee_goto( x-2, y-2 );
ee_putstr( "-'" );
ee_goto( x+2, y-2 );
ee_putstr( "`-" );
break;
case 22:
gfx_color( CYAN );
gfx_goto( x, y-3 );
gfx_putstr( "__" );
gfx_goto( x-1, y-2 );
gfx_putchar( '\'' );
gfx_goto( x+2, y-2 );
gfx_putchar( '`' );
gfx_color( WHITE );
gfx_goto( x-3, y-2 );
gfx_putstr( ",-" );
gfx_goto( x+3, y-2 );
gfx_putstr( "-." );
ee_color( EE_CYAN );
ee_goto( x, y-3 );
ee_putstr( "__" );
ee_goto( x-1, y-2 );
ee_putchar( '\'' );
ee_goto( x+2, y-2 );
ee_putchar( '`' );
ee_color( EE_WHITE );
ee_goto( x-3, y-2 );
ee_putstr( ",-" );
ee_goto( x+3, y-2 );
ee_putstr( "-." );
break;
case 21:
gfx_color( CYAN );
gfx_goto( x-1, y-3 );
gfx_putstr( "____" );
gfx_goto( x-2, y-2 );
gfx_putchar( '\'' );
gfx_goto( x+3, y-2 );
gfx_putchar( '`' );
gfx_color( WHITE );
gfx_goto( x-4, y-2 );
gfx_putstr( ",-" );
gfx_goto( x+4, y-2 );
gfx_putstr( "-." );
ee_color( EE_CYAN );
ee_goto( x-1, y-3 );
ee_putstr( "____" );
ee_goto( x-2, y-2 );
ee_putchar( '\'' );
ee_goto( x+3, y-2 );
ee_putchar( '`' );
ee_color( EE_WHITE );
ee_goto( x-4, y-2 );
ee_putstr( ",-" );
ee_goto( x+4, y-2 );
ee_putstr( "-." );
break;
case 20:
gfx_color( WHITE );
gfx_goto( x, y-3 );
gfx_putstr( "%%" );
gfx_goto( x-4, y-2 );
gfx_putchar( ',' );
gfx_goto( x+5, y-2 );
gfx_putchar( '.' );
gfx_color( CYAN );
gfx_goto( x-1, y-3 );
gfx_putchar( ':' );
gfx_goto( x+2, y-3 );
gfx_putchar( ':' );
gfx_goto( x-3, y-2 );
gfx_putstr( "-'" );
gfx_goto( x+3, y-2 );
gfx_putstr( "`-" );
ee_color( EE_WHITE );
ee_goto( x, y-3 );
ee_putstr( "%%" );
ee_goto( x-4, y-2 );
ee_putchar( ',' );
ee_goto( x+5, y-2 );
ee_putchar( '.' );
ee_color( EE_CYAN );
ee_goto( x-1, y-3 );
ee_putchar( ':' );
ee_goto( x+2, y-3 );
ee_putchar( ':' );
ee_goto( x-3, y-2 );
ee_putstr( "-'" );
ee_goto( x+3, y-2 );
ee_putstr( "`-" );
break;
case 19:
gfx_color( WHITE );
gfx_goto( x, y-4 );
gfx_putstr( "%%" );
gfx_goto( x, y-3 );
gfx_putstr( "##" );
gfx_color( CYAN );
gfx_goto( x-1, y-4 );
gfx_putchar( ':' );
gfx_goto( x+2, y-4 );
gfx_putchar( ':' );
gfx_goto( x-1, y-3 );
gfx_putchar( '%' );
gfx_goto( x+2, y-3 );
gfx_putchar( '%' );
gfx_goto( x-4, y-2 );
gfx_putstr( ",-'" );
gfx_goto( x+3, y-2 );
gfx_putstr( "`-." );
gfx_color( BLUE );
gfx_goto( x-2, y-3 );
gfx_putchar( ':' );
gfx_goto( x+3, y-3 );
gfx_putchar( ':' );
ee_color( EE_WHITE );
ee_goto( x, y-4 );
ee_putstr( "%%" );
ee_goto( x, y-3 );
ee_putstr( "##" );
ee_color( EE_CYAN );
ee_goto( x-1, y-4 );
ee_putchar( ':' );
ee_goto( x+2, y-4 );
ee_putchar( ':' );
ee_goto( x-1, y-3 );
ee_putchar( '%' );
ee_goto( x+2, y-3 );
ee_putchar( '%' );
ee_goto( x-4, y-2 );
ee_putstr( ",-'" );
ee_goto( x+3, y-2 );
ee_putstr( "`-." );
ee_color( EE_BLUE );
ee_goto( x-2, y-3 );
ee_putchar( ':' );
ee_goto( x+3, y-3 );
ee_putchar( ':' );
break;
case 18:
default:
r = (18 - frame) * (18 - frame);
gfx_color( WHITE );
gfx_goto( x-1, y-5-r );
gfx_putstr( ":%%:" );
gfx_goto( x-1, y-4-r );
gfx_putstr( "%##%" );
gfx_color( CYAN );
gfx_goto( x-2, y-4-r );
gfx_putchar( ':' );
gfx_goto( x+3, y-4-r );
gfx_putchar( ':' );
gfx_goto( x-2, y-2 );
gfx_putchar( '\'' );
gfx_goto( x+3, y-2 );
gfx_putchar( '`' );
gfx_color( BLUE );
gfx_goto( x-3, y-2 );
gfx_putchar( ':' );
gfx_goto( x+4, y-2 );
gfx_putchar( ':' );
ee_color( EE_WHITE );
ee_goto( x-1, y-5-r );
ee_putstr( ":%%:" );
ee_goto( x-1, y-4-r );
ee_putstr( "%##%" );
ee_color( EE_CYAN );
ee_goto( x-2, y-4-r );
ee_putchar( ':' );
ee_goto( x+3, y-4-r );
ee_putchar( ':' );
ee_goto( x-2, y-2 );
ee_putchar( '\'' );
ee_goto( x+3, y-2 );
ee_putchar( '`' );
ee_color( EE_BLUE );
ee_goto( x-3, y-2 );
ee_putchar( ':' );
ee_goto( x+4, y-2 );
ee_putchar( ':' );
for( i = 0; i <= r; i++ )
{
gfx_color( WHITE );
gfx_goto( x-1, y-3-i );
gfx_putstr( (i+frame) % 5 ? "####" : "%%%%" );
gfx_color( CYAN );
gfx_goto( x-2, y-3-i );
gfx_putchar( '%' );
gfx_goto( x+3, y-3-i );
gfx_putchar( '%' );
gfx_color( BLUE );
gfx_goto( x-3, y-3-i );
gfx_putchar( ':' );
gfx_goto( x+4, y-3-i );
gfx_putchar( ':' );
ee_color( EE_WHITE );
ee_goto( x-1, y-3-i );
ee_putstr( (i+frame) % 5 ? "####" : "%%%%" );
ee_color( EE_CYAN );
ee_goto( x-2, y-3-i );
ee_putchar( '%' );
ee_goto( x+3, y-3-i );
ee_putchar( '%' );
ee_color( EE_BLUE );
ee_goto( x-3, y-3-i );
ee_putchar( ':' );
ee_goto( x+4, y-3-i );
ee_putchar( ':' );
}
break;
}
@@ -702,11 +702,11 @@ 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 */
gfx_color( BLUE );
ee_color( EE_BLUE );
draw_circle( x, y, r++, ':' );
gfx_color( CYAN );
ee_color( EE_CYAN );
draw_circle( x, y, r++, '%' );
gfx_color( WHITE );
ee_color( EE_WHITE );
draw_circle( x, y, r++, '#' );
draw_circle( x, y, r++, '#' );
}
@@ -718,15 +718,15 @@ static void draw_circle( int x, int y, int r, char c )
/* Optimized Bresenham. Kick ass. */
for( test = 0, dx = 0, dy = r ; dx <= dy ; dx++ )
{
gfx_putcharTO( x + dx, y + dy / 2, c );
gfx_putcharTO( x - dx, y + dy / 2, c );
gfx_putcharTO( x + dx, y - dy / 2, c );
gfx_putcharTO( x - dx, y - dy / 2, c );
gfx_putcharTO( x + dy, y + dx / 2, c );
gfx_putcharTO( x - dy, y + dx / 2, c );
gfx_putcharTO( x + dy, y - dx / 2, c );
gfx_putcharTO( x - dy, y - dx / 2, c );
ee_putcharTO( x + dx, y + dy / 2, c );
ee_putcharTO( x - dx, y + dy / 2, c );
ee_putcharTO( x + dx, y - dy / 2, c );
ee_putcharTO( x - dx, y - dy / 2, c );
ee_putcharTO( x + dy, y + dx / 2, c );
ee_putcharTO( x - dy, y + dx / 2, c );
ee_putcharTO( x + dy, y - dx / 2, c );
ee_putcharTO( x - dy, y - dx / 2, c );

test += test > 0 ? dx - dy-- : dx;
}


正在加载...
取消
保存