Plan 9 from Bell Labs’s /usr/web/sources/contrib/axel/rushhour/src/rushhour.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


enum {
	/* levels */
	Empty		= 0,
	Background,
	Wall,

	/* Own */
	CarX, 
	CarY, 
	CarZ, 

	/* 2-length */
	CarA, 
	CarB, 
	CarC, 
	CarD, 
	CarE, 
	CarF, 
	CarG, 
	CarH, 
	CarI, 
	CarJ, 
	CarK, 
	CarL, 
	CarM, 
	CarN, 

	/* 3-length */
	TruckO,
	TruckP,
	TruckQ,
	TruckR,
	TruckS,
	TruckT,
	TruckU,
	TruckV,

	NElems,
};

enum {
	OHoriz	= 0,
	OVert	= 1,
};


enum {
	MazeX = 20,
	MazeY = 18,
//	BoardX = 48,  //49,
//	BoardY = 48, //49,

	Maxlevels = 200,
	
	Off = 3,		/* offset in board, should be >= max car length */
				/* to have left border  and top border */
				/* to allow car to disappear  to left and to top */
};

int BoardX;
int BoardY;
int SizeX;
int SizeY;

int OutlineWidth;

typedef struct {
	Point 	max;		/* leftmost - bottom-most index; */
					/* for board span subtract Pt(Off,Off) */
	Point 	win;		/* position where we draw win message*/
	uint 	us;			/* the element we need to free to win */
	uint 	index;		/* in list of levels in b2 menu */
	uint	done;
	uint 	board[MazeX][MazeY]; /* offset Off wrt graphics */
	int	orient[NElems];		/* orientation of element */
	int	length[NElems];	/* length of element */
	char	*name;
} Level;

Level level;		/* the current level */
Level levels[Maxlevels];	/* all levels from this file */
int numlevels;		/* how many levels do we have */
int usefaces;		/* use faces in visualization? */
int tinyflag;
int boutflag;

Image *img;		/* buffer */
Image *text;		/* for text messages */
Image *black;		/* for faces border */

Image *win;		/* winning message */
Image *wall;
Image *empty;
Image *bg;
Image *col[NElems];
Image *face[NElems];
Image *car[NElems][2];
Image *msk[NElems][2];

/* graphics.c */
void drawscreen(void);
void drawlevel(void);
void drawwin(Point);
void drawboard(Point, int *, Point);
void resize(Point);
Point boardsize(Point);
int intile(Point, Point);
int inhalftile(Point, Point);
Point subtile(Point, Point);
Point addtile(Point, Point);
Point getdir(Point, Point);

/* level.c */
int loadlevels(char *);

/* move.c */
int item(Point);
void setitem(Point, int);
int isvehicle(int);
Point next(Point);
Point prev(Point);
Point gettopleft(Point);
int canmove(Point, Point);
int onestep(Point, Point, Point*);
Point destof(Point, Point);


/* rushhour.c */
char *genlevels(int);
Image *eallocimage(Rectangle, int, uint);
Image * openimage(char *dir, char *file);
Image * openface(char *path);
char* estrdup(char*);
void* erealloc(void*, ulong);

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.