can anyone please help me with my program, my hand in date is on monday so i really need some help thank you

Recommended Answers

All 5 Replies

Where is your project??? what is it suppose to do? where is the code U have done, what is it that u need help with.... you know that kinda thing

Anyone have a crystle ball I can borrow? I lost mine somewhere.

Also, that seems to be a C program, not c++.

SPECIFICATIONS
The game is a board game in which the player controls a (single) little character, known as the "mouse", which can move and collect "apples". The grid which is displayed on the screen shows a (static) maze made of walls, tunnels and food storage places. The mouse and a few apples also appear in the tunnels.
The player can move the mouse in the free parts of the maze, one step (up, down, left or right) at a time, using a specific set of keyboard keys.
The mouse can push one apple along the tunnels towards one of the free storage places, but it can only do this in a straight line (i.e., it must be behind the apple and move it forward) and if the path on the other side of the apple is free (e.g., it cannot push two apples at the same time).
The aim of the game is for the mouse to collect all the apples as efficiently as possible. The final score of a game corresponds to the number of moves the mouse made to put all the apples into the storage places. Clearly the best score is the lowest. As the game progresses the current score and the number of apples already collected by the mouse are updated and displayed.
The game ends, and an appropriate message is displayed, when the player chooses to quit (i.e., press the 'Q' key) or when the game is over (i.e., all apples have been collected).

More advanced versions of the game offer additional features such as several game levels of increasing complexity, identification of the player(s), a two-player game option, a save option and a more friendly display. Such features are described below.

VERSIONS/REQUIREMENTS
Basic version
The basic version should include the following features:
1a. Mouse & Apples Game
The players can play the game with the basic configuration of the maze in which a mouse can move and push apples, one at a time, until the 6 apples are placed in the store. It shows the number of moves made and number of apples in store at any time.
This includes:
• creating the maze, positioning the mouse and 6 apples on the grid according to the first configuration shown in Appendix 1 on p 7
• allowing the player to control the mouse's movements on the maze using the arrow keys
• allowing the apples to be pushed by the mouse when the rules allow this
• ensuring that the mouse moves safely in the maze (i.e., stays within the grid's boundaries, and remains stuck in the same position if the player tries to move it onto a wall or an apple that cannot move)
• indicating at any time the number of apples that are currently in store
• indicating at any time the number of moves that the mouse has already made
• detecting when the game ends (i.e., all the apples have been collected or the player enters the ‘Q’ key)
• terminating the program and displaying an appropriate message (e.g., "PLAYER WANTS TO QUIT." or "GAME IS OVER!").
1b. Player Identification
When the game starts the player enters his/her name. This information is used to create a friendlier display. (In more advanced versions it will also be used to keep a record of the player’s performance and access any previously saved games for that player).
This includes:
• asking the player for its name (a single word) when the program starts
• displaying that name on the screen while the game is being played
• storing the best score of the player into a file (using the player's name with extension .txt) at the end of a game
• displaying the player's best score so far (or 500 if no previous score has been recorded) on the screen while the game is being played.
1c. Cheat
At any point in the program the player can cheat and move the game along to a point when the game can be won in one move. This is useful for testing purpose.
This includes:
• detecting that the 'C' key has been pressed
• beeping the alarm 3 times
• moving 5 apples in the store area, updating the number of apples in store accordingly and leaving the last one ready to be pushed in a free storage place.
• placing the mouse in a position where it is ready to push the last apple in the store.
• setting the number of moves to 1000 and updating the player's score accordingly,
• displaying a message indicating that the cheat key was used (e.g., "PLAYER CHEATED!").

Additional features
The following features are all independent and can be attempted in any order. If more than one feature is implemented they should work together.
2a. Cheese Bonuses
There are 6 bits of cheese scattered at random in the maze. The apples can be pushed over them and they get "eaten" by the mouse when it goes over them and they must all be eaten before a game can end.
This feature should include:
• positioning the bits of cheese at random in free cells of the maze (they should all be visible when the game starts)
• showing the mouse or the apple when they are passing over (and so covering) a bit of cheese
• not displaying the bits of cheese that have been eaten
• ensuring that all the bits of cheese have been eaten before a game can be won.
2b. Game Levels
The game has several levels that offer the player an increasing challenge. The maze configuration becomes more complex and there are more apples to be collected.
The player can choose any entry level when starting the game. When the player succeeds in collecting all the apples in one level, the game automatically offers the next level configuration.
This feature should include:
• offering at least two levels corresponding to the game configurations shown in Appendix 1 (p 7) (for further levels, add any other interesting combinations you can think of)
• storing the game configurations in text files (level1.maz , level2.maz, etc.) and reading this information in the program when appropriate
• displaying the game levels available when the program starts and allowing the user to select one
• displaying the current game level on the screen at any time
• displaying an appropriate message at the end of a level (e.g., "Level 2 completed" when all apples have been collected at that level or “Game Over” if there is no further level available)
• detecting when a level is over and allowing the player to get to the next level game configuration (new maze and number of apples)
• ensuring that the player can see the state of a grid and the messages that have been displayed (e.g., wait for a key press before closing the game or moving to the next level)
2c. Best Scores Record
The best player’s performances are recorded and displayed when the player presses ‘B’.
This feature should include:
• keeping track of the six best players’ name and score, which should be set initially to anonymous1, anonymous2, ..., anonymous6 with a score of 500 each
• recording this information in a text file bestScores.txt so that it can be used in each session
• offering an option for the player to see the names and scores of these "best" players (displayed in descending order).
If you program offers levels you may wish to store the best performances per level too (maybe using different text files).
2d. A (simple) Save Option
The player should be able to save a game session, keep a record of the current state of the game and reload it later when he/she runs the program again. A player can only save one game (i.e., each time a player saves a game any previously saved data for that player is lost).
This feature should include:
• storing all necessary data in a file (named after the player with .sav extension) when the player presses ‘S’
• checking when the program starts whether some "saved" data is available for the player and, if it is, offering him/her the choice to reload the last saved image or start a new game.

2e. A Two-Player Game Option
When the game starts the player is offered a two-player option. Two mice can move in the same maze at the same time and compete for the apples.
This feature should include:
• offering special maze configuration(s) with two separate storage areas for each of the mice (the second configuration in Appendix 1 can be adapted for that purpose)
• allocating another four keys on the keyboard for the control of the second mouse
• using different symbols (or colours) for each mouse and each storage area
• displaying a message associating a player's name to a mouse, set of keys and storage area
• controlling that each player moves his/her allocated mouse in turn (i.e., one valid move per player on each turn)
2f. An Undo Option
At any time the player can undo the single last move. This should be done without saving any information into a file.
This feature should include:
• detecting that the 'U' key has been pressed.
• displaying a message indicating that the undo key has been used.
• resetting all other aspects of the game exactly as they were before the last move so that the game can carry on as normal.
2g. Graphical User Interface (GUI)
A fully-fledged Graphical User-Interface to the system would certainly be an interesting development of the console application developed. The design of the graphics is left up to you. The code should be well structured and documented.
Even without writing a pure GUI application, you can gain some marks in this section for appropriately handling colour, flashing, sound, etc.
VIEWS OF GAME ON CONSOLE
The grid is represented on the screen by a playable area (in which the mouse can move and push the apples).
Distinct characters are used to represent each of the elements in the game, e.g., the tunnels are left blank (‘ ‘), the mouse could be represented with the symbol '@', an apple with the letter 'O', the walls of the maze with ‘#’, the storage areas with'+' and the cheese with '*'. You can choose to use other symbols (colours or icons) providing that their meaning is clearly indicated on the screen.

here is the code i have done:

//---------------------------------------------------------------------------
//Program: Skeleton for Ass 2

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
//----- include libraries
//---------------------------------------------------------------------------

//include standard libraries
#include <iostream>		//for output and input: getch(), cout <<, cin >>
#include <conio.h>		//for kbhit
#include <iomanip> 		//for formatted output
#include <string>		//for string
using namespace std;

//include our own libraries
#include "RandomUtils.h"	//for Seed, Random,
#include "ConsoleUtils.h"	//for Clrscr, Gotoxy, etc.

//---------------------------------------------------------------------------
//----- define constants
//---------------------------------------------------------------------------

//defining the size of the grid
#define SIZEY   (6)		//vertical dimension
#define SIZEX   (10)     	//horizontal dimension
//defining symbols used for display of the grid & content
#define MOUSE   ('@')    	//mouse
#define TUNNEL  (' ')    	//tunnel
#define WALL    ('#')    	//border
//defining the command letters to move the mouse on the maze
#define UP      (72)	//up arrow
#define DOWN    (80) 	//down arrow
#define RIGHT   (77)	//right arrow
#define LEFT    (75) 	//left arrow
//defining the other command letters
#define QUIT    ('Q')	 //to end the game

//---------------------------------------------------------------------------
//----- run game
//---------------------------------------------------------------------------

int main()
{
	//function declarations (prototypes)
	void initialiseGame( char g[][ SIZEX+1], char m[][ SIZEX+1], int mouse[]);
	void paintGame( const char g[][ SIZEX+1], string& mess);
	bool isArrowKey( int k);
	void setKeyDirection( int k, int& dx, int& dy);
	int  getKeyPress();
	void moveMouse( const char g[][ SIZEX+1], int m[], int dx, int dy, string& mess);
	void updateGrid( char g[][ SIZEX+1], const char m[][ SIZEX+1], int mouse[]);
	void endProgram();

	//local variable declarations 	//arrays that store ...
	char grid[ SIZEY+1][ SIZEX+1];	//grid for display
	char maze[ SIZEY+1][ SIZEX+1];	//structure of the maze
	int  mouse[2];		//mouse's position ([y-coordinate][x-coordinate])
	string message = "LET'S START...";	//current message to player
	int key;				//arrow or letter command


 
	//action...
	Clrscr();
	Seed();				//seed the random number generator
	initialiseGame( grid, maze, mouse);	//initialise grid (incl. walls & mouse)
	paintGame( grid, message);	//display game info, modified grid & messages
	key = getKeyPress(); 	//display menu & read in selected option
	while (key != QUIT)	//while user does not want to quit
	{
		if ( isArrowKey( key))
		{
			int dx( 0), dy( 0);
			setKeyDirection( key, dx, dy); 	//find direction indicated by key
			moveMouse( grid, mouse, dx, dy, message);	//move mouse in that direction
			updateGrid( grid, maze, mouse);	//update grid information
		}
		else
			message = "INVALID KEY!";	//set 'Invalid key' message
		paintGame( grid, message);	//display game info, modified grid & messages
		key = getKeyPress(); 	//display menu & read in next option
	}
	endProgram();		//display final message
	return 0;
} //end main


//---------------------------------------------------------------------------
//----- initialise game state
//---------------------------------------------------------------------------

void initialiseGame( char grid[][ SIZEX+1], char maze[][ SIZEX+1], int mouse[])
{ //initialise grid & place mouse in middle
	void setInitialMazeStructure( char g[][ SIZEX+1]);
	void setInitialMouseCoordinates( int mouse[]);
	void updateGrid( char g[][ SIZEX+1], const char m[][ SIZEX+1], int mouse[]);

	setInitialMazeStructure( maze);	//initialise maze
	setInitialMouseCoordinates( mouse);	//initialise mouse's position
	updateGrid( grid, maze, mouse); 	//prepare grid
} //end of initialiseGrid

void setInitialMazeStructure( char maze[][ SIZEX+1])
{ //set the position of the walls in the maze
	//initialise maze configuration
	char initialMaze[ SIZEY+1][ SIZEX+1] 	//local array to store the maze structure
	  = { {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'},
	      {'X', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'},
	      {'X', '#', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
	      {'X', '#', ' ', ' ', '#', ' ', ' ', '#', ' ', ' ', '#'},
	      {'X', '#', ' ', ' ', '#', '#', ' ', '#', ' ', '#', '#'},
	      {'X', '#', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'},
	      {'X', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'} };
	// with '#' for wall, ' ' for tunnel and 'X' for unused part of array
	//copy into maze structure
	for ( int row( 1); row <= SIZEY; ++row)	//for each row (vertically)
		for ( int col( 1); col <= SIZEX; ++col)	//for each column (horizontally)
			maze[row][col] = initialMaze[row][col];
} //end of setMazeStructure

void setInitialMouseCoordinates( int mouse[])
{ //calculate mouse's coordinates at beginning of game
	mouse[0] = 3;  		//y-coordinate: vertically
	mouse [1] = 5; 		//x-coordinate: horizontally
} //end of setInitialMouseCoordinates


//---------------------------------------------------------------------------
//----- update grid state
//---------------------------------------------------------------------------

void updateGrid( char grid[][ SIZEX+1], const char maze[][ SIZEX+1], int mouse[])
{ //update grid configuration after each move
	void setMaze( char g[][ SIZEX+1], const char m[][ SIZEX+1]);
	void placeMouse( char g[][ SIZEX+1], int mouse[]);

	setMaze( grid, maze);	//reset the empty maze configuration into grid
	placeMouse( grid, mouse);	//set mouse in grid
} //end of updateGrid

 

void setMaze( char grid[][ SIZEX+1], const char maze[][ SIZEX+1])
{ //reset the empty/fixed maze configuration into grid
	for ( int row( 1); row <= SIZEY; ++row)	//for each row (vertically)
		for ( int col( 1); col <= SIZEX; ++col)	//for each column (horizontally)
			grid[row][col] = maze[row][col];
} //end of setFrame

void placeMouse( char g[][ SIZEX+1], int m[])
{ //place mouse at its new position in grid
	g[m[0]][m[1]] = MOUSE;
} //end of placeMouse


//---------------------------------------------------------------------------
//----- move the mouse
//---------------------------------------------------------------------------

void moveMouse( const char g[][ SIZEX+1], int m[], int dx, int dy, string& mess)
{ //move mouse in required direction
	//check new target position in grid & update mouse coordinates if move is possible
	switch( g[m[0]+dy][m[1]+dx])
	{			//...depending on what's on the target position in grid...
		case TUNNEL:	//can move
			m[0] += dy;	//go in that Y direction
			m[1] += dx;	//go in that X direction
			break;
		case WALL:  	//hit a wall & stay there
			cout << '\a';	//beep the alarm
			mess = "CANNOT GO THERE!";
			break;
	}
} //end of moveMouse

//---------------------------------------------------------------------------
//----- process key
//---------------------------------------------------------------------------

void setKeyDirection( int key, int& dx, int& dy)
{ //
	switch( key)		//...depending on the selected key...
	{
		case LEFT:  	//when LEFT arrow pressed...
			dx = -1;	//decrease the X coordinate
			dy = 0;
			break;
		case RIGHT: 	//when RIGHT arrow pressed...
			dx = +1;	//increase the X coordinate
			dy = 0;
			break;
		case UP: 		//when UP arrow pressed...
			dx = 0;
			dy = -1;	//decrease the Y coordinate
			break;
		case DOWN: 	//when DOWN arrow pressed...
			dx = 0;
			dy = +1;	//increase the Y coordinate
			break;
	}
} //end of setKeyDirection

int getKeyPress()
{ //get key or command selected by user
	int keyPressed( getch();	//read in the selected arrow key or command letter
	while ( keyPressed == 224) 	//ignore symbol following cursor key
		keyPressed = getch();
	keyPressed = toupper( keyPressed); 	//put it in uppercase
	return( keyPressed);
} //end of getKeyPress

bool isArrowKey( int key)
{	//check if the key pressed is an arrow key (also accept 'K', 'M', 'H' and 'P')
	return ((key == LEFT) || (key == RIGHT) || (key == UP) || ( key == DOWN));
}

 
//---------------------------------------------------------------------------
//----- display info on screen
//---------------------------------------------------------------------------
void paintGame( const char gd[][ SIZEX+1], string& mess)
{ //display game title, messages, maze, mouse & apples on screen
	void paintGrid( const char g[][ SIZEX+1]);

	Clrscr();

	//display game title
	SelectTextColour( clYellow);
	Gotoxy(0, 0);
	cout << "___MOUSE AND APPLES GAME___\n" << endl;
	SelectBackColour( clWhite);
	SelectTextColour( clRed);
	Gotoxy(40, 0);
	cout << "Pascale Vacher: February 08";

	// display grid contents
	paintGrid( gd);

	//display menu options available
	SelectBackColour( clRed);
	SelectTextColour( clYellow);
	Gotoxy(40, 3);
	cout << "TO MOVE USE KEYBOARD ARROWS ";
	Gotoxy(40, 4);
	cout << "TO QUIT ENTER 'Q'           ";

	//print auxiliary messages if any
	SelectBackColour( clBlack);
	SelectTextColour( clWhite);
	Gotoxy(40, 8);
	cout << mess;	//display current message
	mess = "";		//reset message to blank
} //end of paintGame

void paintGrid( const char g[][ SIZEX+1])
{ //display grid content on screen
	SelectBackColour( clBlack);
	SelectTextColour( clWhite);
	Gotoxy(0, 2);
	for ( int row( 1); row <= SIZEY; ++row)	//for each row (vertically)
	{
		for ( int col( 1); col <= SIZEX; ++col)	//for each column (horizontally)
		{
			cout << g[row][col];	//output cell content
		} //end of col-loop
		cout << '\n';
	} //end of row-loop
} //end of paintGrid


void endProgram()
{
	SelectBackColour( clRed);
	SelectTextColour( clYellow);
	Gotoxy(40, 8);
	//hold output screen until a keyboard key is hit
	cout << "PRESS ANY KEY TO END PROGRAM!";
	while (!_kbhit())  /* do nothing */;
}

please help!

>>please help!
Help do what? Write the rest of your assignment for you? The answer to that is a big NO.

We would need RandomUtils.h and ConsoleUtils.h too if someone wants to compile your code. But since this assignment is due TODAY I doubt you will get help quickly enough to do you any good.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.