Bugs (bit-mapped game)

hjespersen at trillium.waterloo.edu hjespersen at trillium.waterloo.edu
Thu Jun 1 04:07:59 AEST 1989


I have long been frustrated by the lack of arcade style games
on the 3B1 (UNIXpc). So, I decided to write one. This is the
first time that I have fooled with the bitmapping capabilities
of the UNIXpc, and I was surprised to see how simple it really
is. I would like to encourage others to write games for this
machine and distribute them freely.

Anyway, 'Bugs' is a Space Invader type game. I tried to preserve
as many of the elements of the original game as possible. Any
differences will be immediately obvious. 

---------------------cut here------------------------------
echo x - Makefile
sed 's/^X//' >Makefile <<'*-*-END-of-Makefile-*-*'
Xbugs: bugs.o sprites.o window.o move.o init.o game.o shot.o
X	cc sprites.o bugs.o window.o move.o init.o game.o shot.o -o bugs -ltam -ltermlib 
X
Xbugs.o: bugs.c bugs.h
X	cc -O -c bugs.c
X
Xsprites.o: sprites.c bugs.h
X	cc -O -c sprites.c 
X
Xwindow.o: window.c bugs.h
X	cc -O -c window.c
X
Xmove.o: move.c bugs.h
X	cc -O -c move.c
X
Xinit.o: init.c bugs.h
X	cc -O -c init.c
X
Xgame.o: game.c bugs.h
X	cc -O -c game.c
X
Xshot.o: shot.c bugs.h
X	cc -O -c shot.c
Xclean:
X	rm sprites.o bugs.o window.o move.o init.o game.o shot.o 
*-*-END-of-Makefile-*-*
echo x - Manifest
sed 's/^X//' >Manifest <<'*-*-END-of-Manifest-*-*'
XMakefile
XManifest
XREADME
Xbugs.h
Xsprites.c
Xbugs.c
Xwindow.c
Xmove.c
Xinit.c
Xgame.c
Xshot.c
*-*-END-of-Manifest-*-*
echo x - README
sed 's/^X//' >README <<'*-*-END-of-README-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X* NOTICE:                                                  *
X*                                                          *
X* This program is in the public domain. You are incouraged *
X* to give it away to as many fellow UNIXpc owners as       *
X* possible. However, neither this program nor parts of it  *
X* can be used for commercial purposes. You are free to use *
X* parts of this program in other public domain software    *
X* provided you give credit where credit is due.            *
X*                                                          *
X\**********************************************************/
X
XI have long been frustrated by the lack of arcade style games
Xon the 3B1 (UNIXpc). So, I decided to write one. This is the
Xfirst time that I have fooled with the bitmapping capabilities
Xof the UNIXpc, and I was surprised to see how simple it really
Xis. I would like to encourage others to write games for this
Xmachine and distribute them freely.
X
XAnyway, 'Bugs' is a Space Invader type game. I tried to preserve
Xas many of the elements of the original game as possible. Any
Xdifferences will be immediately obvious. 
X
XThe controls for the game are as follows :
X
X	'a'	- shoot
X	'j'	- move left
X	'k'	- stop moving
X	'l'	- move right
X	'b'	- toggle beeping
X	's' 	- blow away shelters
X	'q'	- quit
X
XAnyone wishing to change these controls should look at bugs.h
X
XMany other game aspects are modifiable by changing constants
Xthat are defined in bugs.h. I am quite satisfied with the pace
Xof the game, but if you wish to speed things up (at the expense
Xof smoothness in most cases) try bumping up the increament 
Xconstants BUGINC, BASEINC, SHOTINC, etc. (these represent the
Xnumber of pixels to move each iteration). NOTE: moving the mouse
Xpointer off the screen helps speed things up a bit.
X
XAt each successive level you will notice that the bugs start 
Xat a lower position. There are 6 levels. The 7th level starts
Xback where the first level did, however the number of shots
Xincreases making play harder still. The same happens again after
Xthe 12th level. In all there are 18 levels. My hat's off to 
Xanyone who makes it through all 18 (I haven't). After the 18th
Xplay continues forever at the highest difficulty.
X
XPlease let me know what you think of this program. I may add
Xsome new features in the future and perhaps spruce up the 
Xgraphics. I am also starting on another game (asteroids)
Xand I will post it to unix-pc.sources when I am finished.
X
XI can be reached at my University of Waterloo account until
Xthe end of August '89.
X
Xhjespersen\@trillium.waterloo.edu
Xuunet!watmath!trillium!hjespersen
X
Xor at work anytime thereafter
X
Xhjespers\@attcan.uucp
Xuunet!attcan!hjespers 
*-*-END-of-README-*-*
echo x - bugs.c
sed 's/^X//' >bugs.c <<'*-*-END-of-bugs.c-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include "bugs.h"
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X	if( argc != 1 ) {
X		fprintf(stderr,"\nusage: bugs\n");
X		fprintf(stderr,"       There aint no arguments dummy, just type 'bugs'\n");
X		exit(-1);
X	} 
X        defsprites();		/* Define the little critters */
X        wininit();		/* Set up the full screen window */
X	beepflag = 0;
X	score = 0;
X	chance = 41;
X	level = 0;
X	for(men = 2; men >= 0;) {
X	        initscreen( level );		/* Display initial screen */
X		playgame();
X	}
X}
*-*-END-of-bugs.c-*-*
echo x - bugs.h
sed 's/^X//' >bugs.h <<'*-*-END-of-bugs.h-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include <sys/window.h>
X#include <fcntl.h>
X#include <tam.h>
X#include <termio.h>
X#include <stdio.h>
X
X#define SCREEN_WIDTH    720
X#define SCREEN_HEIGHT   300
X
X#define BUG_WIDTH       32
X#define BUG_HEIGHT      24
X#define REAL_BUG_WIDTH  28
X#define BUGSCORE	30
X
X#define BASE_WIDTH      32
X#define BASE_HEIGHT     16
X#define REAL_BASE_WIDTH 28
X#define BASE_LEVEL 	SCREEN_HEIGHT - BASE_HEIGHT
X
X#define SHELTER_WIDTH   48      
X#define SHELTER_HEIGHT  32
X#define SHELTER_LEVEL	236	
X
X#define UFO_WIDTH       32
X#define UFO_HEIGHT      24
X
X#define SHOT_WIDTH      16
X#define SHOT_HEIGHT     16
X#define SHOT_OFFSET     12
X#define REAL_SHOT_WIDTH 4
X#define SHOTSCORE	10
X
X#define BANG_WIDTH      32
X#define BANG_HEIGHT     24
X
X#define MAXBUGS		50
X#define MAXSHOTS	10
X#define MAXSHELTERS	4 
X#define MAXLEVEL	6
X
X#define DROPINC		12
X#define MOVEINC		8
X#define BASEINC		2
X#define SHOTINC		8
X#define UFOINC		2
X
X#define TRUE		1
X#define FALSE		0
X
X#define RIGHT		1
X#define LEFT           -1
X#define STOP		0
X
X#define KILL		's'
X#define SHOOT		'a'
X#define BEEP		'b'
X#define LEFTKEY		'j'
X#define STOPKEY		'k'
X#define RIGHTKEY	'l'
X#define QUIT		'q'
X
X#define UFOCHANCE	3000
X
Xextern unsigned short patwhite[];
Xextern unsigned short patgray[];
Xextern unsigned short patltgray[];
Xextern unsigned short patblack[];
X
Xunsigned short bug[2][BUG_WIDTH * BUG_HEIGHT / 16];
Xunsigned short base[BASE_WIDTH * BASE_HEIGHT / 16];
Xunsigned short shelter[SHELTER_WIDTH * SHELTER_HEIGHT / 16];
Xunsigned short ufo[UFO_WIDTH * UFO_HEIGHT / 16];
Xunsigned short shot[SHOT_WIDTH * SHOT_HEIGHT / 16];
Xunsigned short bang[BANG_WIDTH * BANG_HEIGHT / 16];
X
Xstruct position
X{
X        int x;
X        int y;
X};
X
Xstruct position buglist[MAXBUGS];
Xstruct position shelterlist[MAXSHELTERS];
Xstruct position shotlist[MAXSHOTS];
Xstruct position myshot;
Xstruct position mybase;
Xstruct position ufopos;
X
Xint wn;
Xint nbugs;
Xint nshots;
Xint shotflag;
Xint bugflag;
Xint dropflag;
Xint beepflag;
Xint quitflag;
Xint shelterflag;
Xint ufoflag;
Xint score;
Xint men;
Xint bugnum;
Xint shotnum;
Xint bugdir;
Xint chance;
Xint level;
*-*-END-of-bugs.h-*-*
echo x - game.c
sed 's/^X//' >game.c <<'*-*-END-of-game.c-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include "bugs.h"
X
Xplaygame()
X{
X	char key;
X	int moveflag;
X	
X	moveflag = 0;
X	for(; quitflag != TRUE ;) {
X		key = getch();
X		switch( key ) {
X			case KILL:
X				killshelters();
X				break;
X			case SHOOT:
X				shoot();
X				break;
X			case BEEP:
X				togglebeep();
X				break;
X			case LEFTKEY:
X				moveflag = LEFT;
X				break;
X			case STOPKEY:
X				moveflag = STOP;
X				break;
X			case RIGHTKEY:
X				moveflag = RIGHT;
X				break;
X	       		case QUIT:
X				cleanup();
X		}
X		moveshot();
X		movebug( bugnum );
X		bugshoot( bugnum );
X		movebase( moveflag );
X		moveufo();
X	}
X	if( nbugs >= 0 ) 
X		men--;
X	else {
X		if( level < MAXLEVEL )
X			level++;
X		else {
X			if( chance > 20 )
X				chance -= 20;
X			level = 0;
X		}
X	}
X	sleep( 5 );
X	clear();
X}
X
Xtogglebeep()
X{
X	beepflag = 1 - beepflag;
X}
X
Xshoot() 
X{
X	if( !shotflag ) {
X		myshot.x = mybase.x + SHOT_OFFSET;
X		myshot.y = mybase.y;
X		shotflag = TRUE;
X	}
X}
X
Xkillbug( index )
Xint index;
X{
X	int i;
X
X	wrastop(wn,bang,4,0,0,0,0,buglist[index].x,buglist[index].y,BANG_WIDTH,BANG_HEIGHT,SRCAND,DSTSRC,patblack);
X	if(( index == bugnum ) && ( index == nbugs )) {
X		movebug( index );
X		wrastop(wn,bang,4,0,0,0,0,buglist[index].x,buglist[index].y,BANG_WIDTH,BANG_HEIGHT,SRCAND,DSTSRC,patblack);
X	}
X	else {
X		for( i = index; i < nbugs; i++ ) 
X			buglist[i] = buglist[i + 1];
X	}
X	if( index < bugnum )
X		bugnum--;
X	nbugs--;
X	if( nbugs < 0 ) 
X		quitflag = TRUE;
X	score += BUGSCORE;
X	printscore();
X}
X
Xkillshot( index )
Xint index;
X{
X	int i;
X
X	wrastop(wn,shot,2,0,0,0,0,shotlist[index].x,shotlist[index].y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X	for( i = index; i < nshots; i++ ) 
X		shotlist[i] = shotlist[i + 1];
X	nshots--;
X}
X
Xkillshelters()
X{
X	int i;
X	
X	for( i = 0; i < MAXSHELTERS; i++ ) {	
X		wrastop(wn,shelter,4,0,0,0,0,shelterlist[i].x,shelterlist[i].y,SHELTER_WIDTH,SHELTER_HEIGHT,SRCAND,DSTSRC,patblack);
X		shelterlist[i].x = -100;
X		shelterlist[i].y = -100;
X	}
X}
X
Xint collide( apos, awidth, aheight, bpos, bwidth, bheight )
Xstruct position apos;
Xint awidth;
Xint aheight;
Xstruct position bpos;
Xint bwidth;
Xint bheight;
X{
X	if( (bpos.y >= apos.y - bheight) && (bpos.y <= apos.y + aheight) ){
X		if( (bpos.x >= apos.x - bwidth) && (bpos.x <= apos.x + awidth) )
X			return( TRUE );
X		else
X			return( FALSE );
X	}
X	else
X		return( FALSE );
X}
X
Xprintscore()
X{
X	char scorestr[7];
X	char outstr[20];
X	int digit;
X	int tmpscore;
X	int index;
X	
X	tmpscore = score;
X	strcpy( outstr , "score : ");
X	for( index = 0; index < 5; index++ )
X		scorestr[index] = ' ';
X	scorestr[6] = '\0';
X	for( index = 5; tmpscore > 0; index-- ) {
X		digit = tmpscore % 10;
X		tmpscore = (tmpscore - digit)/10;
X		scorestr[index] = digit + '0';
X	}
X	strcat( outstr, scorestr );
X	wprompt(wn,outstr);
X}
*-*-END-of-game.c-*-*
echo x - init.c
sed 's/^X//' >init.c <<'*-*-END-of-init.c-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include "bugs.h"
X
Xinitscreen( level )
Xint level;
X{
X        int i,j,index;
X	char menstr[15];
X
X        mybase.x = 16;
X        mybase.y = BASE_LEVEL;
X        wrastop(0,base,4,0,0,0,0,mybase.x,mybase.y,BASE_WIDTH,BASE_HEIGHT,SRCAND,DSTSRC,patwhite);
X	if( level < 4 ){
X	        for (i = 0; i < MAXSHELTERS; i++) {
X			shelterlist[i].x = i*154 + 105;
X			shelterlist[i].y = SHELTER_LEVEL;
X       		        wrastop(0,shelter,6,0,0,0,0,shelterlist[i].x,shelterlist[i].y,SHELTER_WIDTH,SHELTER_HEIGHT,SRCAND,DSTSRC,patwhite);
X        	}
X		shelterflag = FALSE;
X	}
X	else 
X		shelterflag = TRUE;
X	index = 0;
X	for (i = 0; i < 10; i++) {
X		for (j = 0; j < 5; j++) {
X			buglist[index].x = i*64 + 32;
X			buglist[index].y = j*36 + level*DROPINC + UFO_HEIGHT; 
X                        wrastop(0,bug[0],4,0,0,0,0,buglist[index].x,buglist[index].y,BUG_WIDTH,BUG_HEIGHT,SRCAND,DSTSRC,patwhite);
X			index++;
X                }
X        }
X	strcpy( menstr, "men   :      " );
X	menstr[13] = men + '0';
X	menstr[14] = '\0';
X	wcmd( wn, menstr );
X	nbugs = MAXBUGS - 1;
X	nshots = -1;
X	dropflag = FALSE;
X	shotflag = FALSE;
X	bugflag = FALSE;
X	ufoflag = FALSE;
X	quitflag = FALSE;
X	bugnum = 0;
X	shotnum = 0;
X	bugdir = RIGHT;
X}
*-*-END-of-init.c-*-*
echo x - move.c
sed 's/^X//' >move.c <<'*-*-END-of-move.c-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include "bugs.h"
X
Xmovebase( direction )  
Xint direction;
X{
X	int i;
X
X	if( direction != STOP ) 
X	        wrastop(wn,base,4,0,0,0,0,mybase.x,mybase.y,BASE_WIDTH,BASE_HEIGHT,SRCAND,DSTSRC,patblack);
X	mybase.x += direction * BASEINC;
X	if ( (mybase.x < 0) || (mybase.x + BASE_WIDTH > SCREEN_WIDTH) )
X	        mybase.x -= direction * BASEINC;
X       	wrastop(wn,base,4,0,0,0,0,mybase.x,mybase.y,BASE_WIDTH,BASE_HEIGHT,SRCAND,DSTSRC,patwhite);
X	for( i = 0; i <= nshots; i++ ) {
X		if( collide( shotlist[i], REAL_SHOT_WIDTH, SHOT_HEIGHT, mybase, REAL_BASE_WIDTH, BASE_HEIGHT ) ) {
X			quitflag = TRUE;
X		}
X	}
X}
X
Xmovebug(index)
Xint index;
X{
X	int newbugflag;
X
X	newbugflag = 1 - bugflag;
X	wrastop(wn,bug[bugflag],4,0,0,0,0,buglist[index].x,buglist[index].y,REAL_BUG_WIDTH,BUG_HEIGHT,SRCAND,DSTSRC,patblack);
X	if( (shelterflag == 0) && (buglist[index].y > SHELTER_LEVEL - BUG_HEIGHT) ) {
X		shelterflag = TRUE;
X		killshelters();
X	}
X	if( dropflag ) 
X		buglist[index].y += DROPINC;
X	else
X		buglist[index].x += MOVEINC * bugdir;
X	if( index <= nbugs )
X		wrastop(wn,bug[newbugflag],4,0,0,0,0,buglist[index].x,buglist[index].y,REAL_BUG_WIDTH,BUG_HEIGHT,SRCAND,DSTSRC,patwhite);
X	if( buglist[index].y >= BASE_LEVEL - BUG_HEIGHT ) {
X		quitflag = TRUE;
X	}
X	if( index >= nbugs ) {
X		bugflag = newbugflag;
X		if( dropflag ) {
X			dropflag = FALSE;
X			bugdir *= LEFT;
X		}
X		else if( (bugdir == RIGHT ) && (buglist[nbugs].x > SCREEN_WIDTH - BUG_WIDTH - MOVEINC) )
X			dropflag = TRUE;
X		else if( (bugdir == LEFT) && (buglist[0].x < MOVEINC) )
X			dropflag = TRUE;
X		bugnum = 0;
X	}
X	else
X		bugnum = index + 1;
X}
X
Xmoveshot()
X{
X	if( shotflag )
X		movemyshot();
X	if( nshots >= 0 )
X		movebugshot( shotnum );
X}
X
Xmoveufo()
X{
X	int xpos;
X	int ufoscore;
X
X	if( ufoflag ) {
X		wrastop(wn,ufo,4,0,0,0,0,ufopos.x,ufopos.y,UFO_WIDTH,UFO_HEIGHT,SRCAND,DSTSRC,patblack);
X		ufopos.x -= UFOINC;
X		if( ufopos.x < 0 )  
X			ufoflag = FALSE;
X		else if( collide( myshot, REAL_SHOT_WIDTH, SHOT_HEIGHT, ufopos, UFO_WIDTH, UFO_HEIGHT ) ) { 
X			wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X			if( beepflag ) beep();
X			ufoscore = ((rand() % 4) + 1) * 100;
X			score += ufoscore;
X			xpos = (ufopos.x - (ufopos.x % 9)) / 9;
X			wgoto( wn, 0, xpos );	
X			wprintf( wn, "%d", ufoscore );
X			printscore();
X			ufoflag = FALSE;
X			shotflag = FALSE;
X		}
X		else
X			wrastop(wn,ufo,4,0,0,0,0,ufopos.x,ufopos.y,UFO_WIDTH,UFO_HEIGHT,SRCAND,DSTSRC,patwhite);
X	}
X	else {
X		if( rand() % UFOCHANCE == 0 ) {
X			ufoflag = TRUE;
X			ufopos.x = SCREEN_WIDTH;
X			ufopos.y = 0;
X		}
X	}
X}
*-*-END-of-move.c-*-*
echo x - shot.c
sed 's/^X//' >shot.c <<'*-*-END-of-shot.c-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include "bugs.h"
X
Xmovemyshot()
X{
X	int index;
X
X	wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X	if( myshot.y < SHOTINC ) { 
X		shotflag = 0;
X		myshot.y = BASE_LEVEL;
X	}
X	else {
X		myshot.y -= SHOTINC;
X		wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patwhite);
X	}
X	for( index = 0; index <= nbugs; index++ ){
X		if( collide( myshot, REAL_SHOT_WIDTH, SHOT_HEIGHT, buglist[index], REAL_BUG_WIDTH, BUG_HEIGHT ) ){
X			wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X			shotflag = 0;
X			if( beepflag ) beep();
X			killbug( index );
X		}
X	}
X	for( index = 0; index <= nshots; index++ ){
X		if( collide( myshot, REAL_SHOT_WIDTH, SHOT_HEIGHT, shotlist[index], REAL_SHOT_WIDTH, SHOT_HEIGHT ) ){
X			wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X			shotflag = 0;
X			if( beepflag ) beep();
X			killshot( index );
X			score += SHOTSCORE;
X			printscore();
X		}
X	}
X	for( index = 0; index < MAXSHELTERS; index++ ){
X		if( collide( myshot, REAL_SHOT_WIDTH, SHOT_HEIGHT, shelterlist[index], SHELTER_WIDTH, SHELTER_HEIGHT ) ){
X			wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X			shotflag = 0;
X			if( beepflag ) beep();
X		}
X	}
X}
X
Xmovebugshot( index )
Xint index;
X{
X	int i;
X
X	if( index <= nshots ) {
X		if( shotlist[index].y <= BASE_LEVEL ) {
X			wrastop(wn,shot,2,0,0,0,0,shotlist[index].x,shotlist[index].y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X			shotlist[index].y += SHOTINC;
X			wrastop(wn,shot,2,0,0,0,0,shotlist[index].x,shotlist[index].y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patwhite);
X			if( collide( shotlist[index], REAL_SHOT_WIDTH, SHOT_HEIGHT, mybase, REAL_BASE_WIDTH, BASE_HEIGHT ) ) 
X				quitflag = 1;
X			for( i = 0; i < MAXSHELTERS; i++ ){
X				if( collide( shotlist[index], REAL_SHOT_WIDTH, SHOT_HEIGHT, shelterlist[i], SHELTER_WIDTH, SHELTER_HEIGHT ) ){
X					wrastop(wn,shot,2,0,0,0,0,shotlist[index].x,shotlist[index].y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack);
X					killshot( index );
X				}
X			}
X		}
X		else {
X			killshot( index );
X		}
X	}
X	if( ++shotnum >= MAXSHOTS )
X		shotnum = 0;
X}
X
Xbugshoot( index )
Xint index;
X{
X	if( nshots < MAXSHOTS - 1 ) {
X		if( rand() % chance == 0 ) {
X			nshots++;
X			shotlist[nshots].x = buglist[index].x + BUG_WIDTH / 2;
X			shotlist[nshots].y = buglist[index].y + BUG_HEIGHT;
X		}
X	}
X}
*-*-END-of-shot.c-*-*
echo x - sprites.c
sed 's/^X//' >sprites.c <<'*-*-END-of-sprites.c-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include "bugs.h"
X
Xdefsprites()
X{
X        /* define bugs */
X
X        bug[0][0] = bug[0][2] = bug[0][4] = bug[0][6] = 0x000f;
X        bug[0][1] = bug[0][3] = bug[0][5] = bug[0][7] = 0x0f00;
X        bug[0][8] = bug[0][10] = bug[0][12] = bug[0][14] = 0x00f0;
X        bug[0][9] = bug[0][11] = bug[0][13] = bug[0][15] = 0x00f0;
X        bug[0][16] = bug[0][18] = bug[0][20] = bug[0][22] = 0xff00;
X        bug[0][17] = bug[0][19] = bug[0][21] = bug[0][23] = 0x000f;
X        bug[0][24] = bug[0][26] = bug[0][28] = bug[0][30] = 0xf0f0;
X        bug[0][25] = bug[0][27] = bug[0][29] = bug[0][31] = 0x00f0;
X        bug[0][32] = bug[0][34] = bug[0][36] = bug[0][38] = 0xfff0;
X        bug[0][33] = bug[0][35] = bug[0][37] = bug[0][39] = 0x00ff;
X        bug[0][40] = bug[0][42] = bug[0][44] = bug[0][46] = 0x000f;
X        bug[0][41] = bug[0][43] = bug[0][45] = bug[0][47] = 0x0f00;
X
X        /* define more bugs */
X
X        bug[1][0] = bug[1][2] = bug[1][4] = bug[1][6] = 0x0000;
X        bug[1][1] = bug[1][3] = bug[1][5] = bug[1][7] = 0x0000;
X        bug[1][8] = bug[1][10] = bug[1][12] = bug[1][14] = 0x00ff;
X        bug[1][9] = bug[1][11] = bug[1][13] = bug[1][15] = 0x0ff0;
X        bug[1][16] = bug[1][18] = bug[1][20] = bug[1][22] = 0xff00;
X        bug[1][17] = bug[1][19] = bug[1][21] = bug[1][23] = 0x000f;
X        bug[1][24] = bug[1][26] = bug[1][28] = bug[1][30] = 0xf0f0;
X        bug[1][25] = bug[1][27] = bug[1][29] = bug[1][31] = 0x00f0;
X        bug[1][32] = bug[1][34] = bug[1][36] = bug[1][38] = 0xfff0;
X        bug[1][33] = bug[1][35] = bug[1][37] = bug[1][39] = 0x00ff;
X        bug[1][40] = bug[1][42] = bug[1][44] = bug[1][46] = 0x00f0;
X        bug[1][41] = bug[1][43] = bug[1][45] = bug[1][47] = 0x00f0;
X
X        /* define base */
X
X        base[0] = base[2] = base[4] = base[6] = 0xf000;
X        base[1] = base[3] = base[5] = base[7] = 0x0000;
X        base[8] = base[10] = base[12] = base[14] = 0xfff0;
X        base[9] = base[11] = base[13] = base[15] = 0x00ff;
X        base[16] = base[18] = base[20] = base[22] = 0xffff;
X        base[17] = base[19] = base[21] = base[23] = 0x0fff;
X        base[24] = base[26] = base[28] = base[30] = 0xffff;
X        base[25] = base[27] = base[29] = base[31] = 0x0fff;
X
X        /* define shelter */
X        
X        shelter[0] = shelter[3] = shelter[6] = shelter[9] = 0xff00;
X        shelter[1] = shelter[4] = shelter[7] = shelter[10] = 0xffff;
X        shelter[2] = shelter[5] = shelter[8] = shelter[11] = 0x00ff;
X        shelter[12] = shelter[15] = shelter[18] = shelter[21] = 0xfff0;
X        shelter[13] = shelter[16] = shelter[19] = shelter[22] = 0xffff;
X        shelter[14] = shelter[17] = shelter[20] = shelter[23] = 0x0fff;
X        shelter[24] = shelter[27] = shelter[30] = shelter[33] = 0xffff;
X        shelter[25] = shelter[28] = shelter[31] = shelter[34] = 0xffff;
X        shelter[26] = shelter[29] = shelter[32] = shelter[35] = 0xffff;
X        shelter[36] = shelter[39] = shelter[42] = shelter[45] = 0xffff;
X        shelter[37] = shelter[40] = shelter[43] = shelter[46] = 0xffff;
X        shelter[38] = shelter[41] = shelter[44] = shelter[47] = 0xffff;
X        shelter[48] = shelter[51] = shelter[54] = shelter[57] = 0xffff;
X        shelter[49] = shelter[52] = shelter[55] = shelter[58] = 0xffff;
X        shelter[50] = shelter[53] = shelter[56] = shelter[59] = 0xffff;
X        shelter[60] = shelter[63] = shelter[66] = shelter[69] = 0xffff;
X        shelter[61] = shelter[64] = shelter[67] = shelter[70] = 0xffff;
X        shelter[62] = shelter[65] = shelter[68] = shelter[71] = 0xffff;
X        shelter[72] = shelter[75] = shelter[78] = shelter[81] = 0x00ff;
X        shelter[73] = shelter[76] = shelter[79] = shelter[82] = 0x0000;
X        shelter[74] = shelter[77] = shelter[80] = shelter[83] = 0xff00;
X        shelter[84] = shelter[87] = shelter[90] = shelter[93] = 0x00ff;
X        shelter[85] = shelter[88] = shelter[91] = shelter[94] = 0x0000;
X        shelter[86] = shelter[89] = shelter[92] = shelter[95] = 0xff00;
X
X        /* define UFO */
X
X        ufo[0] = ufo[2] = ufo[4] = ufo[6] = 0xfff0;
X        ufo[1] = ufo[3] = ufo[5] = ufo[7] = 0x00ff;
X        ufo[8] = ufo[10] = ufo[12] = ufo[14] = 0xffff;
X        ufo[9] = ufo[11] = ufo[13] = ufo[15] = 0x0fff;
X        ufo[16] = ufo[18] = ufo[20] = ufo[22] = 0x0f0f;
X        ufo[17] = ufo[19] = ufo[21] = ufo[23] = 0x0f0f;
X        ufo[24] = ufo[26] = ufo[28] = ufo[30] = 0xffff;
X	ufo[25] = ufo[27] = ufo[29] = ufo[31] = 0x0fff;
X	ufo[32] = ufo[34] = ufo[36] = ufo[38] = 0xfff0;
X	ufo[33] = ufo[35] = ufo[37] = ufo[39] = 0x00ff;
X	ufo[40] = ufo[42] = ufo[44] = ufo[46] = 0x0000;
X	ufo[41] = ufo[43] = ufo[45] = ufo[47] = 0x0000;
X	
X	/* define shot */
X
X	shot[1] = shot[2] = shot[3] = shot[4] = 0x000f;
X	shot[5] = shot[6] = shot[7] = shot[8] = 0x000f;
X	shot[9] = shot[10] = shot[11] = shot[12] = 0x000f;
X	shot[13] = shot[14] = shot[15] = shot[0] = 0x000f;
X
X	/* define explosion */
X
X	bang[0] = bang[2] = bang[4] = bang[6] = 0xffff;
X	bang[1] = bang[3] = bang[5] = bang[7] = 0xffff;
X	bang[8] = bang[10] = bang[12] = bang[14] = 0xffff;
X	bang[9] = bang[11] = bang[13] = bang[15] = 0xffff;
X	bang[16] = bang[18] = bang[20] = bang[22] = 0xffff;
X	bang[17] = bang[19] = bang[21] = bang[23] = 0xffff;
X	bang[24] = bang[26] = bang[28] = bang[30] = 0xffff;
X	bang[25] = bang[27] = bang[29] = bang[31] = 0xffff;
X	bang[32] = bang[34] = bang[36] = bang[38] = 0xffff;
X	bang[33] = bang[35] = bang[37] = bang[39] = 0xffff;
X	bang[40] = bang[42] = bang[44] = bang[46] = 0xffff;
X	bang[41] = bang[43] = bang[45] = bang[47] = 0xffff;
X}
*-*-END-of-sprites.c-*-*
echo x - window.c
sed 's/^X//' >window.c <<'*-*-END-of-window.c-*-*'
X/**********************************************************\
X* Bugs : a bit-mapped arcade game for the AT&T UNIX PC.    *
X*                                                          *
X* By : Hans Jespersen                                      *
X*                                                          *
X* Copyright 1989, Hans Jespersen                           *
X*                                                          *
X\**********************************************************/
X
X#include "bugs.h"
X
Xvoid wininit()
X{
X	int wid;
X
X	close( 0 );
X	close( 1 );
X	close( 2 );
X	wid = open( "/dev/window",O_RDWR );
X	dup( 0 );
X	dup( 0 );
X        winit();
X        if( !iswind() ) {
X                fprintf(stderr,"\nSorry, you must use bit-mapped display!\n");
X                wexit(-1);
X        }
X        wn = wcreate( 0, 0, 25, 80, NBORDER );
X	wuser( wn, "Bugs" );
X	wprompt( wn, "score :      0" );
X	wprintf( wn, "\033[=1C" );
X	nodelay( 0,1 );
X	noecho();
X        clear();
X}
X 
Xvoid cleanup()
X{
X        clear();
X	wprintf( wn, "\033[=0C" );
X        wdelete( wn );		/* Quick, the boss is comming */
X        wexit( 0 );
X}
*-*-END-of-window.c-*-*
exit
-- 
Hans Jespersen
hjespersen at trillium.waterloo.edu
uunet!watmath!trillium!hjespersen



More information about the Unix-pc.sources mailing list