| @@ -24,36 +24,36 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| static void draw_alien_foo( game *g, int x, int y, int frame ); | |||||
| static void draw_alien_bar( game *g, int x, int y, int frame ); | |||||
| static void draw_alien_baz( game *g, int x, int y, int frame ); | |||||
| static void draw_alien_foo(game *, int, int, int); | |||||
| static void draw_alien_bar(game *, int, int, int); | |||||
| static void draw_alien_baz(game *, int, int, int); | |||||
| void init_aliens( game *g, aliens *al ) | |||||
| void init_aliens(game *g, aliens *al) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < ALIENS; i++ ) | |||||
| for(i = 0; i < ALIENS; i++) | |||||
| { | { | ||||
| al->type[i] = ALIEN_NONE; | al->type[i] = ALIEN_NONE; | ||||
| } | } | ||||
| } | } | ||||
| void draw_aliens( game *g, aliens *al ) | |||||
| void draw_aliens(game *g, aliens *al) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < ALIENS; i++ ) | |||||
| for(i = 0; i < ALIENS; i++) | |||||
| { | { | ||||
| switch( al->type[i] ) | |||||
| switch(al->type[i]) | |||||
| { | { | ||||
| case ALIEN_FOO: | case ALIEN_FOO: | ||||
| draw_alien_foo( g, al->x[i], al->y[i], al->img[i] % 8 ); | |||||
| draw_alien_foo(g, al->x[i], al->y[i], al->img[i] % 8); | |||||
| break; | break; | ||||
| case ALIEN_BAR: | case ALIEN_BAR: | ||||
| draw_alien_bar( g, al->x[i], al->y[i], al->img[i] % 2 ); | |||||
| draw_alien_bar(g, al->x[i], al->y[i], al->img[i] % 2); | |||||
| break; | break; | ||||
| case ALIEN_BAZ: | case ALIEN_BAZ: | ||||
| draw_alien_baz( g, al->x[i], al->y[i], al->img[i] % 6 ); | |||||
| draw_alien_baz(g, al->x[i], al->y[i], al->img[i] % 6); | |||||
| break; | break; | ||||
| case ALIEN_NONE: | case ALIEN_NONE: | ||||
| break; | break; | ||||
| @@ -61,22 +61,22 @@ void draw_aliens( game *g, aliens *al ) | |||||
| } | } | ||||
| } | } | ||||
| void update_aliens( game *g, aliens *al ) | |||||
| void update_aliens(game *g, aliens *al) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < ALIENS; i++ ) | |||||
| for(i = 0; i < ALIENS; i++) | |||||
| { | { | ||||
| /* If alien died, make it explode */ | /* If alien died, make it explode */ | ||||
| if( al->type[i] != ALIEN_NONE && al->life[i] < 0 ) | |||||
| if(al->type[i] != ALIEN_NONE && al->life[i] < 0) | |||||
| { | { | ||||
| add_explosion( g, g->ex, al->x[i], al->y[i], 0, 0, EXPLOSION_MEDIUM ); | |||||
| add_explosion(g, g->ex, al->x[i], al->y[i], 0, 0, EXPLOSION_MEDIUM); | |||||
| al->type[i] = ALIEN_NONE; | al->type[i] = ALIEN_NONE; | ||||
| add_bonus( g, g->bo, al->x[i], al->y[i], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||||
| add_bonus(g, g->bo, al->x[i], al->y[i], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE); | |||||
| } | } | ||||
| /* Update coordinates */ | /* Update coordinates */ | ||||
| switch( al->type[i] ) | |||||
| switch(al->type[i]) | |||||
| { | { | ||||
| case ALIEN_FOO: | case ALIEN_FOO: | ||||
| case ALIEN_BAR: | case ALIEN_BAR: | ||||
| @@ -86,8 +86,8 @@ void update_aliens( game *g, aliens *al ) | |||||
| al->img[i] = al->img[i] + 1; | al->img[i] = al->img[i] + 1; | ||||
| /* Check bounds */ | /* Check bounds */ | ||||
| if( al->y[i] < 0 ) al->y[i] = 0; | |||||
| if( al->y[i] > g->w - 1 ) al->y[i] = g->w - 1; | |||||
| if(al->y[i] < 0 ) al->y[i] = 0; | |||||
| if(al->y[i] > g->w - 1 ) al->y[i] = g->w - 1; | |||||
| break; | break; | ||||
| case ALIEN_NONE: | case ALIEN_NONE: | ||||
| break; | break; | ||||
| @@ -95,20 +95,20 @@ void update_aliens( game *g, aliens *al ) | |||||
| } | } | ||||
| } | } | ||||
| void add_alien( game *g, aliens *al, int x, int y, int type ) | |||||
| void add_alien(game *g, aliens *al, int x, int y, int type) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < ALIENS; i++ ) | |||||
| for(i = 0; i < ALIENS; i++) | |||||
| { | { | ||||
| if( al->type[i] == ALIEN_NONE ) | |||||
| if(al->type[i] == ALIEN_NONE) | |||||
| { | { | ||||
| al->type[i] = type; | al->type[i] = type; | ||||
| al->x[i] = x; | al->x[i] = x; | ||||
| al->y[i] = y; | al->y[i] = y; | ||||
| al->img[i] = 0; | al->img[i] = 0; | ||||
| switch( al->type[i] ) | |||||
| switch(al->type[i]) | |||||
| { | { | ||||
| case ALIEN_FOO: | case ALIEN_FOO: | ||||
| al->life[i] = 3; | al->life[i] = 3; | ||||
| @@ -128,132 +128,132 @@ void add_alien( game *g, aliens *al, int x, int y, int type ) | |||||
| } | } | ||||
| } | } | ||||
| static void draw_alien_bar( game *g, int x, int y, int frame ) | |||||
| static void draw_alien_bar(game *g, int x, int y, int frame) | |||||
| { | { | ||||
| switch( frame ) | |||||
| switch(frame) | |||||
| { | { | ||||
| case 0: | case 0: | ||||
| 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( "^^^^^" ); | |||||
| 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; | break; | ||||
| case 1: | case 1: | ||||
| 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( "^^^^^" ); | |||||
| 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; | break; | ||||
| } | } | ||||
| } | } | ||||
| static void draw_alien_baz( game *g, int x, int y, int frame ) | |||||
| static void draw_alien_baz(game *g, int x, int y, int frame) | |||||
| { | { | ||||
| ee_color( EE_GREEN ); | |||||
| ee_goto( x, y-1 ); | |||||
| ee_putstr( "__" ); | |||||
| ee_color(EE_GREEN); | |||||
| ee_goto(x, y-1); | |||||
| ee_putstr("__"); | |||||
| ee_goto( x-1, y ); | |||||
| ee_putchar( '/' ); | |||||
| ee_goto( x+2, y ); | |||||
| ee_putchar( '\\' ); | |||||
| ee_goto(x-1, y); | |||||
| ee_putchar('/'); | |||||
| ee_goto(x+2, y); | |||||
| ee_putchar('\\'); | |||||
| switch( frame ) | |||||
| switch(frame) | |||||
| { | { | ||||
| case 3: | case 3: | ||||
| ee_goto( x-2, y+1 ); | |||||
| ee_putstr( "//'`\\\\" ); | |||||
| ee_goto(x-2, y+1); | |||||
| ee_putstr("//'`\\\\"); | |||||
| break; | break; | ||||
| case 4: | case 4: | ||||
| case 2: | case 2: | ||||
| ee_goto( x-2, y+1 ); | |||||
| ee_putstr( "/(~~)\\" ); | |||||
| ee_goto(x-2, y+1); | |||||
| ee_putstr("/(~~)\\"); | |||||
| break; | break; | ||||
| case 5: | case 5: | ||||
| case 1: | case 1: | ||||
| ee_goto( x-2, y+1 ); | |||||
| ee_putstr( "((^^))" ); | |||||
| ee_goto(x-2, y+1); | |||||
| ee_putstr("((^^))"); | |||||
| break; | break; | ||||
| case 0: | case 0: | ||||
| ee_goto( x-1, y+1 ); | |||||
| ee_putstr( "\\\\//" ); | |||||
| ee_goto(x-1, y+1); | |||||
| ee_putstr("\\\\//"); | |||||
| break; | break; | ||||
| } | } | ||||
| ee_color( EE_WHITE ); | |||||
| ee_goto( x, y ); | |||||
| ee_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 ) | |||||
| static void draw_alien_foo(game *g, int x, int y, int frame) | |||||
| { | { | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_color(EE_YELLOW); | |||||
| switch( frame ) | |||||
| switch(frame) | |||||
| { | { | ||||
| case 0: | case 0: | ||||
| ee_goto( x, y ); | |||||
| ee_putchar( '.' ); | |||||
| ee_goto( x+6, y ); | |||||
| ee_putchar( ',' ); | |||||
| ee_goto( x+1, y+1 ); | |||||
| ee_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; | break; | ||||
| case 7: | case 7: | ||||
| case 1: | case 1: | ||||
| ee_goto( x-1, y ); | |||||
| ee_putchar( '.' ); | |||||
| ee_goto( x+7, y ); | |||||
| ee_putchar( ',' ); | |||||
| ee_goto( x, y+1 ); | |||||
| ee_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; | break; | ||||
| case 6: | case 6: | ||||
| case 2: | case 2: | ||||
| ee_goto( x-1, y+1 ); | |||||
| ee_putstr( "`-- X --'" ); | |||||
| ee_goto(x-1, y+1); | |||||
| ee_putstr("`-- X --'"); | |||||
| break; | break; | ||||
| case 5: | case 5: | ||||
| case 3: | case 3: | ||||
| ee_goto( x, y+1 ); | |||||
| ee_putstr( ",- X -." ); | |||||
| ee_goto( x-1, y+2 ); | |||||
| ee_putchar( '\'' ); | |||||
| ee_goto( x+7, y+2 ); | |||||
| ee_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; | break; | ||||
| case 4: | case 4: | ||||
| ee_goto( x+1, y+1 ); | |||||
| ee_putstr( ", X ." ); | |||||
| ee_goto( x, y+2 ); | |||||
| ee_putchar( '/' ); | |||||
| ee_goto( x+6, y+2 ); | |||||
| ee_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; | break; | ||||
| } | } | ||||
| ee_goto( x+2, y+2 ); | |||||
| ee_putstr( "`V'" ); | |||||
| ee_goto(x+2, y+2); | |||||
| ee_putstr("`V'"); | |||||
| ee_color( EE_WHITE ); | |||||
| ee_goto( x+2, y+1 ); | |||||
| ee_putchar( 'o' ); | |||||
| ee_goto( x+4, y+1 ); | |||||
| ee_putchar( 'o' ); | |||||
| ee_color(EE_WHITE); | |||||
| ee_goto(x+2, y+1); | |||||
| ee_putchar('o'); | |||||
| ee_goto(x+4, y+1); | |||||
| ee_putchar('o'); | |||||
| } | } | ||||
| @@ -24,49 +24,49 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| void init_bonus( game *g, bonus *bo ) | |||||
| void init_bonus(game *g, bonus *bo) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < BONUS; i++ ) | |||||
| for(i = 0; i < BONUS; i++) | |||||
| { | { | ||||
| bo->type[i] = BONUS_NONE; | bo->type[i] = BONUS_NONE; | ||||
| } | } | ||||
| } | } | ||||
| void draw_bonus( game *g, bonus *bo ) | |||||
| void draw_bonus(game *g, bonus *bo) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < BONUS; i++ ) | |||||
| for(i = 0; i < BONUS; i++) | |||||
| { | { | ||||
| switch( bo->type[i] ) | |||||
| switch(bo->type[i]) | |||||
| { | { | ||||
| case BONUS_GREEN: | case BONUS_GREEN: | ||||
| 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' ); | |||||
| 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; | break; | ||||
| case BONUS_LIFE: | case BONUS_LIFE: | ||||
| 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( '^' ); | |||||
| 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; | break; | ||||
| case BONUS_NONE: | case BONUS_NONE: | ||||
| break; | break; | ||||
| @@ -74,18 +74,18 @@ void draw_bonus( game *g, bonus *bo ) | |||||
| } | } | ||||
| } | } | ||||
| void update_bonus( game *g, bonus *bo ) | |||||
| void update_bonus(game *g, bonus *bo) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < BONUS; i++ ) | |||||
| for(i = 0; i < BONUS; i++) | |||||
| { | { | ||||
| switch( bo->type[i] ) | |||||
| switch(bo->type[i]) | |||||
| { | { | ||||
| case BONUS_GREEN: | case BONUS_GREEN: | ||||
| bo->n[i]++; | bo->n[i]++; | ||||
| bo->y[i]++; | bo->y[i]++; | ||||
| if( bo->y[i] > g->h ) | |||||
| if(bo->y[i] > g->h) | |||||
| { | { | ||||
| bo->type[i] = BONUS_NONE; | bo->type[i] = BONUS_NONE; | ||||
| } | } | ||||
| @@ -93,7 +93,7 @@ void update_bonus( game *g, bonus *bo ) | |||||
| case BONUS_LIFE: | case BONUS_LIFE: | ||||
| bo->n[i]++; | bo->n[i]++; | ||||
| bo->y[i]++; | bo->y[i]++; | ||||
| if( bo->y[i] > g->h ) | |||||
| if(bo->y[i] > g->h) | |||||
| { | { | ||||
| bo->type[i] = BONUS_NONE; | bo->type[i] = BONUS_NONE; | ||||
| } | } | ||||
| @@ -104,13 +104,13 @@ void update_bonus( game *g, bonus *bo ) | |||||
| } | } | ||||
| } | } | ||||
| void add_bonus( game *g, bonus *bo, int x, int y, int type ) | |||||
| void add_bonus(game *g, bonus *bo, int x, int y, int type) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < BONUS; i++ ) | |||||
| for(i = 0; i < BONUS; i++) | |||||
| { | { | ||||
| if( bo->type[i] == BONUS_NONE ) | |||||
| if(bo->type[i] == BONUS_NONE) | |||||
| { | { | ||||
| bo->type[i] = type; | bo->type[i] = type; | ||||
| bo->x[i] = x; | bo->x[i] = x; | ||||
| @@ -24,9 +24,9 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| box * create_box( game *g, int x, int y, int w, int h ) | |||||
| box * create_box(game *g, int x, int y, int w, int h) | |||||
| { | { | ||||
| box *b = malloc( sizeof( box ) ); | |||||
| box *b = malloc(sizeof( box )); | |||||
| b->x = x; | b->x = x; | ||||
| b->y = y; | b->y = y; | ||||
| @@ -37,21 +37,21 @@ box * create_box( game *g, int x, int y, int w, int h ) | |||||
| return b; | return b; | ||||
| } | } | ||||
| void draw_box( game *g, box *b ) | |||||
| void draw_box(game *g, box *b) | |||||
| { | { | ||||
| int i, j, frame; | int i, j, frame; | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_color(EE_YELLOW); | |||||
| /* Draw the thin horizontal line */ | /* Draw the thin horizontal line */ | ||||
| if( b->frame < 8 ) | |||||
| if(b->frame < 8) | |||||
| { | { | ||||
| for( i = b->x - b->w * b->frame / 16 ; | |||||
| for(i = b->x - b->w * b->frame / 16 ; | |||||
| i < b->x + b->w * b->frame / 16 ; | i < b->x + b->w * b->frame / 16 ; | ||||
| i++ ) | |||||
| i++) | |||||
| { | { | ||||
| ee_goto( i, b->y ); | |||||
| ee_putchar( 'X' ); | |||||
| ee_goto(i, b->y); | |||||
| ee_putchar('X'); | |||||
| } | } | ||||
| return; | return; | ||||
| @@ -60,64 +60,64 @@ void draw_box( game *g, box *b ) | |||||
| /* Draw the frame */ | /* Draw the frame */ | ||||
| frame = b->frame < 12 ? b->frame : 12; | frame = b->frame < 12 ? b->frame : 12; | ||||
| for( i = b->x - b->w / 2 ; | |||||
| for(i = b->x - b->w / 2 ; | |||||
| i < b->x + b->w / 2 ; | i < b->x + b->w / 2 ; | ||||
| i++ ) | |||||
| i++) | |||||
| { | { | ||||
| 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' ); | |||||
| 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 ; | |||||
| for(j = b->y - b->h * (frame - 8) / 8 ; | |||||
| j < b->y + b->h * (frame - 8) / 8 ; | j < b->y + b->h * (frame - 8) / 8 ; | ||||
| j++ ) | |||||
| j++) | |||||
| { | { | ||||
| ee_goto( b->x - b->w / 2, j ); | |||||
| ee_putchar( 'X' ); | |||||
| ee_goto( b->x + b->w / 2 - 1, j ); | |||||
| ee_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'); | |||||
| } | } | ||||
| ee_color( EE_BLACK ); | |||||
| ee_color(EE_BLACK); | |||||
| for( j = b->y - b->h * (frame - 8) / 8 + 1 ; | |||||
| for(j = b->y - b->h * (frame - 8) / 8 + 1 ; | |||||
| j < b->y + b->h * (frame - 8) / 8 ; | j < b->y + b->h * (frame - 8) / 8 ; | ||||
| j++ ) | |||||
| j++) | |||||
| { | { | ||||
| for( i = b->x - b->w / 2 + 1 ; | |||||
| for(i = b->x - b->w / 2 + 1 ; | |||||
| i < b->x + b->w / 2 - 1 ; | i < b->x + b->w / 2 - 1 ; | ||||
| i++ ) | |||||
| i++) | |||||
| { | { | ||||
| ee_goto( i, j ); | |||||
| ee_putchar( 'X' ); | |||||
| ee_goto(i, j); | |||||
| ee_putchar('X'); | |||||
| } | } | ||||
| } | } | ||||
| if( b->frame < 12 ) | |||||
| if(b->frame < 12) | |||||
| { | { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Draw the text inside the frame */ | /* Draw the text inside the frame */ | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_color(EE_YELLOW); | |||||
| /* FIXME: use a font */ | /* FIXME: use a font */ | ||||
| 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'" ); | |||||
| 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 ) | |||||
| void free_box(box *b) | |||||
| { | { | ||||
| free( b ); | |||||
| free(b); | |||||
| } | } | ||||
| @@ -27,23 +27,23 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| void ceo_alert( game *g ) | |||||
| void ceo_alert(game *g) | |||||
| { | { | ||||
| int end = 0; | int end = 0; | ||||
| while( !end ) | |||||
| while(!end) | |||||
| { | { | ||||
| ee_clear(); | ee_clear(); | ||||
| if( ee_get_key() == '\t' ) | |||||
| if(ee_get_key() == '\t') | |||||
| { | { | ||||
| end = 1; | end = 1; | ||||
| } | } | ||||
| fprintf( stderr, "foo\n" ); | |||||
| fprintf(stderr, "foo\n"); | |||||
| ee_refresh(); | ee_refresh(); | ||||
| usleep( 40000 ); | |||||
| usleep(40000); | |||||
| } | } | ||||
| } | } | ||||
| @@ -3,7 +3,7 @@ | |||||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | ||||
| * All Rights Reserved | * All Rights Reserved | ||||
| * | * | ||||
| * $Id: collide.c,v 1.11 2003/01/06 12:22:58 sam Exp $ | |||||
| * $Id$ | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or modify | * 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 | * it under the terms of the GNU General Public License as published by | ||||
| @@ -24,16 +24,16 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) | |||||
| void collide_weapons_tunnel(game *g, weapons *wp, tunnel *t, explosions *ex) | |||||
| { | { | ||||
| int i, j, x, y; | int i, j, x, y; | ||||
| for( i = 0; i < WEAPONS; i++ ) | |||||
| for(i = 0; i < WEAPONS; i++) | |||||
| { | { | ||||
| x = wp->x[i] >> 4; | x = wp->x[i] >> 4; | ||||
| y = wp->y[i] >> 4; | y = wp->y[i] >> 4; | ||||
| switch( wp->type[i] ) | |||||
| switch(wp->type[i]) | |||||
| { | { | ||||
| case WEAPON_LIGHTNING: | case WEAPON_LIGHTNING: | ||||
| case WEAPON_NONE: | case WEAPON_NONE: | ||||
| @@ -41,36 +41,36 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) | |||||
| case WEAPON_SEEKER: | case WEAPON_SEEKER: | ||||
| case WEAPON_BOMB: | case WEAPON_BOMB: | ||||
| case WEAPON_FRAGBOMB: | case WEAPON_FRAGBOMB: | ||||
| if( y < 0 || y >= g->h ) | |||||
| if(y < 0 || y >= g->h) | |||||
| { | { | ||||
| break; | break; | ||||
| } | } | ||||
| if( x <= t->left[y] | |||||
| || x >= t->right[y] ) | |||||
| if(x <= t->left[y] | |||||
| || x >= t->right[y]) | |||||
| { | { | ||||
| int damage = wp->type[i] == WEAPON_SEEKER ? 1 : 2; | int damage = wp->type[i] == WEAPON_SEEKER ? 1 : 2; | ||||
| add_explosion( g, ex, x, y, 0, 1, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM ); | |||||
| add_explosion(g, ex, x, y, 0, 1, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM); | |||||
| if( x <= t->left[y] ) | |||||
| if(x <= t->left[y]) | |||||
| { | { | ||||
| if( y-2 >= 0 ) t->left[y-2] -= damage - 1; | |||||
| if( y-1 >= 0 ) t->left[y-1] -= damage; | |||||
| if(y-2 >= 0) t->left[y-2] -= damage - 1; | |||||
| if(y-1 >= 0) t->left[y-1] -= damage; | |||||
| t->left[y] -= damage + 1; | t->left[y] -= damage + 1; | ||||
| if( y+1 < g->h ) t->left[y+1] -= damage; | |||||
| if( y+2 < g->h ) t->left[y+2] -= damage - 1; | |||||
| if(y+1 < g->h) t->left[y+1] -= damage; | |||||
| if(y+2 < g->h) t->left[y+2] -= damage - 1; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if( y-2 >= 0 ) t->right[y-2] += damage - 1; | |||||
| if( y-1 >= 0 ) t->right[y-1] += damage; | |||||
| if(y-2 >= 0) t->right[y-2] += damage - 1; | |||||
| if(y-1 >= 0) t->right[y-1] += damage; | |||||
| t->right[y] += damage + 1; | t->right[y] += damage + 1; | ||||
| if( y+1 < g->h ) t->right[y+1] += damage; | |||||
| if( y+2 < g->h ) t->right[y+2] += damage - 1; | |||||
| if(y+1 < g->h) t->right[y+1] += damage; | |||||
| if(y+2 < g->h) t->right[y+2] += damage - 1; | |||||
| } | } | ||||
| if( wp->type[i] == WEAPON_FRAGBOMB ) | |||||
| if(wp->type[i] == WEAPON_FRAGBOMB) | |||||
| { | { | ||||
| wp->n[i] = -1; | wp->n[i] = -1; | ||||
| } | } | ||||
| @@ -81,55 +81,55 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) | |||||
| } | } | ||||
| break; | break; | ||||
| case WEAPON_LASER: | case WEAPON_LASER: | ||||
| for( j = GET_MIN( 0, wp->vy[i] >> 4 ) ; | |||||
| j < GET_MAX( 0, wp->vy[i] >> 4 ) ; | |||||
| j++ ) | |||||
| for(j = GET_MIN(0, wp->vy[i] >> 4); | |||||
| j < GET_MAX(0, wp->vy[i] >> 4); | |||||
| j++) | |||||
| { | { | ||||
| if( y+j >= g->h || y+j < 0 ) | |||||
| if(y+j >= g->h || y+j < 0) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if( x <= t->left[y+j] || x >= t->right[y+j] ) | |||||
| if(x <= t->left[y+j] || x >= t->right[y+j]) | |||||
| { | { | ||||
| add_explosion( g, ex, x, y+j, 0, 1, EXPLOSION_SMALL ); | |||||
| add_explosion(g, ex, x, y+j, 0, 1, EXPLOSION_SMALL); | |||||
| wp->type[i] = WEAPON_NONE; | wp->type[i] = WEAPON_NONE; | ||||
| if( x <= t->left[y+j] ) | |||||
| if(x <= t->left[y+j]) | |||||
| { | { | ||||
| if( y+j-1 >= 0 ) t->left[y+j-1]--; | |||||
| if(y+j-1 >= 0) t->left[y+j-1]--; | |||||
| t->left[y+j] -= 2; | t->left[y+j] -= 2; | ||||
| if( y+j+1 < g->h ) t->left[y+j+1]--; | |||||
| if(y+j+1 < g->h) t->left[y+j+1]--; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if( y+j-1 >= 0 ) t->right[y+j-1]++; | |||||
| if(y+j-1 >= 0) t->right[y+j-1]++; | |||||
| t->right[y+j] += 2; | t->right[y+j] += 2; | ||||
| if( y+j+1 < g->h ) t->right[y+j+1]++; | |||||
| if(y+j+1 < g->h) t->right[y+j+1]++; | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| case WEAPON_BEAM: | case WEAPON_BEAM: | ||||
| if( wp->n[i] > 19 ) | |||||
| if(wp->n[i] > 19) | |||||
| { | { | ||||
| break; | break; | ||||
| } | } | ||||
| j = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; | j = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; | ||||
| j = GET_MIN( y, j ); | |||||
| j = GET_MIN(y, j); | |||||
| for( ; j > 0 ; j-- ) | |||||
| for(; j > 0; j--) | |||||
| { | { | ||||
| if( x - 2 <= t->left[y-j] ) | |||||
| if(x - 2 <= t->left[y-j]) | |||||
| { | { | ||||
| add_explosion( g, ex, GET_MIN(t->left[y-j], x+3), y-j, 0, 1, EXPLOSION_SMALL ); | |||||
| add_explosion(g, ex, GET_MIN(t->left[y-j], x+3), y-j, 0, 1, EXPLOSION_SMALL); | |||||
| t->left[y-j] -= GET_RAND(0,3); | t->left[y-j] -= GET_RAND(0,3); | ||||
| } | } | ||||
| else if( x + 3 >= t->right[y-j] ) | |||||
| else if(x + 3 >= t->right[y-j]) | |||||
| { | { | ||||
| add_explosion( g, ex, GET_MAX(t->right[y-j], x-2), y-j, 0, 1, EXPLOSION_SMALL ); | |||||
| add_explosion(g, ex, GET_MAX(t->right[y-j], x-2), y-j, 0, 1, EXPLOSION_SMALL); | |||||
| t->right[y-j] += GET_RAND(0,3); | t->right[y-j] += GET_RAND(0,3); | ||||
| } | } | ||||
| } | } | ||||
| @@ -142,11 +142,11 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) | |||||
| } | } | ||||
| } | } | ||||
| void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| void collide_weapons_aliens(game *g, weapons *wp, aliens *al, explosions *ex) | |||||
| { | { | ||||
| int i, j, k, x, y; | int i, j, k, x, y; | ||||
| for( i = 0; i < WEAPONS; i++ ) | |||||
| for(i = 0; i < WEAPONS; i++) | |||||
| { | { | ||||
| int ok = 0; | int ok = 0; | ||||
| int r; | int r; | ||||
| @@ -154,7 +154,7 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| x = wp->x[i] >> 4; | x = wp->x[i] >> 4; | ||||
| y = wp->y[i] >> 4; | y = wp->y[i] >> 4; | ||||
| switch( wp->type[i] ) | |||||
| switch(wp->type[i]) | |||||
| { | { | ||||
| case WEAPON_LIGHTNING: | case WEAPON_LIGHTNING: | ||||
| case WEAPON_NONE: | case WEAPON_NONE: | ||||
| @@ -163,17 +163,17 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| /* Big nuke */ | /* Big nuke */ | ||||
| r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; | r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; | ||||
| for( j = 0; j < ALIENS; j++ ) | |||||
| for(j = 0; j < ALIENS; j++) | |||||
| { | { | ||||
| if( al->type[j] == ALIEN_NONE || al->life[j] < 0 ) | |||||
| if(al->type[j] == ALIEN_NONE || al->life[j] < 0) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if( wp->n[i] == 0 /* Nuke destroys _everything_ */ || | |||||
| if(wp->n[i] == 0 /* Nuke destroys _everything_ */ || | |||||
| (al->x[j] - x) * (al->x[j] - x) | (al->x[j] - x) * (al->x[j] - x) | ||||
| + 4 * (al->y[j] - y) * (al->y[j] - y) | + 4 * (al->y[j] - y) * (al->y[j] - y) | ||||
| <= r * r ) | |||||
| <= r * r) | |||||
| { | { | ||||
| /* Kill alien, not nuke */ | /* Kill alien, not nuke */ | ||||
| al->life[j] -= 10; | al->life[j] -= 10; | ||||
| @@ -182,22 +182,22 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| break; | break; | ||||
| case WEAPON_BEAM: | case WEAPON_BEAM: | ||||
| if( wp->n[i] > 19 ) | |||||
| if(wp->n[i] > 19) | |||||
| { | { | ||||
| break; | break; | ||||
| } | } | ||||
| r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; | r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; | ||||
| for( j = 0; j < ALIENS; j++ ) | |||||
| for(j = 0; j < ALIENS; j++) | |||||
| { | { | ||||
| if( al->type[j] == ALIEN_NONE || al->life[j] < 0 ) | |||||
| if(al->type[j] == ALIEN_NONE || al->life[j] < 0) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if( x >= al->x[j] && x <= al->x[j] + 4 | |||||
| && y >= al->y[j] + 2 && y-5-r <= al->y[j] ) | |||||
| if(x >= al->x[j] && x <= al->x[j] + 4 | |||||
| && y >= al->y[j] + 2 && y-5-r <= al->y[j]) | |||||
| { | { | ||||
| al->life[j] -= 4; | al->life[j] -= 4; | ||||
| } | } | ||||
| @@ -205,19 +205,19 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| break; | break; | ||||
| case WEAPON_LASER: | case WEAPON_LASER: | ||||
| for( j = 0; j < ALIENS; j++ ) | |||||
| for(j = 0; j < ALIENS; j++) | |||||
| { | { | ||||
| if( al->type[j] == ALIEN_NONE || al->life[j] < 0 ) | |||||
| if(al->type[j] == ALIEN_NONE || al->life[j] < 0) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| for( k = GET_MIN( 0, wp->vy[i] >> 4 ) ; | |||||
| k < GET_MAX( 0, wp->vy[i] >> 4 ) ; | |||||
| k++ ) | |||||
| for(k = GET_MIN(0, wp->vy[i] >> 4); | |||||
| k < GET_MAX(0, wp->vy[i] >> 4); | |||||
| k++) | |||||
| { | { | ||||
| if( x >= al->x[j] && x <= al->x[j] + 4 | |||||
| && y+k >= al->y[j] && y+k <= al->y[j] + 2 ) | |||||
| if(x >= al->x[j] && x <= al->x[j] + 4 | |||||
| && y+k >= al->y[j] && y+k <= al->y[j] + 2) | |||||
| { | { | ||||
| al->life[j]--; | al->life[j]--; | ||||
| ok = 1; | ok = 1; | ||||
| @@ -226,9 +226,9 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| } | } | ||||
| } | } | ||||
| if( ok ) | |||||
| if(ok) | |||||
| { | { | ||||
| add_explosion( g, ex, x, y+1, 0, 0, EXPLOSION_SMALL ); | |||||
| add_explosion(g, ex, x, y+1, 0, 0, EXPLOSION_SMALL); | |||||
| wp->type[i] = WEAPON_NONE; | wp->type[i] = WEAPON_NONE; | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -236,26 +236,26 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| case WEAPON_SEEKER: | case WEAPON_SEEKER: | ||||
| case WEAPON_BOMB: | case WEAPON_BOMB: | ||||
| case WEAPON_FRAGBOMB: | case WEAPON_FRAGBOMB: | ||||
| for( j = 0; j < ALIENS; j++ ) | |||||
| for(j = 0; j < ALIENS; j++) | |||||
| { | { | ||||
| if( al->type[j] == ALIEN_NONE || al->life[j] < 0 ) | |||||
| if(al->type[j] == ALIEN_NONE || al->life[j] < 0) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if( x >= al->x[j] && x <= al->x[j] + 4 | |||||
| && y >= al->y[j] && y <= al->y[j] + 2 ) | |||||
| if(x >= al->x[j] && x <= al->x[j] + 4 | |||||
| && y >= al->y[j] && y <= al->y[j] + 2) | |||||
| { | { | ||||
| al->life[j] -= wp->type[i] == WEAPON_SEEKER ? 1 : 5; | al->life[j] -= wp->type[i] == WEAPON_SEEKER ? 1 : 5; | ||||
| ok = 1; | ok = 1; | ||||
| } | } | ||||
| } | } | ||||
| if( ok ) | |||||
| if(ok) | |||||
| { | { | ||||
| add_explosion( g, ex, x, y+1, 0, 0, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM ); | |||||
| add_explosion(g, ex, x, y+1, 0, 0, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM); | |||||
| if( wp->type[i] == WEAPON_FRAGBOMB ) | |||||
| if(wp->type[i] == WEAPON_FRAGBOMB) | |||||
| { | { | ||||
| wp->n[i] = -1; | wp->n[i] = -1; | ||||
| } | } | ||||
| @@ -269,25 +269,25 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||||
| } | } | ||||
| } | } | ||||
| void collide_player_tunnel( game *g, player *p, tunnel *t, explosions *ex ) | |||||
| void collide_player_tunnel(game *g, player *p, tunnel *t, explosions *ex) | |||||
| { | { | ||||
| if( p->dead ) | |||||
| if(p->dead) | |||||
| { | { | ||||
| return; | return; | ||||
| } | } | ||||
| if( p->x <= t->left[p->y] ) | |||||
| if(p->x <= t->left[p->y]) | |||||
| { | { | ||||
| p->x += 3; | p->x += 3; | ||||
| p->vx = 2; | p->vx = 2; | ||||
| add_explosion( g, ex, p->x+1, p->y-1, 0, 0, EXPLOSION_SMALL ); | |||||
| add_explosion(g, ex, p->x+1, p->y-1, 0, 0, EXPLOSION_SMALL); | |||||
| p->life -= 180; | p->life -= 180; | ||||
| } | } | ||||
| else if( p->x + 5 >= t->right[p->y] ) | |||||
| else if(p->x + 5 >= t->right[p->y]) | |||||
| { | { | ||||
| p->x -= 3; | p->x -= 3; | ||||
| p->vx = -2; | p->vx = -2; | ||||
| add_explosion( g, ex, p->x+4, p->y-1, 0, 0, EXPLOSION_SMALL ); | |||||
| add_explosion(g, ex, p->x+4, p->y-1, 0, 0, EXPLOSION_SMALL); | |||||
| p->life -= 180; | p->life -= 180; | ||||
| } | } | ||||
| } | } | ||||
| @@ -146,85 +146,85 @@ typedef struct | |||||
| /* | /* | ||||
| * From aliens.c | * From aliens.c | ||||
| */ | */ | ||||
| void init_aliens( game *g, aliens *al ); | |||||
| void draw_aliens( game *g, aliens *al ); | |||||
| void update_aliens( game *g, aliens *al ); | |||||
| void add_alien( game *g, aliens *al, int x, int y, int type ); | |||||
| void init_aliens(game *, aliens *); | |||||
| void draw_aliens(game *, aliens *); | |||||
| void update_aliens(game *, aliens *); | |||||
| void add_alien(game *, aliens *, int, int, int); | |||||
| /* | /* | ||||
| * From bonus.c | * From bonus.c | ||||
| */ | */ | ||||
| void init_bonus( game *g, bonus *bo ); | |||||
| void draw_bonus( game *g, bonus *bo ); | |||||
| void update_bonus( game *g, bonus *bo ); | |||||
| void add_bonus( game *g, bonus *bo, int x, int y, int type ); | |||||
| void init_bonus(game *, bonus *); | |||||
| void draw_bonus(game *, bonus *); | |||||
| void update_bonus(game *, bonus *); | |||||
| void add_bonus(game *, bonus *, int, int, int); | |||||
| /* | /* | ||||
| * From box.c | * From box.c | ||||
| */ | */ | ||||
| box * create_box( game *g, int x, int y, int w, int h ); | |||||
| void draw_box( game *g, box *b ); | |||||
| void free_box( box *b ); | |||||
| box * create_box(game *, int, int, int, int); | |||||
| void draw_box(game *, box *); | |||||
| void free_box(box *); | |||||
| /* | /* | ||||
| * From ceo.c | * From ceo.c | ||||
| */ | */ | ||||
| void ceo_alert( game *g ); | |||||
| void ceo_alert(game *); | |||||
| /* | /* | ||||
| * From collide.c | * From collide.c | ||||
| */ | */ | ||||
| void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ); | |||||
| void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ); | |||||
| void collide_player_tunnel( game *g, player *p, tunnel *t, explosions *ex ); | |||||
| void collide_weapons_tunnel(game *, weapons *, tunnel *, explosions *); | |||||
| void collide_weapons_aliens(game *, weapons *, aliens *, explosions *); | |||||
| void collide_player_tunnel(game *, player *, tunnel *, explosions *); | |||||
| /* | /* | ||||
| * From explosions.c | * From explosions.c | ||||
| */ | */ | ||||
| void init_explosions( game *g, explosions *ex ); | |||||
| void add_explosion( game *g, explosions *ex, int x, int y, int vx, int vy, int type ); | |||||
| void draw_explosions( game *g, explosions *ex ); | |||||
| void update_explosions( game *g, explosions *ex ); | |||||
| void init_explosions(game *, explosions *); | |||||
| void add_explosion(game *, explosions *, int, int, int, int, int); | |||||
| void draw_explosions(game *, explosions *); | |||||
| void update_explosions(game *, explosions *); | |||||
| /* | /* | ||||
| * From math.c | * From math.c | ||||
| */ | */ | ||||
| int r00t( int a ); | |||||
| int r00t(int); | |||||
| /* | /* | ||||
| * From overlay.c | * From overlay.c | ||||
| */ | */ | ||||
| void draw_status( game *g ); | |||||
| void draw_status(game *); | |||||
| /* | /* | ||||
| * From player.c | * From player.c | ||||
| */ | */ | ||||
| player * create_player( game *g ); | |||||
| void free_player( player *p ); | |||||
| void draw_player( game *g, player *p ); | |||||
| void update_player( game *g, player *p ); | |||||
| player * create_player(game *); | |||||
| void free_player(player *); | |||||
| void draw_player(game *, player *); | |||||
| void update_player(game *, player *); | |||||
| /* | /* | ||||
| * From starfield.c | * From starfield.c | ||||
| */ | */ | ||||
| starfield * create_starfield( game *g ); | |||||
| void draw_starfield( game *g, starfield *s ); | |||||
| void update_starfield( game *g, starfield *s ); | |||||
| void free_starfield( game *g, starfield *s ); | |||||
| starfield * create_starfield(game *); | |||||
| void draw_starfield(game *, starfield *); | |||||
| void update_starfield(game *, starfield *); | |||||
| void free_starfield(game *, starfield *); | |||||
| /* | /* | ||||
| * From tunnel.c | * From tunnel.c | ||||
| */ | */ | ||||
| tunnel * create_tunnel( game *g, int w, int h ); | |||||
| void free_tunnel( tunnel *t ); | |||||
| void draw_tunnel( game *g, tunnel *t ); | |||||
| void update_tunnel( game *g, tunnel *t ); | |||||
| tunnel * create_tunnel(game *, int, int); | |||||
| void free_tunnel(tunnel *); | |||||
| void draw_tunnel(game *, tunnel *); | |||||
| void update_tunnel(game *, tunnel *); | |||||
| /* | /* | ||||
| * From weapons.c | * From weapons.c | ||||
| */ | */ | ||||
| void init_weapons( game *g, weapons *wp ); | |||||
| void draw_weapons( game *g, weapons *wp ); | |||||
| void update_weapons( game *g, weapons *wp ); | |||||
| void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type ); | |||||
| void init_weapons(game *, weapons *); | |||||
| void draw_weapons(game *, weapons *); | |||||
| void update_weapons(game *, weapons *); | |||||
| void add_weapon(game *, weapons *, int, int, int, int, int); | |||||
| @@ -24,33 +24,33 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| static void draw_small_explosion( int x, int y, int frame ); | |||||
| static void draw_medium_explosion( int x, int y, int frame ); | |||||
| static void draw_small_explosion(int x, int y, int frame); | |||||
| static void draw_medium_explosion(int x, int y, int frame); | |||||
| void init_explosions( game *g, explosions *ex ) | |||||
| void init_explosions(game *g, explosions *ex) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < EXPLOSIONS; i++ ) | |||||
| for(i = 0; i < EXPLOSIONS; i++) | |||||
| { | { | ||||
| ex->type[i] = EXPLOSION_NONE; | ex->type[i] = EXPLOSION_NONE; | ||||
| } | } | ||||
| } | } | ||||
| void add_explosion( game *g, explosions *ex, int x, int y, int vx, int vy, int type ) | |||||
| void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < EXPLOSIONS; i++ ) | |||||
| for(i = 0; i < EXPLOSIONS; i++) | |||||
| { | { | ||||
| if( ex->type[i] == EXPLOSION_NONE ) | |||||
| if(ex->type[i] == EXPLOSION_NONE) | |||||
| { | { | ||||
| ex->type[i] = type; | ex->type[i] = type; | ||||
| ex->x[i] = x; | ex->x[i] = x; | ||||
| ex->y[i] = y; | ex->y[i] = y; | ||||
| ex->vx[i] = vx; | ex->vx[i] = vx; | ||||
| ex->vy[i] = vy; | ex->vy[i] = vy; | ||||
| switch( type ) | |||||
| switch(type) | |||||
| { | { | ||||
| case EXPLOSION_MEDIUM: | case EXPLOSION_MEDIUM: | ||||
| ex->n[i] = 11; | ex->n[i] = 11; | ||||
| @@ -64,44 +64,44 @@ 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 draw_explosions(game *g, explosions *ex) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < EXPLOSIONS; i++ ) | |||||
| for(i = 0; i < EXPLOSIONS; i++) | |||||
| { | { | ||||
| #if 0 | #if 0 | ||||
| ee_color( GREEN ); | |||||
| ee_goto( ex->x[i] + 3, ex->y[i] ); | |||||
| switch( GET_RAND(0,3) ) | |||||
| ee_color(GREEN); | |||||
| ee_goto(ex->x[i] + 3, ex->y[i]); | |||||
| switch(GET_RAND(0,3)) | |||||
| { | { | ||||
| case 0: | case 0: | ||||
| ee_putchar( 'p' ); | |||||
| ee_putchar( 'i' ); | |||||
| ee_putchar( 'f' ); | |||||
| ee_putchar('p'); | |||||
| ee_putchar('i'); | |||||
| ee_putchar('f'); | |||||
| break; | break; | ||||
| case 1: | case 1: | ||||
| ee_putchar( 'p' ); | |||||
| ee_putchar( 'a' ); | |||||
| ee_putchar( 'f' ); | |||||
| ee_putchar('p'); | |||||
| ee_putchar('a'); | |||||
| ee_putchar('f'); | |||||
| break; | break; | ||||
| case 2: | case 2: | ||||
| ee_putchar( 'p' ); | |||||
| ee_putchar( 'o' ); | |||||
| ee_putchar( 'u' ); | |||||
| ee_putchar( 'f' ); | |||||
| ee_putchar('p'); | |||||
| ee_putchar('o'); | |||||
| ee_putchar('u'); | |||||
| ee_putchar('f'); | |||||
| break; | break; | ||||
| } | } | ||||
| ee_putchar( '!' ); | |||||
| ee_putchar('!'); | |||||
| #endif | #endif | ||||
| switch( ex->type[i] ) | |||||
| switch(ex->type[i]) | |||||
| { | { | ||||
| case EXPLOSION_MEDIUM: | case EXPLOSION_MEDIUM: | ||||
| draw_medium_explosion( ex->x[i], ex->y[i], ex->n[i] ); | |||||
| draw_medium_explosion(ex->x[i], ex->y[i], ex->n[i]); | |||||
| break; | break; | ||||
| case EXPLOSION_SMALL: | case EXPLOSION_SMALL: | ||||
| draw_small_explosion( ex->x[i], ex->y[i], ex->n[i] ); | |||||
| draw_small_explosion(ex->x[i], ex->y[i], ex->n[i]); | |||||
| break; | break; | ||||
| case EXPLOSION_NONE: | case EXPLOSION_NONE: | ||||
| break; | break; | ||||
| @@ -109,20 +109,20 @@ void draw_explosions( game *g, explosions *ex ) | |||||
| } | } | ||||
| } | } | ||||
| void update_explosions( game *g, explosions *ex ) | |||||
| void update_explosions(game *g, explosions *ex) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < EXPLOSIONS; i++ ) | |||||
| for(i = 0; i < EXPLOSIONS; i++) | |||||
| { | { | ||||
| switch( ex->type[i] ) | |||||
| switch(ex->type[i]) | |||||
| { | { | ||||
| case EXPLOSION_MEDIUM: | case EXPLOSION_MEDIUM: | ||||
| case EXPLOSION_SMALL: | case EXPLOSION_SMALL: | ||||
| ex->x[i] += ex->vx[i]; | ex->x[i] += ex->vx[i]; | ||||
| ex->y[i] += ex->vy[i]; | ex->y[i] += ex->vy[i]; | ||||
| ex->n[i]--; | ex->n[i]--; | ||||
| if( ex->n[i] < 0 ) | |||||
| if(ex->n[i] < 0) | |||||
| { | { | ||||
| ex->type[i] = EXPLOSION_NONE; | ex->type[i] = EXPLOSION_NONE; | ||||
| } | } | ||||
| @@ -133,121 +133,121 @@ void update_explosions( game *g, explosions *ex ) | |||||
| } | } | ||||
| } | } | ||||
| static void draw_small_explosion( int x, int y, int frame ) | |||||
| static void draw_small_explosion(int x, int y, int frame) | |||||
| { | { | ||||
| switch( frame ) | |||||
| switch(frame) | |||||
| { | { | ||||
| case 6: | case 6: | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_goto( x, y ); | |||||
| ee_putchar( '+' ); | |||||
| ee_color(EE_YELLOW); | |||||
| ee_goto(x, y); | |||||
| ee_putchar('+'); | |||||
| break; | break; | ||||
| case 5: | case 5: | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_goto( x, y ); | |||||
| ee_putchar( 'o' ); | |||||
| ee_color(EE_YELLOW); | |||||
| ee_goto(x, y); | |||||
| ee_putchar('o'); | |||||
| break; | break; | ||||
| case 4: | case 4: | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_goto( x, y-1 ); | |||||
| ee_putchar( '_' ); | |||||
| ee_goto( x-1, y ); | |||||
| ee_putstr( ")_(" ); | |||||
| ee_color(EE_YELLOW); | |||||
| ee_goto(x, y-1); | |||||
| ee_putchar('_'); | |||||
| ee_goto(x-1, y); | |||||
| ee_putstr(")_("); | |||||
| break; | break; | ||||
| case 3: | case 3: | ||||
| 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( "\' `" ); | |||||
| 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; | break; | ||||
| case 2: | case 2: | ||||
| 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( "\'^`" ); | |||||
| 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; | break; | ||||
| case 1: | case 1: | ||||
| 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( "\' `" ); | |||||
| 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; | break; | ||||
| } | } | ||||
| } | } | ||||
| static void draw_medium_explosion( int x, int y, int frame ) | |||||
| static void draw_medium_explosion(int x, int y, int frame) | |||||
| { | { | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_color(EE_YELLOW); | |||||
| switch( frame ) | |||||
| switch(frame) | |||||
| { | { | ||||
| case 10: | case 10: | ||||
| ee_goto( x, y ); | |||||
| ee_putchar( '+' ); | |||||
| ee_goto(x, y); | |||||
| ee_putchar('+'); | |||||
| break; | break; | ||||
| case 9: | case 9: | ||||
| ee_goto( x, y ); | |||||
| ee_putchar( 'o' ); | |||||
| ee_goto(x, y); | |||||
| ee_putchar('o'); | |||||
| break; | break; | ||||
| case 8: | case 8: | ||||
| ee_goto( x, y-1 ); | |||||
| ee_putchar( '_' ); | |||||
| ee_goto( x-1, y ); | |||||
| ee_putstr( ")_(" ); | |||||
| ee_goto(x, y-1); | |||||
| ee_putchar('_'); | |||||
| ee_goto(x-1, y); | |||||
| ee_putstr(")_("); | |||||
| break; | break; | ||||
| case 7: | case 7: | ||||
| ee_goto( x-1, y-1 ); | |||||
| ee_putstr( "._," ); | |||||
| ee_goto( x-1, y ); | |||||
| ee_putstr( ")_(" ); | |||||
| ee_goto( x-1, y+1 ); | |||||
| ee_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; | break; | ||||
| case 6: | case 6: | ||||
| ee_goto( x-1, y-1 ); | |||||
| ee_putstr( ".v," ); | |||||
| ee_goto( x-1, y ); | |||||
| ee_putstr( "> <" ); | |||||
| ee_goto( x-1, y+1 ); | |||||
| ee_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; | break; | ||||
| case 5: | case 5: | ||||
| ee_color( EE_RED ); | |||||
| ee_color(EE_RED); | |||||
| case 4: | case 4: | ||||
| ee_goto( x-2, y-1 ); | |||||
| ee_putstr( "_\\~/_" ); | |||||
| ee_goto( x-2, y ); | |||||
| ee_putstr( "> <" ); | |||||
| ee_goto( x-2, y+1 ); | |||||
| ee_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; | break; | ||||
| case 3: | case 3: | ||||
| ee_color( EE_RED ); | |||||
| ee_color(EE_RED); | |||||
| case 2: | case 2: | ||||
| ee_goto( x-2, y-1 ); | |||||
| ee_putstr( "_\\ /_" ); | |||||
| ee_goto( x-2, y ); | |||||
| ee_putstr( "_ _" ); | |||||
| ee_goto( x-2, y+1 ); | |||||
| ee_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; | break; | ||||
| case 1: | case 1: | ||||
| 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( "\' . `" ); | |||||
| 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; | break; | ||||
| } | } | ||||
| } | } | ||||
| @@ -37,7 +37,7 @@ int main (int argc, char **argv) | |||||
| srand(time(NULL)); | srand(time(NULL)); | ||||
| if( ee_init() ) | |||||
| if(ee_init()) | |||||
| { | { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| @@ -64,174 +64,174 @@ static void start_game (game *g) | |||||
| box *pausebox = NULL; | box *pausebox = NULL; | ||||
| g->sf = create_starfield( g ); | |||||
| g->sf = create_starfield(g); | |||||
| g->wp = malloc(sizeof(weapons)); | g->wp = malloc(sizeof(weapons)); | ||||
| g->ex = malloc(sizeof(explosions)); | g->ex = malloc(sizeof(explosions)); | ||||
| g->bo = malloc(sizeof(bonus)); | g->bo = malloc(sizeof(bonus)); | ||||
| g->t = create_tunnel( g, g->w, g->h ); | |||||
| g->p = create_player( g ); | |||||
| g->t = create_tunnel(g, g->w, g->h); | |||||
| g->p = create_player(g); | |||||
| g->al = malloc(sizeof(aliens)); | g->al = malloc(sizeof(aliens)); | ||||
| init_bonus( g, g->bo ); | |||||
| init_weapons( g, g->wp ); | |||||
| init_explosions( g, g->ex ); | |||||
| init_aliens( g, g->al ); | |||||
| init_bonus(g, g->bo); | |||||
| init_weapons(g, g->wp); | |||||
| init_explosions(g, g->ex); | |||||
| init_aliens(g, g->al); | |||||
| /* Temporary stuff */ | /* Temporary stuff */ | ||||
| g->t->w = 25; | g->t->w = 25; | ||||
| while( !quit ) | |||||
| while(!quit) | |||||
| { | { | ||||
| char key; | char key; | ||||
| while( ( key = ee_get_key() ) ) | |||||
| while((key = ee_get_key())) | |||||
| { | { | ||||
| switch( key ) | |||||
| switch(key) | |||||
| { | { | ||||
| case 'q': | case 'q': | ||||
| quit = 1; | quit = 1; | ||||
| break; | break; | ||||
| case 'p': | case 'p': | ||||
| poz = !poz; | poz = !poz; | ||||
| if( poz ) | |||||
| if(poz) | |||||
| { | { | ||||
| pausebox = create_box( g, g->w / 2, g->h / 2, | |||||
| g->w - 16, 8 ); | |||||
| pausebox = create_box(g, g->w / 2, g->h / 2, | |||||
| g->w - 16, 8); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| free_box( pausebox ); | |||||
| free_box(pausebox); | |||||
| } | } | ||||
| break; | break; | ||||
| case '\t': | case '\t': | ||||
| ceo_alert( g ); | |||||
| ceo_alert(g); | |||||
| poz = 1; | poz = 1; | ||||
| break; | break; | ||||
| case 's': | case 's': | ||||
| skip = 1; | skip = 1; | ||||
| break; | break; | ||||
| default: | default: | ||||
| if( g->p->dead ) | |||||
| if(g->p->dead) | |||||
| { | { | ||||
| break; | break; | ||||
| } | } | ||||
| switch( key ) | |||||
| switch(key) | |||||
| { | { | ||||
| case 'h': | case 'h': | ||||
| g->p->vx = -2; | g->p->vx = -2; | ||||
| break; | break; | ||||
| case 'j': | case 'j': | ||||
| if( g->p->y < g->h - 2 ) g->p->y += 1; | |||||
| if(g->p->y < g->h - 2) g->p->y += 1; | |||||
| break; | break; | ||||
| case 'k': | case 'k': | ||||
| if( g->p->y > 1 ) g->p->y -= 1; | |||||
| if(g->p->y > 1) g->p->y -= 1; | |||||
| break; | break; | ||||
| case 'l': | case 'l': | ||||
| g->p->vx = 2; | g->p->vx = 2; | ||||
| break; | break; | ||||
| case 'n': | case 'n': | ||||
| if( g->p->special >= COST_NUKE ) | |||||
| if(g->p->special >= COST_NUKE) | |||||
| { | { | ||||
| g->p->special -= COST_NUKE; | g->p->special -= COST_NUKE; | ||||
| add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_NUKE ); | |||||
| add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_NUKE); | |||||
| } | } | ||||
| break; | break; | ||||
| case 'f': | case 'f': | ||||
| if( g->p->special >= COST_FRAGBOMB ) | |||||
| if(g->p->special >= COST_FRAGBOMB) | |||||
| { | { | ||||
| g->p->special -= COST_FRAGBOMB; | g->p->special -= COST_FRAGBOMB; | ||||
| add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_FRAGBOMB ); | |||||
| add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_FRAGBOMB); | |||||
| } | } | ||||
| break; | break; | ||||
| case 'b': | case 'b': | ||||
| if( g->p->special >= COST_BEAM ) | |||||
| if(g->p->special >= COST_BEAM) | |||||
| { | { | ||||
| g->p->special -= COST_BEAM; | g->p->special -= COST_BEAM; | ||||
| add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_BEAM ); | |||||
| add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_BEAM); | |||||
| } | } | ||||
| break; | break; | ||||
| case ' ': | case ' ': | ||||
| if( g->p->weapon == 0 ) | |||||
| if(g->p->weapon == 0) | |||||
| { | { | ||||
| g->p->weapon = 4; | g->p->weapon = 4; | ||||
| add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, 0, -32, WEAPON_LASER ); | |||||
| add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -32, WEAPON_LASER ); | |||||
| add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, 0, -32, WEAPON_LASER); | |||||
| add_weapon(g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -32, WEAPON_LASER); | |||||
| /* Extra schtuph */ | /* Extra schtuph */ | ||||
| add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER ); | |||||
| add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER ); | |||||
| add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER); | |||||
| add_weapon(g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER); | |||||
| /* More schtuph */ | /* More schtuph */ | ||||
| add_weapon( g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); | |||||
| add_weapon( g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); | |||||
| add_weapon(g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER); | |||||
| add_weapon(g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER); | |||||
| /* Even more schtuph */ | /* Even more schtuph */ | ||||
| add_weapon( g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); | |||||
| add_weapon( g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); | |||||
| add_weapon(g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER); | |||||
| add_weapon(g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER); | |||||
| /* Extra schtuph */ | /* Extra schtuph */ | ||||
| add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER ); | |||||
| add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER ); | |||||
| add_weapon(g, g->wp, g->p->x << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER); | |||||
| add_weapon(g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER); | |||||
| /* MORE SCHTUPH! */ | /* MORE SCHTUPH! */ | ||||
| add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB ); | |||||
| add_weapon(g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB); | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if( !poz || skip ) | |||||
| if(!poz || skip) | |||||
| { | { | ||||
| skip = 0; | skip = 0; | ||||
| /* XXX: to be removed */ | /* XXX: to be removed */ | ||||
| if( GET_RAND(0,10) == 0 ) | |||||
| if(GET_RAND(0,10) == 0) | |||||
| { | { | ||||
| int list[3] = { ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ }; | int list[3] = { ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ }; | ||||
| add_alien( g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)] ); | |||||
| add_alien(g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)]); | |||||
| } | } | ||||
| /* Update game rules */ | /* Update game rules */ | ||||
| if( g->t->right[1] - g->t->left[1] == g->t->w ) | |||||
| if(g->t->right[1] - g->t->left[1] == g->t->w) | |||||
| { | { | ||||
| g->t->w = 85 - g->t->w; | g->t->w = 85 - g->t->w; | ||||
| } | } | ||||
| /* Scroll and update positions */ | /* Scroll and update positions */ | ||||
| collide_player_tunnel( g, g->p, g->t, g->ex ); | |||||
| update_player( g, g->p ); | |||||
| collide_player_tunnel( g, g->p, g->t, g->ex ); | |||||
| update_starfield( g, g->sf ); | |||||
| update_bonus( g, g->bo ); | |||||
| update_aliens( g, g->al ); | |||||
| collide_weapons_tunnel( g, g->wp, g->t, g->ex ); | |||||
| collide_weapons_aliens( g, g->wp, g->al, g->ex ); | |||||
| update_weapons( g, g->wp ); | |||||
| collide_weapons_tunnel( g, g->wp, g->t, g->ex ); | |||||
| collide_weapons_aliens( g, g->wp, g->al, g->ex ); | |||||
| update_explosions( g, g->ex ); | |||||
| update_tunnel( g, g->t ); | |||||
| collide_player_tunnel(g, g->p, g->t, g->ex); | |||||
| update_player(g, g->p); | |||||
| collide_player_tunnel(g, g->p, g->t, g->ex); | |||||
| update_starfield(g, g->sf); | |||||
| update_bonus(g, g->bo); | |||||
| update_aliens(g, g->al); | |||||
| collide_weapons_tunnel(g, g->wp, g->t, g->ex); | |||||
| collide_weapons_aliens(g, g->wp, g->al, g->ex); | |||||
| update_weapons(g, g->wp); | |||||
| collide_weapons_tunnel(g, g->wp, g->t, g->ex); | |||||
| collide_weapons_aliens(g, g->wp, g->al, g->ex); | |||||
| update_explosions(g, g->ex); | |||||
| update_tunnel(g, g->t); | |||||
| } | } | ||||
| /* Clear screen */ | /* Clear screen */ | ||||
| ee_clear(); | ee_clear(); | ||||
| /* Print starfield, tunnel, aliens, player and explosions */ | /* Print starfield, tunnel, aliens, player and explosions */ | ||||
| draw_starfield( g, g->sf ); | |||||
| draw_aliens( g, g->al ); | |||||
| draw_tunnel( g, g->t ); | |||||
| draw_bonus( g, g->bo ); | |||||
| draw_explosions( g, g->ex ); | |||||
| draw_weapons( g, g->wp ); | |||||
| draw_player( g, g->p ); | |||||
| draw_status( g ); | |||||
| draw_starfield(g, g->sf); | |||||
| draw_aliens(g, g->al); | |||||
| draw_tunnel(g, g->t); | |||||
| draw_bonus(g, g->bo); | |||||
| draw_explosions(g, g->ex); | |||||
| draw_weapons(g, g->wp); | |||||
| draw_player(g, g->p); | |||||
| draw_status(g); | |||||
| /* Print pause box if needed */ | /* Print pause box if needed */ | ||||
| if( poz ) | |||||
| if(poz) | |||||
| { | { | ||||
| pausebox->frame++; | pausebox->frame++; | ||||
| draw_box( g, pausebox ); | |||||
| draw_box(g, pausebox); | |||||
| } | } | ||||
| /* Refresh */ | /* Refresh */ | ||||
| @@ -240,13 +240,13 @@ static void start_game (game *g) | |||||
| purcompteur++; | purcompteur++; | ||||
| } | } | ||||
| if( pausebox ) | |||||
| if(pausebox) | |||||
| { | { | ||||
| free_box( pausebox ); | |||||
| free_box(pausebox); | |||||
| } | } | ||||
| free_starfield( g, g->sf ); | |||||
| free_tunnel( g->t ); | |||||
| free_player( g->p ); | |||||
| free_starfield(g, g->sf); | |||||
| free_tunnel(g->t); | |||||
| free_player(g->p); | |||||
| } | } | ||||
| @@ -3,7 +3,7 @@ | |||||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | ||||
| * All Rights Reserved | * All Rights Reserved | ||||
| * | * | ||||
| * $Id: math.c,v 1.2 2002/12/22 23:01:35 sam Exp $ | |||||
| * $Id$ | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or modify | * 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 | * it under the terms of the GNU General Public License as published by | ||||
| @@ -22,11 +22,11 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| int r00t( int a ) | |||||
| int r00t(int a) | |||||
| { | { | ||||
| int x = a > 100000 ? 1000 : a > 1000 ? 100 : a > 10 ? 10 : 1; | int x = a > 100000 ? 1000 : a > 1000 ? 100 : a > 10 ? 10 : 1; | ||||
| if( a <= 0 ) | |||||
| if(a <= 0) | |||||
| { | { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -24,63 +24,63 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| void draw_status( game *g ) | |||||
| void draw_status(game *g) | |||||
| { | { | ||||
| static char dots30[] = "------------------------------"; | static char dots30[] = "------------------------------"; | ||||
| static char dashes30[] = "=============================="; | static char dashes30[] = "=============================="; | ||||
| /* Draw life jauge */ | /* Draw life jauge */ | ||||
| ee_color( EE_GRAY ); | |||||
| ee_goto( 4, 1 ); | |||||
| ee_putstr( dots30 ); | |||||
| ee_color(EE_GRAY); | |||||
| ee_goto(4, 1); | |||||
| ee_putstr(dots30); | |||||
| if( g->p->life > MAX_LIFE * 7 / 10 ) | |||||
| if(g->p->life > MAX_LIFE * 7 / 10) | |||||
| { | { | ||||
| ee_color( EE_GREEN ); | |||||
| ee_color(EE_GREEN); | |||||
| } | } | ||||
| else if( g->p->life > MAX_LIFE * 3 / 10 ) | |||||
| else if(g->p->life > MAX_LIFE * 3 / 10) | |||||
| { | { | ||||
| ee_color( EE_YELLOW ); | |||||
| ee_color(EE_YELLOW); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| ee_color( EE_RED ); | |||||
| ee_color(EE_RED); | |||||
| } | } | ||||
| ee_goto( 4, 1 ); | |||||
| ee_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); | |||||
| ee_color( EE_WHITE ); | |||||
| ee_goto( 1, 1 ); | |||||
| ee_putstr( "L |" ); | |||||
| ee_goto( 34, 1 ); | |||||
| ee_putstr( "|" ); | |||||
| ee_color(EE_WHITE); | |||||
| ee_goto(1, 1); | |||||
| ee_putstr("L |"); | |||||
| ee_goto(34, 1); | |||||
| ee_putstr("|"); | |||||
| /* Draw weapon jauge */ | /* Draw weapon jauge */ | ||||
| ee_color( EE_GRAY ); | |||||
| ee_goto( 42, 1 ); | |||||
| ee_putstr( dots30 + 10 ); | |||||
| ee_color(EE_GRAY); | |||||
| ee_goto(42, 1); | |||||
| ee_putstr(dots30 + 10); | |||||
| if( g->p->special > MAX_SPECIAL * 9 / 10 ) | |||||
| if(g->p->special > MAX_SPECIAL * 9 / 10) | |||||
| { | { | ||||
| ee_color( EE_WHITE ); | |||||
| ee_color(EE_WHITE); | |||||
| } | } | ||||
| else if( g->p->special > MAX_SPECIAL * 3 / 10 ) | |||||
| else if(g->p->special > MAX_SPECIAL * 3 / 10) | |||||
| { | { | ||||
| ee_color( EE_CYAN ); | |||||
| ee_color(EE_CYAN); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| ee_color( EE_BLUE ); | |||||
| ee_color(EE_BLUE); | |||||
| } | } | ||||
| ee_goto( 42, 1 ); | |||||
| ee_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); | |||||
| ee_color( EE_WHITE ); | |||||
| ee_goto( 39, 1 ); | |||||
| ee_putstr( "S |" ); | |||||
| ee_goto( 62, 1 ); | |||||
| ee_putstr( "|" ); | |||||
| ee_color(EE_WHITE); | |||||
| ee_goto(39, 1); | |||||
| ee_putstr("S |"); | |||||
| ee_goto(62, 1); | |||||
| ee_putstr("|"); | |||||
| } | } | ||||
| @@ -25,7 +25,7 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| /* Init tunnel */ | /* Init tunnel */ | ||||
| player * create_player( game *g ) | |||||
| player * create_player(game *g) | |||||
| { | { | ||||
| player *p = malloc(sizeof(player)); | player *p = malloc(sizeof(player)); | ||||
| @@ -41,59 +41,59 @@ player * create_player( game *g ) | |||||
| return p; | return p; | ||||
| } | } | ||||
| void free_player( player *p ) | |||||
| void free_player(player *p) | |||||
| { | { | ||||
| free( p ); | |||||
| free(p); | |||||
| } | } | ||||
| void draw_player( game *g, player *p ) | |||||
| void draw_player(game *g, player *p) | |||||
| { | { | ||||
| if( p->dead ) | |||||
| if(p->dead) | |||||
| { | { | ||||
| return; | return; | ||||
| } | } | ||||
| 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" ); | |||||
| 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 ) | |||||
| void update_player(game *g, player *p) | |||||
| { | { | ||||
| if( p->dead ) | |||||
| if(p->dead) | |||||
| { | { | ||||
| return; | return; | ||||
| } | } | ||||
| if( p->life <= 0 ) | |||||
| if(p->life <= 0) | |||||
| { | { | ||||
| add_explosion( g, g->ex, p->x, p->y, 0, 0, EXPLOSION_SMALL ); | |||||
| add_explosion(g, g->ex, p->x, p->y, 0, 0, EXPLOSION_SMALL); | |||||
| p->dead = 1; | p->dead = 1; | ||||
| return; | return; | ||||
| } | } | ||||
| /* Update weapon stats */ | /* Update weapon stats */ | ||||
| if( p->weapon ) | |||||
| if(p->weapon) | |||||
| { | { | ||||
| p->weapon--; | p->weapon--; | ||||
| } | } | ||||
| if( p->special < MAX_SPECIAL ) | |||||
| if(p->special < MAX_SPECIAL) | |||||
| { | { | ||||
| p->special++; | p->special++; | ||||
| } | } | ||||
| /* Update life */ | /* Update life */ | ||||
| if( p->life < MAX_LIFE ) | |||||
| if(p->life < MAX_LIFE) | |||||
| { | { | ||||
| p->life++; | p->life++; | ||||
| } | } | ||||
| @@ -101,20 +101,20 @@ void update_player( game *g, player *p ) | |||||
| /* Update coords */ | /* Update coords */ | ||||
| p->x += p->vx; | p->x += p->vx; | ||||
| if( p->vx < 0 ) | |||||
| if(p->vx < 0) | |||||
| { | { | ||||
| p->vx++; | p->vx++; | ||||
| } | } | ||||
| else if( p->vx > 0 ) | |||||
| else if(p->vx > 0) | |||||
| { | { | ||||
| p->vx--; | p->vx--; | ||||
| } | } | ||||
| if( p->x < 1 ) | |||||
| if(p->x < 1) | |||||
| { | { | ||||
| p->x = 1; | p->x = 1; | ||||
| } | } | ||||
| else if( p->x > g->w - 7 ) | |||||
| else if(p->x > g->w - 7) | |||||
| { | { | ||||
| p->x = g->w - 7; | p->x = g->w - 7; | ||||
| } | } | ||||
| @@ -24,55 +24,55 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| starfield * create_starfield( game *g ) | |||||
| starfield * create_starfield(game *g) | |||||
| { | { | ||||
| int i; | int i; | ||||
| starfield *s; | starfield *s; | ||||
| s = malloc( STARS * sizeof(starfield) ); | |||||
| s = malloc(STARS * sizeof(starfield)); | |||||
| for( i = 0; i < STARS; i++ ) | |||||
| for(i = 0; i < STARS; i++) | |||||
| { | { | ||||
| s[i].x = GET_RAND( 0, g->w ); | |||||
| s[i].y = GET_RAND( 0, g->h ); | |||||
| s[i].z = GET_RAND( 1, 4 ); | |||||
| s[i].c = GET_RAND( 6, 8 ); | |||||
| s[i].ch = GET_RAND( 0, 2 ) ? '.' : '\''; | |||||
| s[i].x = GET_RAND(0, g->w); | |||||
| s[i].y = GET_RAND(0, g->h); | |||||
| s[i].z = GET_RAND(1, 4); | |||||
| s[i].c = GET_RAND(6, 8); | |||||
| s[i].ch = GET_RAND(0, 2) ? '.' : '\''; | |||||
| } | } | ||||
| return s; | return s; | ||||
| } | } | ||||
| void draw_starfield( game *g, starfield *s ) | |||||
| void draw_starfield(game *g, starfield *s) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < STARS; i++ ) | |||||
| for(i = 0; i < STARS; i++) | |||||
| { | { | ||||
| if( s[i].x >= 0 ) | |||||
| if(s[i].x >= 0) | |||||
| { | { | ||||
| ee_color( s[i].c ); | |||||
| ee_goto( s[i].x, s[i].y ); | |||||
| ee_putchar( s[i].ch ); | |||||
| ee_color(s[i].c); | |||||
| ee_goto(s[i].x, s[i].y); | |||||
| ee_putchar(s[i].ch); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void update_starfield( game *g, starfield *s ) | |||||
| void update_starfield(game *g, starfield *s) | |||||
| { | { | ||||
| int i; | int i; | ||||
| for( i = 0; i < STARS; i++ ) | |||||
| for(i = 0; i < STARS; i++) | |||||
| { | { | ||||
| if( s[i].x < 0 ) | |||||
| if(s[i].x < 0) | |||||
| { | { | ||||
| s[i].x = GET_RAND( 0, g->w ); | |||||
| s[i].x = GET_RAND(0, g->w); | |||||
| s[i].y = 0; | s[i].y = 0; | ||||
| s[i].z = GET_RAND( 1, 3 ); | |||||
| s[i].c = GET_RAND( 6, 8 ); | |||||
| s[i].ch = GET_RAND( 0, 2 ) ? '.' : '\''; | |||||
| s[i].z = GET_RAND(1, 3); | |||||
| s[i].c = GET_RAND(6, 8); | |||||
| s[i].ch = GET_RAND(0, 2) ? '.' : '\''; | |||||
| } | } | ||||
| else if( s[i].y < g->h-1 ) | |||||
| else if(s[i].y < g->h-1) | |||||
| { | { | ||||
| s[i].y += s[i].z; | s[i].y += s[i].z; | ||||
| } | } | ||||
| @@ -83,8 +83,8 @@ void update_starfield( game *g, starfield *s ) | |||||
| } | } | ||||
| } | } | ||||
| void free_starfield( game *g, starfield *s ) | |||||
| void free_starfield(game *g, starfield *s) | |||||
| { | { | ||||
| free( s ); | |||||
| free(s); | |||||
| } | } | ||||
| @@ -27,7 +27,7 @@ | |||||
| #include "common.h" | #include "common.h" | ||||
| /* Init tunnel */ | /* Init tunnel */ | ||||
| tunnel * create_tunnel( game *g, int w, int h ) | |||||
| tunnel * create_tunnel(game *g, int w, int h) | |||||
| { | { | ||||
| int i; | int i; | ||||
| tunnel *t = malloc(sizeof(tunnel)); | tunnel *t = malloc(sizeof(tunnel)); | ||||
| @@ -37,9 +37,9 @@ tunnel * create_tunnel( game *g, int w, int h ) | |||||
| t->w = w; | t->w = w; | ||||
| t->h = h; | t->h = h; | ||||
| if( t->w >= g->w ) | |||||
| if(t->w >= g->w) | |||||
| { | { | ||||
| for( i = 0; i < g->h; i++ ) | |||||
| for(i = 0; i < g->h; i++) | |||||
| { | { | ||||
| t->left[i] = -10; | t->left[i] = -10; | ||||
| t->right[i] = g->w + 10; | t->right[i] = g->w + 10; | ||||
| @@ -50,119 +50,119 @@ tunnel * create_tunnel( game *g, int w, int h ) | |||||
| t->left[0] = (g->w - w) / 2; | t->left[0] = (g->w - w) / 2; | ||||
| t->right[0] = (g->w + w) / 2; | t->right[0] = (g->w + w) / 2; | ||||
| /* Yeah, sub-efficient, but less code to do :-) */ | /* Yeah, sub-efficient, but less code to do :-) */ | ||||
| for( i = 0; i < g->h; i++ ) | |||||
| for(i = 0; i < g->h; i++) | |||||
| { | { | ||||
| update_tunnel( g, t ); | |||||
| update_tunnel(g, t); | |||||
| } | } | ||||
| } | } | ||||
| return t; | return t; | ||||
| } | } | ||||
| void free_tunnel( tunnel *t ) | |||||
| void free_tunnel(tunnel *t) | |||||
| { | { | ||||
| free( t->left ); | |||||
| free( t->right ); | |||||
| free( t ); | |||||
| free(t->left); | |||||
| free(t->right); | |||||
| free(t); | |||||
| } | } | ||||
| void draw_tunnel( game *g, tunnel *t ) | |||||
| void draw_tunnel(game *g, tunnel *t) | |||||
| { | { | ||||
| int i, j; | int i, j; | ||||
| char c; | char c; | ||||
| ee_color( EE_GREEN ); | |||||
| ee_color(EE_GREEN); | |||||
| /* Left border */ | /* Left border */ | ||||
| for( i = 0; i < g->h ; i++ ) | |||||
| for(i = 0; i < g->h ; i++) | |||||
| { | { | ||||
| if( t->left[i] <= -10 ) | |||||
| if(t->left[i] <= -10) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if( i + 1 == g->h || t->left[i] > t->left[i+1] ) | |||||
| if(i + 1 == g->h || t->left[i] > t->left[i+1]) | |||||
| { | { | ||||
| c = ( i == 0 || t->left[i] > t->left[i-1] ) ? '>' : '/'; | |||||
| c = (i == 0 || t->left[i] > t->left[i-1]) ? '>' : '/'; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| c = ( i == 0 || t->left[i] > t->left[i-1] ) ? '\\' : '<'; | |||||
| c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<'; | |||||
| } | } | ||||
| ee_goto( t->left[i] + 1, i ); | |||||
| ee_putchar( c ); | |||||
| ee_goto(t->left[i] + 1, i); | |||||
| ee_putchar(c); | |||||
| if( i + 1 < g->h ) | |||||
| if(i + 1 < g->h) | |||||
| { | { | ||||
| for( j = 1; j < t->left[i+1] - t->left[i]; j++ ) | |||||
| for(j = 1; j < t->left[i+1] - t->left[i]; j++) | |||||
| { | { | ||||
| ee_goto( t->left[i] + j + 1, i ); | |||||
| ee_putchar( '_' ); | |||||
| ee_goto(t->left[i] + j + 1, i); | |||||
| ee_putchar('_'); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Right border */ | /* Right border */ | ||||
| for( i = 0; i < g->h ; i++ ) | |||||
| for(i = 0; i < g->h ; i++) | |||||
| { | { | ||||
| if( t->right[i] >= g->w + 10 ) | |||||
| if(t->right[i] >= g->w + 10) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if( i + 1 == g->h || t->right[i] > t->right[i+1] ) | |||||
| if(i + 1 == g->h || t->right[i] > t->right[i+1]) | |||||
| { | { | ||||
| c = ( i == 0 || t->right[i] > t->right[i-1] ) ? '>' : '/'; | |||||
| c = (i == 0 || t->right[i] > t->right[i-1]) ? '>' : '/'; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| c = ( i == 0 || t->right[i] > t->right[i-1] ) ? '\\' : '<'; | |||||
| c = (i == 0 || t->right[i] > t->right[i-1]) ? '\\' : '<'; | |||||
| } | } | ||||
| if( i + 1 < g->h ) | |||||
| if(i + 1 < g->h) | |||||
| { | { | ||||
| for( j = 1; j < t->right[i] - t->right[i+1]; j++ ) | |||||
| for(j = 1; j < t->right[i] - t->right[i+1]; j++) | |||||
| { | { | ||||
| ee_goto( t->right[i+1] + j - 1, i ); | |||||
| ee_putchar( '_' ); | |||||
| ee_goto(t->right[i+1] + j - 1, i); | |||||
| ee_putchar('_'); | |||||
| } | } | ||||
| } | } | ||||
| ee_goto( t->right[i] - 1, i ); | |||||
| ee_putchar( c ); | |||||
| ee_goto(t->right[i] - 1, i); | |||||
| ee_putchar(c); | |||||
| } | } | ||||
| ee_color( EE_RED ); | |||||
| ee_color(EE_RED); | |||||
| /* Left concrete */ | /* Left concrete */ | ||||
| for( i = 0; i < g->h ; i++ ) | |||||
| for(i = 0; i < g->h ; i++) | |||||
| { | { | ||||
| for( j = 0 ; j <= t->left[i]; j++ ) | |||||
| for(j = 0 ; j <= t->left[i]; j++) | |||||
| { | { | ||||
| ee_goto( j, i ); | |||||
| ee_putchar( '#' ); | |||||
| ee_goto(j, i); | |||||
| ee_putchar('#'); | |||||
| } | } | ||||
| } | } | ||||
| /* Right concrete */ | /* Right concrete */ | ||||
| for( i = 0; i < g->h ; i++ ) | |||||
| for(i = 0; i < g->h ; i++) | |||||
| { | { | ||||
| for( j = t->right[i] ; j < g->w ; j++ ) | |||||
| for(j = t->right[i] ; j < g->w ; j++) | |||||
| { | { | ||||
| ee_goto( j, i ); | |||||
| ee_putchar( '#' ); | |||||
| ee_goto(j, i); | |||||
| ee_putchar('#'); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void update_tunnel( game *g, tunnel *t ) | |||||
| void update_tunnel(game *g, tunnel *t) | |||||
| { | { | ||||
| static int const delta[] = { -3, -2, -1, 1, 2, 3 }; | static int const delta[] = { -3, -2, -1, 1, 2, 3 }; | ||||
| int i,j,k; | int i,j,k; | ||||
| /* Slide tunnel one block vertically */ | /* Slide tunnel one block vertically */ | ||||
| for( i = t->h - 1; i--; ) | |||||
| for(i = t->h - 1; i--;) | |||||
| { | { | ||||
| t->left[i+1] = t->left[i]; | t->left[i+1] = t->left[i]; | ||||
| t->right[i+1] = t->right[i]; | t->right[i+1] = t->right[i]; | ||||
| @@ -173,18 +173,18 @@ void update_tunnel( game *g, tunnel *t ) | |||||
| j = delta[GET_RAND(0,6)]; | j = delta[GET_RAND(0,6)]; | ||||
| /* Check in which direction we need to alter tunnel */ | /* Check in which direction we need to alter tunnel */ | ||||
| if( t->right[1] - t->left[1] < t->w ) | |||||
| if(t->right[1] - t->left[1] < t->w) | |||||
| { | { | ||||
| /* Not wide enough, make sure i <= j */ | /* Not wide enough, make sure i <= j */ | ||||
| if( i > j ) | |||||
| if(i > j) | |||||
| { | { | ||||
| k = j; j = i; i = k; | k = j; j = i; i = k; | ||||
| } | } | ||||
| } | } | ||||
| else if( t->right[1] - t->left[1] - 2 > t->w ) | |||||
| else if(t->right[1] - t->left[1] - 2 > t->w) | |||||
| { | { | ||||
| /* Too wide, make sure i >= j */ | /* Too wide, make sure i >= j */ | ||||
| if( i < j ) | |||||
| if(i < j) | |||||
| { | { | ||||
| k = j; j = i; i = k; | k = j; j = i; i = k; | ||||
| } | } | ||||
| @@ -195,7 +195,7 @@ void update_tunnel( game *g, tunnel *t ) | |||||
| } | } | ||||
| /* If width doesn't exceed game size, update coords */ | /* If width doesn't exceed game size, update coords */ | ||||
| if( t->w <= g->w || t->right[1] - t->left[1] < t->w ) | |||||
| if(t->w <= g->w || t->right[1] - t->left[1] < t->w) | |||||
| { | { | ||||
| t->left[0] = t->left[1] + i; | t->left[0] = t->left[1] + i; | ||||
| t->right[0] = t->right[1] + j; | t->right[0] = t->right[1] + j; | ||||
| @@ -206,26 +206,26 @@ void update_tunnel( game *g, tunnel *t ) | |||||
| t->right[0] = g->w + 10; | t->right[0] = g->w + 10; | ||||
| } | } | ||||
| if( t->w > g->w ) | |||||
| if(t->w > g->w) | |||||
| { | { | ||||
| if( t->left[0] < 0 && t->right[0] < g->w - 2 ) | |||||
| if(t->left[0] < 0 && t->right[0] < g->w - 2) | |||||
| { | { | ||||
| t->left[0] = t->left[1] + 1; | t->left[0] = t->left[1] + 1; | ||||
| } | } | ||||
| if( t->left[0] > 1 && t->right[0] > g->w - 1 ) | |||||
| if(t->left[0] > 1 && t->right[0] > g->w - 1) | |||||
| { | { | ||||
| t->right[0] = t->right[1] - 1; | t->right[0] = t->right[1] - 1; | ||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if( t->left[0] < 0 ) | |||||
| if(t->left[0] < 0) | |||||
| { | { | ||||
| t->left[0] = t->left[1] + 1; | t->left[0] = t->left[1] + 1; | ||||
| } | } | ||||
| if( t->right[0] > g->w - 1 ) | |||||
| if(t->right[0] > g->w - 1) | |||||
| { | { | ||||
| t->right[0] = t->right[1] - 1; | t->right[0] = t->right[1] - 1; | ||||
| } | } | ||||