/* * "RADIATE.H" * * Header for tile based two-player game * * * Author: ScoTT Campbell * Date: 29/9/98 * */ #include "..\escpslib\escpslib.h" #include "button\button.h" /*************************** Display related definitions ****************************/ #define TILE_WIDTH (40) // Tile sizes in pixels #define TILE_HEIGHT (30) #define DISPLAY_WIDTH (13) // Display sizes in tiles #define DISPLAY_HEIGHT (14) // Offsets required to place display in centre of screen #define DISPLAY_X_OFFSET ((SCREEN_WIDTH - (DISPLAY_WIDTH *TILE_WIDTH ))/2) #define DISPLAY_Y_OFFSET ((SCREEN_HEIGHT - (DISPLAY_HEIGHT*TILE_HEIGHT))/2) /************************************************************************************/ /*************************** Map related definitions ********************************/ #define MAP_HEIGHT (11) // Map sizes in tiles #define MAP_WIDTH (11) #define MAP_TOP_Y (DISPLAY_Y_OFFSET + (((DISPLAY_HEIGHT - MAP_HEIGHT)-1) * TILE_HEIGHT)) #define MAP_BOTTOM_Y (MAP_TOP_Y + (MAP_HEIGHT * TILE_HEIGHT)) #define MAP_LEFT_X (DISPLAY_X_OFFSET + (((DISPLAY_WIDTH - MAP_WIDTH)/2) * TILE_WIDTH)) #define MAP_RIGHT_X (MAP_LEFT_X + (MAP_WIDTH * TILE_WIDTH)) #define MAP_HEIGHT_START_INDEX (2) #define MAP_WIDTH_START_INDEX (1) #define MAP_HEIGHT_END_INDEX (MAP_HEIGHT_START_INDEX + MAP_HEIGHT) #define MAP_WIDTH_END_INDEX (MAP_WIDTH_START_INDEX + MAP_WIDTH) #define AMOUNT_TILE_IMAGES (2) #define AMOUNT_STATION_IMAGES (2) // Amount of station images per player #define AMOUNT_BACKGROUND_IMAGES (11) #define MAP_OT_LENGTH (3) #define AMOUNT_MAPS (5) // How many different maps there are #define AMOUNT_BACKGROUNDS (5) // How many different types of tile there are typedef int map_array[DISPLAY_HEIGHT][DISPLAY_WIDTH]; /*==================== MAP CODE ========================*/ /* 0: BLANK */ /* c: players starting tile */ /* g: ground tile */ /* o: object tile */ /* x: left hand station */ /* y: right hand station */ /* s: left pipe start */ /* r: right pipe start */ /* p: pipe body */ /* e: pipe right hand bend */ /* f: pipe left hand bend */ /* t: top border */ /* b: bottom border */ /* l: left border */ /* 1: top right corner border with pipe body */ /* 2: bottom left corner border */ /* 3: bottom right corner border */ /*======================================================*/ /* Classic */ map_array map1 = { {'e','0','0','0','0','0','0','0','0','0','0','0','f'}, {'s','t','t','t','t','t','t','t','t','t','t','t','1'}, {'x','c','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','r'}, {'l','g','g','g','g','g','g','g','g','g','g','c','y'}, {'2','b','b','b','b','b','b','b','b','b','b','b','3'}, }; /* I'm On A Plain */ map_array map2 = { {'e','0','0','0','0','0','0','0','0','0','0','0','f'}, {'s','t','t','t','t','t','t','t','t','t','t','t','1'}, {'x','c','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','r'}, {'l','g','g','g','g','g','g','g','g','g','g','c','y'}, {'2','b','b','b','b','b','b','b','b','b','b','b','3'}, }; /* To Each Their Own */ map_array map3 = { {'e','0','0','0','0','0','0','0','0','0','0','0','f'}, {'s','t','t','t','t','t','t','t','t','t','t','t','1'}, {'x','c','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','p'}, {'l','g','g','g','g','g','o','g','g','g','g','g','r'}, {'l','g','g','g','g','g','o','g','g','g','g','c','y'}, {'2','b','b','b','b','b','b','b','b','b','b','b','3'}, }; /* The Mulberry Bush */ map_array map4 = { {'e','0','0','0','0','0','0','0','0','0','0','0','f'}, {'s','t','t','t','t','t','t','t','t','t','t','t','1'}, {'x','c','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','g','o','o','o','o','o','o','o','g','g','p'}, {'l','g','g','o','o','o','o','o','o','o','g','g','p'}, {'l','g','g','o','o','o','o','o','o','o','g','g','p'}, {'l','g','g','o','o','o','o','o','o','o','g','g','p'}, {'l','g','g','o','o','o','o','o','o','o','g','g','p'}, {'l','g','g','o','o','o','o','o','o','o','g','g','p'}, {'l','g','g','o','o','o','o','o','o','o','g','g','p'}, {'l','g','g','g','g','g','g','g','g','g','g','g','r'}, {'l','g','g','g','g','g','g','g','g','g','g','c','y'}, {'2','b','b','b','b','b','b','b','b','b','b','b','3'}, }; /* SuperMarket */ map_array map5 = { {'e','0','0','0','0','0','0','0','0','0','0','0','f'}, {'s','t','t','t','t','t','t','t','t','t','t','t','1'}, {'x','c','g','g','g','g','g','g','g','g','g','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','p'}, {'l','g','o','g','o','g','o','g','o','g','o','g','r'}, {'l','g','g','g','g','g','g','g','g','g','g','c','y'}, {'2','b','b','b','b','b','b','b','b','b','b','b','3'}, }; void InitMapImages(); /* Sets up the images used for the background and map */ GsOT* CreateMap(map_array map, GsSPRITE* tileArray); /* Create an OT which has all the drawing commands needed for the background */ void DrawMap(GsOT* mapOT); /* Draws the ordering table mapOT's primitives in the current buffer */ int DestroyMap(GsOT* mapOT); /* frees up the memory being used by a maps drawing commands */ /************************************************************************************/ /*************************** Status bar related definitions *************************/ typedef struct{ EsGBOXF left; EsGBOXF right; GsSPRITE cover; int coverPosition; }status_bar; #define BAR_HEIGHT (28) #define COVER_SPRITE_WIDTH (8) #define TOTAL_BAR_WIDTH (MAP_WIDTH * TILE_WIDTH) #define BAR_START_WIDTH ((TOTAL_BAR_WIDTH - COVER_SPRITE_WIDTH)/2) #define BAR_LEFT_START_X (DISPLAY_X_OFFSET + TILE_WIDTH) #define BAR_RIGHT_START_X (BAR_LEFT_START_X + BAR_START_WIDTH + COVER_SPRITE_WIDTH) #define COVER_START_X (BAR_LEFT_START_X + BAR_START_WIDTH) #define BAR_Y (DISPLAY_Y_OFFSET + ((TILE_HEIGHT/2) - (BAR_HEIGHT/2))) #define COVER_Y (BAR_Y) #define BAR_LEFT_END (BAR_LEFT_START_X) #define BAR_RIGHT_END (BAR_LEFT_START_X + TOTAL_BAR_WIDTH - COVER_SPRITE_WIDTH) void InitStatusBar(status_bar* statusBar); /* Initialises a status bar ready for a new game */ int UpdateStatusBar(status_bar* statusBar, int value); /* Changes the centre point in the status bar by the value of the second argument */ /* Returns 1 if the cover sprite is a either end; 0 otherwise */ void ResetStatusBar(status_bar* statusBar); /* Set up a status bar to the values in InitStatusBar */ void DrawStatusBar(status_bar* statusBar, int buffer); /* Places a status bar into buffer's OT */ /************************************************************************************/ /***************************** Tile map related definitions *************************/ typedef struct tile_map{ int x; int y; struct tile_map* next; }tile_map_node; typedef struct{ tile_map_node* front; unsigned int count; }tile_map_header; tile_map_header* CreateTileMap(map_array map, int tile); /* Creates a new tile map which contains pairs of co-ords representing the */ /* top left corner of any tiles with the character constant value tile in */ /* the map_array map */ int DestroyTileMap(tile_map_header* header); /* Destroys an existing tile map and frees up the memory it was using */ /* Returns 1 if there was a problem; 0 otherwise */ /************************************************************************************/ /***************************** Player related definitions****************************/ #define AMOUNT_PLAYER_IMAGES (1) #define PLAYER_SPRITE_WIDTH (30) #define PLAYER_SPRITE_HEIGHT (24) #define PLAYER_SPEED (3); typedef struct{ GsSPRITE playerSprite; int currentX; int currentY; int width; int height; button_list itemList; int powerValue; unsigned int itemValue; char padClearFlag; }player_type; int InitPlayer(player_type* player, unsigned long int address, int xStart, int yStart); /* Sets up the sprites for both players */ /* Puts all the sprites into an array, one for each player */ /* After being called player1 and player2 will point to the start of these arrays */ void ResetPlayer(player_type* player, int xStart, int yStart); /* Set the players position to xStart, yStart and reset all necessary values */ void DrawPlayer(player_type* player, int buffer); /* Create drawing commands for player sprite and insert into buffer's OT */ /************************************************************************************/ /**************************** Collision related definitions *************************/ typedef struct{ int x; // Top left corner co-ordinates int y; int width; int height; }bounding_box; typedef struct{ bounding_box* boxArray; unsigned short int count; }collision_map_header; int CheckTopCollision(player_type* player, int* x, int* y); /* Stop player going off top of map */ int CheckBottomCollision(player_type* player, int* x, int* y); /* Stop player going off bottom of map */ int CheckLeftCollision(player_type* player, int* x, int* y); /* Stop player going off left of map */ int CheckRightCollision(player_type* player, int* x, int* y); /* Stop player going off right of map */ int Collision(int x1, int y1, unsigned int width1, unsigned int height1, int x2, int y2, unsigned int width2, unsigned int height2); /* Returns 1 if player has collided with box; 0 otherwise */ /* Only works when bounding boxes for player and box are same size */ collision_map_header* CreateCollisionMap(tile_map_header* tileMap, int width, int height); /* Creates an array of bounding boxes from map */ /* The size of the array created is put into the memory pointed to by size */ /* Returns a pointer to the array if size>0 and memory is available; NULL otherwise */ int DestroyCollisionMap(collision_map_header* collisionMap); /* Free up the memory being used by a collision_map */ /* Returns 1 if thers a problem; 0 otherwise */ /************************************************************************************/ /****************************** Item related definitions ****************************/ #define AMOUNT_ITEM_IMAGES (4) #define ITEM_WIDTH (20) #define ITEM_HEIGHT (20) typedef struct{ unsigned char active; // Flag. 1 if item exists, 0 otherwise GsSPRITE itemSprite; bounding_box box; button_type itemID; }item_type; typedef struct{ item_type* itemArray; unsigned int count; int activeCount; }item_map_header; GsSPRITE* InitItemImages(unsigned long int address,unsigned int amount); /* Returns a pointer to an array of GsSPRITE, which contains the initialised item sprites */ item_map_header* CreateItemMap(tile_map_header* tileMap); /* Creates an initialised empty array of item_type and returns an item_type_header ptr */ int GetItemMapActiveCount(item_map_header* itemMap); /* Returns the number of items in itemMap that are active */ button_type GetItemFromItemMap(item_map_header* itemMap, unsigned int position); /* Returns the item in itemMap at position */ int DestroyItemMap(item_map_header* itemMap); /* Destroys an item map created by CreateItemMap(). Returns 0 if successful; 1 otherwise */ void AddItemsToItemMap(item_map_header* itemMap, GsSPRITE* spriteArray, unsigned int numberOfItems); /* Adds numberOfItems to itemMap, or fills the map if numberOfItems is greater than the */ /* number of un-used slots */ void DrawItems(item_map_header* itemMap, unsigned char buffer); /* Creates the drawing commands to draw the active items on screen, and places them in */ /* worldOT[buffer] */ /************************************************************************************/ /****************************** Menu related definitions ****************************/ #define MENU_TEXT_HEIGHT (20) // Menu text height in pixels #define AMOUNT_MAIN_MENU_ITEMS (5) #define MAP_MENU_POSITION (1) // Position of the map submenu within the main menu #define BACKGROUND_MENU_POSITION (2) // Position of the background submenu within the main menu void InitMenu(); /* Initialise the text for the menu and set up the menu structure */ void DisplayMenu(menu_type); /* Display the main menu screen including games title */ /************************************************************************************/