Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* 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 mapMAXMAPLOCATIONS;
int itemCount;
Item itemsMAXITEMCOUNT;
Player player;
int GameInitializeGame 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 MAXMAPLOCATIONS, MAXITEMCOUNT, 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 GAMEH
#define GAMEH
#include "Location.h
#include "Player.h
#include "Item.h
#define MAXMAPLOCATIONS
#define MAXITEMCOUNT
#define MAPFILENAME "map.txt
#define ITEMFILENAME "items.txt
typedef struct
int numLocations;
Location mapMAXMAPLOCATIONS;
int itemCount;
Item itemsMAXITEMCOUNT;
Player player;
Game;
int GameInitializeGame 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 GameInitializeGame pGame
pGamenumLocations LocationReadMappGamemap, MAXMAPLOCATIONS, MAPFILENAME;
pGameitemCount ItemReadItemspGameitems, MAXITEMCOUNT, ITEMFILENAME;
The player object is also initialized
PlayerInit&pGameplayer;
put the items on the map
srand clock rand
srandclock;
forfor each item in item.txtitemCount
LocationAddItem
display
printfGAME ITEMS:";
printf;
printfcomb a small hair comb";
printfbrush a large hair brush";
printfbowl a pretty bowl suitable for eating breakfast cereal";
printfsoap a fragrantly smelling bar of soap";
printfvase a beautifully decorated vase";
printfcandlestick a brass candlestick covered with melted wax";
printf;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started