Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

Define defective goods. What are rework costs?

Answered: 1 week ago

Question

What does the start( ) method defined by Thread do?

Answered: 1 week ago