DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T f

⟦472645368⟧ TextFile

    Length: 6018 (0x1782)
    Types: TextFile
    Names: »fall.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/X/Xwanderer/fall.c« 

TextFile

#include "wand_head.h"

extern void draw_symbol();
#ifdef XWANDER
extern int tinymode;
#endif

int fall(mx,my,x,y,sx,sy,screen,howdead)
int  x,y,sx,sy, *mx, *my;
char screen[NOOFROWS][ROWLEN+1],
     howdead[25];
{
int nx = x,nyl = y,nyr = y,retval = 0;
if (y>(NOOFROWS-1))
    return(0);
if((screen[y][x]!='O')&&(screen[y][x]!=' ')&&(screen[y][x]!='M')&&(screen[y][x]!='\\')&&(screen[y][x]!='/')&&(screen[y][x]!='@'))
    return(0);
if(screen[y][x] == 'O')
    {
    if((screen[y][x-1] == ' ') && (screen[y-1][x-1] == ' '))
        nx--;
    else
	{
        if((screen[y][x+1] == ' ') && (screen[y-1][x+1] == ' '))
            nx++;
	else
	    nx = -1;
	}
    if((screen[y-1][x] == ' ') && (screen[y-1][x+1] == ' '))
        nyr--;
    else
	{
        if((screen[y+1][x] == ' ') && (screen[y+1][x+1] == ' '))
            nyr++;
	else
	    nyr = -1;
	}
    if((screen[y-1][x] == ' ') && (screen[y-1][x-1] == ' '))
        nyl--;
    else
	{
        if((screen[y+1][x] == ' ') && (screen[y+1][x-1] == ' '))
            nyl++;
	else
	    nyl = -1;
	}
    }
if(screen[y][x] == '\\')
    {
    if(screen[y-1][++nx] != ' ')
	nx = -1;
    if(screen[--nyr][x+1] != ' ')
        nyr = -1;
    if(screen[++nyl][x-1] != ' ')
        nyl = -1;
    }
if(screen[y][x] == '/')
    {
    if(screen[y-1][--nx] != ' ')
	nx = -1;
    if(screen[++nyr][x+1] != ' ')
	nyr = -1;
    if(screen[--nyl][x-1] != ' ')
	nyl = -1;
    }
if((screen[y][nx] != ' ')&&(screen[y][nx] != ' '))
    nx = -1;
if((screen[y-1][x] == 'O') && (nx>=0) && (y>0))       /* boulder falls ? */
    {
    screen[y-1][x] = ' ';
    if(screen[y][nx] == '@')
        {
    	strcpy(howdead,"a falling boulder"); dobeep();
    	retval=1;
    	}
    if(screen[y][nx] == 'M')
        {
    	dobeep();
    	*mx = *my = -2;
	screen[y][nx] = ' ';
    	}
    screen[y][nx] = 'O';
#ifndef XWANDER
    if((y<(sy+5)) && (y>(sy-3)) && (x>(sx-6)) && (x<(sx+6)))
        draw_symbol((x-sx+5)*3,(y-sy+2)*2,' ');
#else
    if((y<(sy+5)) && (y>(sy-3)) && (x>(sx-6)) && (x<(sx+6)) || tinymode)
        draw_symbol((x-sx+5),(y-sy+2),' ');
#endif
#ifndef XWANDER
    if((y<(sy+4)) && (y>(sy-4)) && (nx>(sx-6)) && (nx<(sx+6)))
        draw_symbol((nx-sx+5)*3,(y-sy+3)*2,'O');
    refresh();
#else
    if((y<(sy+4)) && (y>(sy-4)) && (nx>(sx-6)) && (nx<(sx+6)) || tinymode)
        draw_symbol((nx-sx+5),(y-sy+3),'O');
    update_symbols ();
#endif
    retval+=fall(mx,my,nx ,y+1,sx,sy,screen,howdead);
    retval+=fall(mx,my,nx ,y+1,sx,sy,screen,howdead);
    retval+=fall(mx,my,nx ,y+1,sx,sy,screen,howdead);
    retval+=fall(mx,my,x+1,y-1,sx,sy,screen,howdead);
    retval+=fall(mx,my,x-1,y-1,sx,sy,screen,howdead);
    retval+=fall(mx,my,x  ,y-1,sx,sy,screen,howdead);
    if(screen[y+1][nx] == '@')
        {
    	strcpy(howdead,"a falling boulder");  dobeep();
    	return(1);
    	}
    if(screen[y+1][nx] == 'M')
        {
    	dobeep();
    	*mx = *my = -2;
	screen[y+1][nx] = ' ';
    	}
    }
if((screen[nyr][x] != ' ')&&(screen[nyr][x] != 'M'))
    nyr = -1;
if((screen[y][x+1] == '<')&&(nyr>=0)) /* arrow moves ( < ) ? */
    {
    screen[y][x+1] = ' ';
    if(screen[nyr][x] == '@')
        {
    	strcpy(howdead,"a speeding arrow");  dobeep();
    	retval = 1;
    	}
    if(screen[nyr][x] == 'M')
        {
    	dobeep();
    	*mx = *my = -2;
	screen[nyr][x] = ' ';
    	}
    screen[nyr][x] = '<';
#ifndef XWANDER
    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)))
        draw_symbol((x-sx+6)*3,(y-sy+3)*2,' ');
#else
    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)) || tinymode)
        draw_symbol((x-sx+6),(y-sy+3),' ');
#endif
#ifndef XWANDER
    if((nyr<(sy+4)) && (nyr>(sy-4)) && (x<(sx+7)) && (x>(sx-5)))
        draw_symbol((x-sx+5)*3,(nyr-sy+3)*2,'<');
    refresh();
#else
    if((nyr<(sy+4)) && (nyr>(sy-4)) && (x<(sx+7)) && (x>(sx-5))||tinymode)
        draw_symbol((x-sx+5),(nyr-sy+3),'<');
    update_symbols ();
#endif
    retval+=fall(mx,my,x-1,nyr,sx,sy,screen,howdead);
    retval+=fall(mx,my,x+1,y-1,sx,sy,screen,howdead);
    retval+=fall(mx,my,x+1,y+1,sx,sy,screen,howdead);
    retval+=fall(mx,my,x-1,y-1,sx,sy,screen,howdead);
    retval+=fall(mx,my,x-1,y+1,sx,sy,screen,howdead);
    retval+=fall(mx,my,x+1,y  ,sx,sy,screen,howdead);
    if(screen[nyr][x-1] == '@')
        {
    	strcpy(howdead,"a speeding arrow");  dobeep();
    	return(1);
    	}
    if(screen[nyr][x-1] == 'M')
        {
    	dobeep();
    	*mx = *my = -2;
	screen[nyr][x-1] = ' ';
    	}
    }
if((screen[nyl][x] != ' ')&&(screen[nyl][x] != 'M'))
    nyl = -1;
if((screen[y][x-1] == '>')&&(nyl>=0))       /* arrow moves ( > ) ? */
    {
    screen[y][x-1] = ' ';
    if(screen[nyl][x] == '@')
        {
    	strcpy(howdead,"a speeding arrow");  dobeep();
    	retval = 1;
    	}
    if(screen[nyl][x] == 'M')
        {
    	dobeep();
    	*mx = *my = -2;
	screen[nyl][x] = ' ';
    	}
    screen[nyl][x] = '>';
#ifndef XWANDER
    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)))
        draw_symbol((x-sx+4)*3,(y-sy+3)*2,' ');
#else
    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)) || tinymode)
        draw_symbol((x-sx+4),(y-sy+3),' ');
#endif
#ifndef XWANDER
    if((nyl<(sy+4)) && (nyl>(sy-4)) && (x<(sx+5)) && (x>(sx-7)))
        draw_symbol((x-sx+5)*3,(nyl-sy+3)*2,'>');
    refresh();
#else
    if((nyl<(sy+4)) && (nyl>(sy-4)) && (x<(sx+5)) && (x>(sx-7))||tinymode)
        draw_symbol((x-sx+5),(nyl-sy+3),'>');
    update_symbols ();
#endif
    retval+=fall(mx,my,x+1,nyl,sx,sy,screen,howdead);
	retval+=fall(mx,my,x+1,y-1,sx,sy,screen,howdead);
	retval+=fall(mx,my,x+1,y+1,sx,sy,screen,howdead);
	retval+=fall(mx,my,x-1,y-1,sx,sy,screen,howdead);
	retval+=fall(mx,my,x-1,y+1,sx,sy,screen,howdead);
    retval += fall(mx,my,x-1,y,sx,sy,screen,howdead);
    if(screen[nyl][x+1] == '@')
        {
    	strcpy(howdead,"a speeding arrow");  dobeep();
    	return(1);
    	}
    if(screen[nyl][x+1] == 'M')
        {
    	dobeep();
    	*mx = *my = -2;
	screen[nyl][x+1] = ' ';
    	}
    }
if(retval>0)
    return(1);
return(0);
}