#include <iostream>
#include <windows.h>
#include <string.h>
usingnamespace std;
bool gameRunning = true;
char Player = 'P'; // These are to be char statements, not int's
char Dragon = 'D';
char map[28];
int main()
{
int display;
char move;
map[0] = Player;
map[27] = Dragon;
cout << map[0];// Next 7 lines, print out the map array
for (display = 1; display < 27; display++)
{
map[display] = '*';
cout << map[display];
}
cout << map[27];
cout << endl << endl << "Press 'R', to move your character, 'P', one square to the right, to meet the Dragon.." << endl;
// Above line, lets user know what key to press
display=0; // Start at map[0]
while (gameRunning == true)
{
do
{
cin >> move; // Get user input
move = toupper(move); // Make it uppercase
if(move == 'R') // If input correct
{
map[display] = '*'; // Remove old location of player
display++; // Increase display location
map[display] = 'P'; // Insert player in new map array location
}
}while(move !='R');
for(int x=0;x<28;x++) // Print out new map array with the changed player location
cout << map[x];
if (display == 27) // If player at end of map array, end game
{
gameRunning = false;
}
}
cout << endl << endl << "You met up with the Dragon. Game over." << endl; // Show text explaining why game ended
}
Hi, I'm trying to create a game in which the 'P' is my player and the 'D' is the dragon, and I have 28 positions on the board and the player starts in space 1. The player can only travel forward(higher numbers). And I have to keep track of the current position of the player and mark it on the on-screen map with P. I already made the map but I don't know how to do it so that my player can move forward. Thanks in advanced