Question: * This is in C programming * Write Game.h and Game.c In Game.h , use typedef to define the Game type which contains the following

*This is in C programming*
Write Game.h and Game.c
In Game.h, use typedef to define the Game type which contains the following information:
Game:
int numLocations;
Location map[MAX_MAP_LOCATIONS];
int itemCount;
Item items[MAX_ITEM_COUNT];
Player player;
int GameInitialize(Game *pGame);
Initializes the game structure and calls the initialize routines for the games map
and the games items. The player object is also initialized.
Any constants that define buffer size limits of the game should be declared in Game.h. For example, the MAX_MAP_LOCATIONS, MAX_ITEM_COUNT, and other similar constants should be in Game.h. The filenames of the map and items should be defined in Game.h. Putting this kind of information in the .h file allows a user to quickly change a system configuration at one location and not have to search through the code.
In Game.c, implement the GameInitialize() function. This will set up the game, calling
routines to load the item list and the map.
____________________________________________________________
This is my .h file so far:
#ifndef GAME_H
#define GAME_H
#include "Location.h"
#include "Player.h"
#include "Item.h"
#define MAX_MAP_LOCATIONS 25
#define MAX_ITEM_COUNT 10
#define MAP_FILENAME "map.txt"
#define ITEM_FILENAME "items.txt"
typedef struct
{
int numLocations;
Location map[MAX_MAP_LOCATIONS];
int itemCount;
Item items[MAX_ITEM_COUNT];
Player player;
}Game;
int GameInitialize(Game *pGame);
#endif
___________________________________________________________________
This is my .c file so far:
#include
#include
#include
#include "Game.h"
/*Initializes the game structure and calls the initialize routines for the games map
and the games items. The player object is also initialized.*/
int GameInitialize(Game *pGame)
{
pGame->numLocations = LocationReadMap(pGame->map, MAX_MAP_LOCATIONS, MAP_FILENAME);
pGame->itemCount = ItemReadItems(pGame->items, MAX_ITEM_COUNT, ITEM_FILENAME);
//The player object is also initialized
PlayerInit(&pGame->player);
//put the items on the map
//srand(), clock(), rand(),%
//srand(clock());
for()//for each item in item.txt(itemCount)
{
LocationAddItem()
}
//display ??
printf("GAME ITEMS:");
printf("-----------------------------");
printf("comb a small hair comb");
printf("brush a large hair brush");
printf("bowl a pretty bowl suitable for eating breakfast cereal");
printf("soap a fragrantly smelling bar of soap");
printf("vase a beautifully decorated vase");
printf("candlestick a brass candlestick covered with melted wax");
printf("-----------------------------");
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!