Introducción a C++

1

Todo lo que aprenderás sobre C++

2

¿Qué es programar y por qué aprender C++?

Conceptos Generales de C++

3

La Historia de C++ y sus diferencias con C

Preparando el entorno de trabajo

4

Instalando Codeblocks

5

Pasos para instalar en mac

6

Ejecutando nuestro primer programa

7

¿Qué son las librerías STD? - Portada del Proyecto

Manejo de memoria

8

¿Qué es la memoria y tipos de datos?

9

Alojando variables en memoria

10

¿Cómo usar operadores?

11

¿Qué son los apuntadores?

12

Reto: Escribir un programa que calcule áreas.

Entrada de datos y funciones

13

¿Cómo introducir datos a nuestro programa?

14

¿Cómo usar condicionales?

15

Usando condicionales

16

¿Cómo encapsular código en funciones ?

17

¿Qué son los parámetros y como usarlos?

18

Reto: Juego narrativo implementando condicionales y entrada de datos.

Loops y arreglos

19

¿Qué son los arreglos?

20

¿Qué son los Loops?

21

Programando Loops

22

Loops , arreglos y arreglos bidimensionales

23

Dibujando el mapa de nuestro juego con arreglos

24

Manipulando mi jugador con inputs en arreglos unidimensionales

25

Arreglos bidimensionales

26

Reto: Moviendo a mi personaje en mi arreglo bidimensional

Lectura de Archivos

27

Creando y leyendo un archivo externo

28

Leyendo archivos externos

29

Reto: En el mapa, crear punto de inicio y salida del jugador

Programación Orientada a Objetos

30

¿Qué es POO?

31

Definiendo una clase y creando sus instancias

32

Encapsulación

33

Abstracción

34

Herencia

35

Propiedades de clase en herencia

36

Polimorfismo

Finalizando nuestro proyecto

37

Creación de personaje y archivo de encabezado

38

Moviendo mi personaje con entrada de datos

39

Mapa

40

Interacción entre el personaje y el mapa

41

Paredes

42

Optimizando trazado de mapa

43

Colisiones

44

Creando nuestra portada de juego

45

Tesoro y victoria

46

Conclusiones

47

Proyecto final

Reto: Moviendo a mi personaje en mi arreglo bidimensional

26/47

Lectura

Bienvenidos, en este tercer reto tienen que lograr que su personaje se mueva en las direcciones izquierda, derecha, arriba y abajo.
En la clase anterior ya vimos como leer la entrada de datos usando CIN e interpretarla con condicionales para mover a mi personaje en dos direcciones (izquierda y derecha), tienen que hacer lo mismo para moverlo arriba y abajo.
Tip: Al igual que sumamos y restamos una variable que representa el movimiento lateral, tenemos que crear otra que represente el movimiento vertical, manipularla y pasársela como parámetro al dibujado del mapa.

Aportes 283

Preguntas 0

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad? Crea una cuenta o inicia sesión.

Acá dejo mi solución al reto. Si se sale del mapa, saldrá del otro lado

#include <iostream>
#include <conio.h>

using namespace std;

void drawMap(int heroPosX, int heroPosY, char gameMap[5][5]) {

    for (int i=0; i<5;i++)
    {
        for(int p=0; p<5; p++)
        {
            if(i != heroPosY )
            {
                cout << gameMap[p][i];
            }else
            {
                if (p != heroPosX)
                {
                    cout << gameMap[p][i];
                }else {
                    cout << 'X';
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    setlocale(LC_ALL, "");
    char gameMap[5][5] = {
        {'o','o','o','o','o'},
        {'o','o','o','o','o'},
        {'o','o','o','o','o'},
        {'o','o','o','o','o'},
        {'o','o','o','o','o'}
    };
    int heroPosX = 1;
    int heroPosY = 1;
    bool isGameOver = false;
    char input;

    drawMap(heroPosX, heroPosY, gameMap);

    while (!isGameOver) {
        cin >> input;
        if(input == 'd') {
            heroPosX += 1;
        }
        if (input == 'a') {
            heroPosX -= 1;
        }
        if (input == 'w') {
            heroPosY -=1;
        }
        if (input == 's') {
            heroPosY +=1;
        }
        if (input == 'p') {
            isGameOver = true;
        }
        if(heroPosX == 5) {
            heroPosX = 0;
        }
        if(heroPosY == 5) {
            heroPosY = 0;
        }
        if(heroPosX == -1) {
            heroPosX = 4;
        }
        if(heroPosY == -1) {
            heroPosY = 4;
        }
        drawMap(heroPosX, heroPosY, gameMap);
    }

    _getch();
    return 0;
}

Reto Cumplido

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX ,int HeroPosY, char GameMap[5][5]){

    for(int i = 0 ; i < 5 ; i++){
        for(int j = 0; j < 5 ; j++){
            if( i != HeroPosY || j!= HeroPosX ){
                cout << GameMap[i][j];
            }else{
                cout << '6';
            }
        }
        cout << "\n";
    }
}
int main()
{
    bool GameOver = false;
    int HeroPosX = 0;
    int HeroPosY = 0;
    char GameMap [5][5] = {
        {'#','#','#','#','#'},
        {'#','#','#','#','#'},
        {'#','#','#','#','#'},
        {'#','#','#','#','#'},
        {'#','#','#','#','#'},
    };
    DrawMap(HeroPosX,HeroPosY,GameMap);
    char Input = ' ';

    do{
    cin >> Input;
    switch(Input){
        case 'd' :{
        HeroPosX += 1;
        break;
        }
        case 'a' :{
        HeroPosX -= 1;
        break;
        }
        case 'w' :{
        HeroPosY -= 1;
        }
        case 's' :{
        HeroPosY += 1;
        }
    }
    if(HeroPosX == 5 ){
        HeroPosX = 0;
    }
    else if(HeroPosX == -1){
        HeroPosX = 4;
    }
     else if(HeroPosY == 5){
        HeroPosY = 0;
    }
     else if(HeroPosY == -1){
        HeroPosY = 4;
    }
    DrawMap(HeroPosX,HeroPosY,GameMap);
    }while(!GameOver);
    
    return 0;
}

<code>

#include <iostream>

using namespace std;

void drawMap(int heroPositionRow,int heroPositionColumn, char gameMap[5][5])
{
    for(int row = 0; row < 5; row++)//loop for Row
        {
            for(int column = 0; column < 5; column ++)//loop for Column
            {
                if( row != heroPositionRow)
                {
                    cout<< gameMap[row][column];
                }else if( column != heroPositionColumn)
                {
                    cout<< gameMap[row][column];
                }else
                {
                    cout<<'H';
                }
            }
            cout<<endl;
        }
}

int main()
{
    int heroPositionRow = 0, heroPositionColumn = 0;
    char input = ' ';
    bool isGameOver = false;
    char gameMap [5][5] =
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };


        drawMap(heroPositionRow,heroPositionColumn ,gameMap);

     while(isGameOver == false)
    {
        cout<<"Direccion: ";cin>>input;

        switch (input)
        {
            /*
            Cada condional se usa para que al mover de posicion este no se salga del mapa.
            */
        case 'd'://Movimiento a la derecha.
            if(heroPositionColumn < 4 )
            {
                heroPositionColumn += 1;
            }
            break;
        case 'i'://Movimineto a la izquierda.
            if(heroPositionColumn == 0)
            {
             heroPositionColumn -= 0;
            }else
            {
                heroPositionColumn -= 1;
            }
            break;
        case 'a'://Movimineto a la arriba.
            if(heroPositionRow == 0)
            {
             heroPositionRow -= 0;
            }else
            {
               heroPositionRow -= 1;
            }

            break;
        case 'b'://Movimineto a la abajo.
             if(heroPositionRow < 4 )
            {
               heroPositionRow += 1;
            }

            break;
        default://Cualquier respueta diferente, finaliza el juego.
            isGameOver = true;
            break;
        }

        drawMap(heroPositionRow, heroPositionColumn,gameMap);

    }




    return 0;
}


Bueno esta sencillo y no se me ocurrio como usar los arrays para hacerlo en menos lineas, ademas de que me encontre de que la libreria iostream solo trae 4 funciones super basicas. Intente instalar otras librerias como ncurses pero se me hizo un chungo y no queria quedarme pegado con el reto, asi que alli va mi esperpento… salu2

#include <iostream>
#include <stdlib.h>

using namespace std;

int fillMap(int xmap, int ymap, int xchar, int ychar)
{

    for(int i=0; i<ymap; i++)
    {
    cout << endl;
        for(int j=0; j<xmap; j++)
        {
            if(xchar == i && ychar == j)
            {
            cout << "O";
            }
            else
            {
            cout << " ";
            }
        }
    }
}

int main()
{
    char gameInput;
    int xmap = 9;
    int ymap = 9;
    int xchar = 2;
    int ychar = 2;
    //char map [xmap][ymap];

    cout << "bienvenido, presiona a,s,d,w + enter para mover tu personaje" << endl
    << "presiona q + enter para salir" << endl;

    while (gameInput != 'q')
    {
        fillMap(xmap, ymap, xchar, ychar);
        cin >> gameInput;
        if (gameInput == 'a')
        {
            /* mueve personaje a la izquierda */
            ychar = ychar - 1;
        }
        else if (gameInput == 'd')
        {
            /* mueve personaje a la derecha */
            ychar = ychar + 1;
        }
        else if (gameInput == 's')
        {
            /* mueve personaje hacia abajo */
            xchar = xchar + 1;
        }
        else if (gameInput == 'w')
        {
            /* mueve personaje hacia abajo */
            xchar = xchar - 1;
        }
        else
        {
            if (gameInput != 'q')
            {
            cout << "tonto, te dije que ingreses a,s,d,w + enter para mover tu personaje" << endl
            << "y presiona q + enter para salir" << endl;
            }
        }

    }
    return 0;

}
#include <iostream>
#include <stdlib.h>

using namespace std;

void print_menu(){
  cout << "Welcome to my liberynth" << endl;
  cout << "Here's te controls" << endl;
  cout << "[A] to move left" << endl;
  cout << "[D] to move right" << endl;
  cout << "[W] to move up" << endl;
  cout << "[S] to move down" << endl;
  cout << "[P] to end game" << endl;
  cout << "Every move press enter" << endl;
  cout << "Tap any button to start" << endl;
}

void draw_map(int HeroPosition[2][1], string map[11][15]) {

  for(int i = 0; i < 11 ; i++){
    for(int j = 0; j < 15; j++){
      if (i != HeroPosition[0][0] /* && j != HeroPosition[0][1] */){
        cout << map[i][j];
      } else {
        if (j != HeroPosition[0][1]){
          cout << map[i][j];
        }else{
          cout << "  H  ";
        }
      }
    }
    cout << ' ' << endl;
  }

}

int change_position(char move, int HeroPosition[2][1], bool* endGame){
  //bool localEndGame = *endGame;

  switch (move) {
    case 'a':
      HeroPosition[0][1]--;
      break;
    case 'd':
      HeroPosition[0][1]++;
      break;
    case 's':
      HeroPosition[0][0]++;
      break;
    case 'w':
      HeroPosition[0][0]--;
      break;
    case 'p':
      *endGame = true;
      break;
  }

  return HeroPosition[2][1];
}

int main(){
  char move;
  int HeroPosition[2][1] = {
    {1}, {13}
  };
  string map[11][15] = {
    {"||", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "||"},
    {"||", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "||"},
    {"||", "     ", "=====", "     ", "=====", "=====", "=====", "     ", "=====", "=====", "=====", "=====", "=====", "=====", "||"},
    {"||", "     ", "=====", "     ", "=====", "=====", "=====", "     ", "=====", "=====", "=====", "=====", "=====", "     ", "||"},
    {"||", "     ", "=====", "     ", "=====", "=====", "=====", "     ", "     ", "     ", "  *  ", "=====", "     ", "  *  ", "||"},
    {"||", "     ", "=====", "  *  ", "=====", "=====", "=====", "  *  ", "=====", "=====", "=====", "=====", "=====", "=====", "||"},
    {"||", "     ", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "||"},
    {"||", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "     ", "  S  ", "||"},
    {"||", "=====", "     ", "=====", "=====", "=====", "=====", "     ", "=====", "=====", "=====", "=====", "=====", "=====", "||"},
    {"||", "  *  ", "     ", "  *  ", "=====", "=====", "=====", "     ", "     ", "     ", "     ", "     ", "     ", "  *  ", "||"},
    {"||", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "=====", "||"}
  };
  bool endGame = false;

  print_menu();
  do {
    cout << ' ' << endl;
    cin >> move;

    system("clear");

    HeroPosition[2][1] = change_position(move, HeroPosition, &endGame);

    if (HeroPosition[0][0] == 0)
      HeroPosition[0][0]++;
    else if (HeroPosition[0][0] == 10)
      HeroPosition[0][0]--;
    else if (HeroPosition[1][0] == 0)
      HeroPosition[1][0]++;
    else if (HeroPosition[1][0] == 14)
      HeroPosition[1][0]--;
    draw_map(HeroPosition, map);
  } while(!endGame);
  
}

Se borra en cada input.

Buen día.
Mi pregunta es: ¿Hasta qué punto es ideal el uso de los apuntadores? hice mi código en base a eso y me gustó, me ayudo a comprender un poquito más este tema, sin embargo, me queda la duda en que momento sería un: “no es necesario un apuntador” o el uso excesivo de estos empiece afectar mi aplicación.

#include <iostream>

void DrawWorld(char gameMap[5][5], int *heroPosX, int *heroPosY)
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (*heroPosY == i)
                if (*heroPosX == j)
                    std::cout << 'H';
                else
                    std::cout << gameMap[i][j];
            else
                std::cout << gameMap[i][j];
        }

        std::cout << "\n";
    }
}

void CalculateHeroPos(char *input, int *currentHeroPosX, int *currentHeroPosY)
{
    switch (*input)
    {
    case 'a':
        --*currentHeroPosX;
        break;
    case 'd':
        ++*currentHeroPosX;
        break;
    case 'w':
        --*currentHeroPosY;
        break;
    case 's':
        ++*currentHeroPosY;
        break;
    case 'q':
        break;

    default:
        std::cout << "invalid command! :( \n";
        break;
    }
}

int main()
{
    char gameMap[5][5] =
        {
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'}};

    int heroPosX = 3;
    int heroPosY = 1;
    char input = ' ';
    bool isGameOver = false;

    while (!isGameOver)
    {

        if (input == 'q')
        {
            isGameOver = true;
            std::cout << "Good bye! :) \n";
            continue;
        }

        DrawWorld(gameMap, &heroPosX, &heroPosY);

        std::cin >> input;

        CalculateHeroPos(&input, &heroPosX, &heroPosY);
    }

    return 0;
}
#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    system("CLS");
    for (int i = 0; i < 5; i = i + 1)
    {
        for (int j = 0; j < 5; j = j + 1)
        {

            if (i != HeroPosY)
            {
                cout << GameMap[j][i];
            }
            else
            {
                if (j != HeroPosX)
                {
                    cout << GameMap[j][i];
                }
                else
                {
                    cout << "H";
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' ';
    char GameMap[5][5] =
        {
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
        };

    DrawMap(HeroPosX, HeroPosY, GameMap);

    while (isGameOver == false)
    {
        cin >> Input;

        if (Input == 'd')
        {
            HeroPosX += 1;
        }
        else if (Input == 'a')
        {
            HeroPosX -= 1;
        }
        else if (Input == 'w')
        {
            HeroPosY -= 1;
        }
        else if (Input == 's')
        {
            HeroPosY += 1;
        }
        else if (Input == 'f')
        {
            isGameOver = true;
        }

        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}```

¡Hola a todos!

Les dejo mi propuesta para el reto, Le añadí las colisiones al jugador.

#include <iostream>

using namespace std;

/* 
    @description: Draw the map with the player's current position in the screen.
    @param playerPosX: Current player's position on x axis.
    @param playerPosY: Current player's position on y axis.
 */
void DrawMap(int playerPosX, int playerPosY) {
    cout << endl;
    
    for (int j=0; j<=6; j++) {
        for (int i=0; i<=6; i++){
            // Add the map's edges and the left/right border.
            if (i==0 || i==6) {
                if (j==0 || j==6) cout << "*";
                else cout << "|";
            } 
            // Add the top/bottom border.
            else if (j==0 || j==6) cout << "-";
            else {
                // Draw the rest of the map.
                if (i == playerPosX and j == playerPosY) cout << "P";
                else cout << ".";
            }
        }
        cout << endl;
    }

    cout << endl << endl;
}

int main(){
    int playerPosX = 1;
    int playerPosY = 1;
    char input = ' ';
    bool gameOver = false;

    cout << "Bienvenido jugador" << endl;

    while (!gameOver) {
        cout << "¿Qué quieres hacer?";
        cout << "Moverte a la izquierda (a) o moverte a la derecha (d): ";
        cin >> input;

        if (input == 'd' and playerPosX < 5) playerPosX += 1;
        else if (input == 'a' and playerPosX > 1) playerPosX -= 1;
        else if (input == 'w' and playerPosY > 1) playerPosY -= 1;
        else if (input == 's' and playerPosY < 5) playerPosY += 1;
        else if (input == 'p') gameOver = true;

        DrawMap(playerPosX, playerPosY);
        cout << endl;
    } 
}

agregue el detalle de introducir limites…eje x eje y

#include <iostream>
using namespace std;

void DrawGame(int PosHeroX, int PosHeroY, int X, int Y)
{
    for(int i=0; i<Y; i++)
    {
        for(int j=0; j<X; j++)
        {
            if(i != PosHeroY)
            {
                cout << "-";
            }
            else
            {
                if(j != PosHeroX)
                {
                    cout << "-";
                }
                else
                {
                    cout << 'H';
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool IsGameOver = false;
    char Input = ' ';
    int limitY = 0;
    int limitX = 0;
    int limitC = 0;
    cout << "Dibuja un mapa ingresando sus limites..." << endl;
    cout << "limite eje x...";
    cin >> limitX;
    cout << "limite eje y...";
    cin >> limitY;
    DrawGame(HeroPosX, HeroPosY, limitX, limitY);
    while(IsGameOver == false)
    {
        cin >> Input;
        switch(Input)
        {
            case 'd':
                if(HeroPosX != limitX-1)
                {
                    HeroPosX++;
                } else {
                    HeroPosX;
                }
                break;
            case 'a':
                if(HeroPosX != limitC)
                {
                    HeroPosX--;
                } else {
                    HeroPosX;
                }
                break;
            case 's':
                if(HeroPosY != limitY-1)
                {
                    HeroPosY++;
                } else {
                    HeroPosY;
                }
                break;
            case 'w':
                if(HeroPosY != limitC)
                {
                    HeroPosY--;
                } else {
                    HeroPosY;
                }
                break;
            default:
                IsGameOver = true;
                break;
        }
        DrawGame(HeroPosX, HeroPosY, limitX, limitY);
    }
    return 0;
}
#include <iostream>
#include <windows.h>

using namespace std;

void drawMap(char gameZone[5][5],int x,int y){
	system("cls");
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < 5; j++){
			if(y == i && x == j){
				gameZone[i][j] = 'h';
				cout << gameZone[i][j];
			}
			else{
				gameZone[i][j] = '.';
				cout << gameZone[i][j];
			}
		}
		cout << endl;
	}
}

int main()
{
	char gameZone[5][5];
	int x = 0,y = 0;
	bool isGameOver = false;
	char movement = ' ';
	
	drawMap(gameZone,x,y);
	
	while(!isGameOver)
	{
		cin >> movement;
		switch(movement){
			case 'a': 
				x--;
				if(x < 0)
					x++;
			break;
			case 'd': 
				x++;
				if(x > 4)
					x--;
			break;
			case 'w': 
				y--;
				if(y < 0)
					y++;
			break;
			case 's': 
				y++;
				if(y > 4)
					y--;
			break;
			case 'p': isGameOver = true;
			break;
			default: cout << "Opcion Invalida" << endl;
			break;
		}
		drawMap(gameZone,x,y);
	}
	
	return 0;
	
}```
#include <iostream>
#include <array>

using namespace std;

// Recorriendo un arreglo y dibujandolo
void drawMap(char gameMap[][5], int mapSize, int x, int y) {

    for ( int i = 0; i < mapSize; i++ ) {

        cout << endl;
        for ( int j = 0; j < mapSize; j++ ) {

            // Dibujar mapa o jugador
            if ( ( i == y ) && ( x == j ) ){
                cout << 'H';
            }
            else {
                cout << gameMap[i][j];
            }

        }
    }
}


// Rellenando un arreglo
void fillMap( char gameMap[][5], int mapSize ) {
    const char EMPTY = '1'; // constante de lugar vacio

    // Recorriendo el arreglo y rellenando
    for ( int i = 0; i < mapSize; i++ ) {
        for ( int j = 0; j < mapSize; j++ ) {
            gameMap[i][j] = EMPTY;
        }
    }
}

int main() {
    // Constant
    const int mapSize = 5;

    // Mapa y coordenadas de jugador
    char gameMap[mapSize][mapSize];
    int heroPosX = 1;
    int heroPosY = 1;

    // track de seguir jugando
    bool keepPlaying = true;

    // Entrada de jugador y rellenando mapa
    char input = ' ';
    fillMap( gameMap, mapSize );

    // TMover al jugador por el mapa acorde a la entrada del usuario
    while ( keepPlaying ) {
        // Dibujando mapa
        drawMap( gameMap, mapSize, heroPosX, heroPosY );

        // Tomando input del usuario
        cin >> input;

        // Cambiando la posicion del jugador dependiendo del input

        // Posicion en X
        if ( input == 'd' ) {
            heroPosX++;
        }
        else if ( input == 'a' ) {
            heroPosX--;
        }

        // Posicion en Y
        else if ( input == 'w' ) {
            heroPosY--;
        }
        else if ( input == 's' ) {
            heroPosY++;
        }

        // GameOver
        else if ( input == 'p' ) {
            keepPlaying = false;
        }

    }

    return 0;
}

Ejercicio resuelto!

  • Matriz de 4x5
  • Incluye comprobación de límites para evitar desbordamiento
  • Posición de jugador almacenada en vector
#include <iostream>

using namespace std;

void DrawMap(int hPos[2], char gMap[4][5]){
    for(int i=0;i<4;i++){
        for(int j=0;j<5;j++){
            if(j!=hPos[0]-1){
                cout<<gMap[i][j]<<" ";
            }else{
                if(i!=hPos[1]-1){
                    cout<<gMap[i][j]<<" ";
                }else{
                    cout<<"X ";
                }
            }
        }
        cout<<endl;
    }
}

int main()
{
    bool IsGameOver=false;
    char pMove=' ';
    int heroPos[2]={1,1};
    char Gamemap [4][5]{
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };

    while(IsGameOver==false){
        DrawMap(heroPos,Gamemap);
        cout<<" ";
        cin>>pMove;
        switch(pMove){

            case 'a':
            if(heroPos[0]!=1){
                heroPos[0]--;
            }
            break;

            case 'd':
            if(heroPos[0]!=5){
                heroPos[0]++;
            }
            break;

            case 'w':
            if(heroPos[1]!=1){
                heroPos[1]--;
            }
            break;

            case 's':
            if(heroPos[1]!=4){
                heroPos[1]++;
            }
            break;

            case 'x':
            IsGameOver=true;
            break;
        }

    }

    return 0;
}

Buenas noches aqui dejo mi solucion al reto

#include <iostream>
using namespace std;
void DrawMap ( int HeroPosX , int HeroPosY , char GameMap[5][5])
{
    for (int Columnas = 0; Columnas < 5; Columnas++)
    {
        for ( int Filas = 0; Filas < 5; Filas ++)
        {
            if (Columnas != HeroPosY)
            {
                cout <<GameMap[Filas][Columnas];
            }
            else
            {
                if (Filas != HeroPosX)
                {
                    cout <<GameMap[Filas][Columnas];
                }
                else
                {
                    cout << 'X';
                }
            }
        }
        cout<<endl;
    }
}

int main()
{

    int HeroPosX = 1;
    int HeroPosY = 1;
    bool IsGameOver = false;
    char Input = ' ';
    char GameMap[5][5] =    {   {'0','0','0','0','0'},
                                {'0','0','0','0','0'},
                                {'0','0','0','0','0'},
                                {'0','0','0','0','0'},
                                {'0','0','0','0','0'},
                           };


    DrawMap(HeroPosX, HeroPosY ,GameMap);

    while (IsGameOver == false)
    {
        cin >> Input ;

    if (Input == 'd' | Input =='D')
    {
        HeroPosX = HeroPosX + 1;
    }
    else if (Input == 'a' | Input =='A')
    {
        HeroPosX = HeroPosX -1;
    }

    else if (Input == 'w' | Input =='W')
    {
        //HeroPosX =HeroPosX;
        HeroPosY = HeroPosY - 1;

    }
    else if (Input == 's' | Input =='S')
    {
        //HeroPosX =HeroPosX;
        HeroPosY = HeroPosY + 1;
    }


    else if (Input == 'p' | Input== 'P')
    {
        IsGameOver = true;
    }

    DrawMap(HeroPosX, HeroPosY ,GameMap);
    }
    return 0;
}
```Muchas gracias
#include <iostream>

using namespace std;

void drawMap(int heroPosV, int heroPosH, char gameMap[4][5])
{
    for(int j = 0; j < 4; j++)
    {
        for(int i = 0; i < 5; i++)
        {
            if(j != heroPosV || i != heroPosH)
            {
                cout << gameMap[j][i];
            }
            else
            {
                cout << 'H';
            }
        }
    cout << endl;
    }
}

int main()
{
    int posicionH = 2;
    int posicionV = 0;
    char mapa[4][5] =
    {
        {'0', '0', '0', '0', '0'},
        {'0', '0', '0', '0', '0'},
        {'0', '0', '0', '0', '0'},
        {'0', '0', '0', '0', '0'}
    };
    bool gameOver = false;

    drawMap(posicionV, posicionH, mapa);

    char input;

    while(!gameOver)
    {
        cin >> input;

        switch(input)
        {
        case 'd':
            posicionH ++;
            break;
        case 'a':
            posicionH --;
            break;
        case 'w':
            posicionV --;
            break;
        case 's':
            posicionV ++;
            break;
        case 'e':
            gameOver = true;
            break;
        default:
            cout << "Ja?" << endl;
            break;
        }

        drawMap(posicionV, posicionH, mapa);
    }

    return 0;
}
void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for (int i = 0; i < 5; i  = i + 1)
    {
        for (int j = 0; j < 5; j++) {
            if (i != HeroPosY){
                cout << GameMap[j][i];
            }else{
                if (j != HeroPosX)
                {
                    cout << GameMap[j][i];
                } else
                {
                    cout << 'H';
                }

            }
        }
        cout << endl;

    }


}

int main() {

    int HeroPosX = 1;
    int HeroPosY = 1;
    bool IsGameOver = false;
    char Input = ' ';
    char GameMap[5][5] =
            {
                    {'1', '1', '1', '1', '1'},
                    {'1', '1', '1', '1', '1'},
                    {'1', '1', '1', '1', '1'},
                    {'1', '1', '1', '1', '1'},
                    {'1', '1', '1', '1', '1'}
            };

    DrawMap(HeroPosX, HeroPosY, GameMap);

    while (IsGameOver == false)
    {
        cin >> Input;

        if (Input == 'd')
        {
            HeroPosX = HeroPosX + 1;
        }else if (Input == 'a')
        {
            HeroPosX = HeroPosX - 1;
        }else if (Input == 'p')
        {
            IsGameOver = true;
        }else if (Input == 'w')
        {
            HeroPosY = HeroPosY - 1;
        }else if (Input == 's')
        {
            HeroPosY = HeroPosY + 1;
        }

        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}```

Les dejo mi versión:

#include <iostream>

using namespace std;
void drawMap(int heroPosX, int heroPosY, char gameMap[5][5])
{
   for(int i = 0; i < 5; i++) //for columnas
    {
        for(int p = 0; p < 5; p++) //for filas
        {
                if(i != heroPosY)
                    {
                        cout << gameMap[p][i];

                    }else
                    {
                        if(p != heroPosX)
                        {
                            cout << gameMap[p][i];
                        } else
                        {
                            cout << 'H';
                        }

                    }
        }
        cout << endl;

    }
}
int main()
{
    int heroPosX = 1;
    int heroPosY = 1;
    bool isGameOver = false;
    char input = ' ';

    char gameMap[5][5] =
    {
        {'1', '1','1','1','1'},
        {'1', '1','1','1','1'},
        {'1', '1','1','1','1'},
        {'1', '1','1','1','1'},
        {'1', '1','1','1','1'}
    };

    drawMap(heroPosX, heroPosY, gameMap);
    while(isGameOver == false)
    {
            cin >> input;

            if(input == 'd')
                {
                heroPosX++;
                }else if(input == 'a')
                    {
                    heroPosX--;
                    } else if(input == 'w')
                        {
                        heroPosY--;
                        }else if(input == 's')
                            {
                            heroPosY++;
                            }
                            else if (input == 'p')
                                {
                                isGameOver = true;
                                }
            drawMap(heroPosX, heroPosY, gameMap);
    }


    return 0;
}```
#include <iostream>

void draw_map(char game_map[5][5], int heroPositionX, int heroPositionY)
{
    for (int i = 0; i < 5; ++i)
    {
        for (int j = 0; j < 5; ++j)
        {
            if (i == heroPositionY && j == heroPositionX)
            {
                std::cout << 'H';
            }
            else
            {
                std::cout << game_map[i][j];
            }
        }

        std::cout << std::endl;
        
    }
}

int main()
{
    int heroPositionX = 0;
    int heroPositionY = 1;
    char key = '\000';
    bool gameOver = false;
    char game_map[5][5] = {{'1', '1', '1', '1', '1'}, 
                           {'1', '1', '1', '1', '1'}, 
                           {'1', '1', '1', '1', '1'},
                           {'1', '1', '1', '1', '1'},
                           {'1', '1', '1', '1', '1'}};

    draw_map(game_map, heroPositionX, heroPositionY);

    while (!gameOver)
    {
        std::cin >> key;
        if (key == 'd')
        {
            ++heroPositionX;
        }
        else if (key == 'a')
        {
            --heroPositionX;
        }
        else if (key == 'w')
        {
            --heroPositionY;
        }
        else if (key == 's')
        {
            ++heroPositionY;
        }
        else if (key == 'p')
        {
            gameOver = true;
        }

        draw_map(game_map, heroPositionX, heroPositionY);
    }

    return 0;
}
`<#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for(int fila = 0; fila < 5; fila++)
    {
        for(int columna = 0; columna<5; columna++)
        {
            if(fila != HeroPosY)
            {
            cout << GameMap[columna][fila] << " ,";
            }else
            {
                if(columna != HeroPosX)
            {
                cout << GameMap[columna][fila] << " ,";
            }else
            {
                cout << "HeroIsHere" << " ,";
            }
            }
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' ';
    char GameMap[5][5] =
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };

    DrawMap(HeroPosX, HeroPosY, GameMap);

    while(isGameOver == false)
    {
          cin >> Input;

    if(Input == 'd')
    {
        HeroPosX += 1;
    }else if(Input == 'a')
    {
        HeroPosX -= 1;
    }else if(Input == 'w')
    {
        HeroPosY -= 1;
    }else if(Input == 'z')
    {
        HeroPosY += 1;
    }else if(Input == 'p')
    {
        isGameOver = true;
    }

    DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}>

Mi solución:

#include <iostream>
#include <conio.h>

using namespace std;

void DrawMap(int heroPX,int heroPY,char map[5][5]) {
	for (int j = 0; j < 5; j++) {
		for (int i = 0; i < 5; i++) {
			if (heroPX == i && heroPY == j) {
				cout << "H";
			}
			else {
				cout << map[j][i];
			}
		}
		cout << endl;
	}
}

int main() {
	int heroPosX = 0;
	int heroPosY = 0;
	bool isGameOver = false;
	char input = ' ';
	//map[filas][columnas]
	char map[5][5] = {
		{'1','1','1','1','1'},
		{'1','1','1','1','1'},
		{'1','1','1','1','1'},
		{'1','1','1','1','1'},
		{'1','1','1','1','1'},
	};

	DrawMap(heroPosX,heroPosY, map);
	while (isGameOver == false) {
		cin >> input;
		input = tolower(input);
		if (input == 'd') {
			heroPosX += 1;
		}
		else if (input == 'a') {
			heroPosX -= 1;
		}
		else if (input == 'w') {
			heroPosY -= 1;
		}
		else if (input == 's') {
			heroPosY += 1;
		}
		else {
			isGameOver = !isGameOver;
		}
		DrawMap(heroPosX,heroPosY, map);
	}

	getch();
	return 0;
}
#include<iostream>
using namespace std; 

void DrawMap (int HeroPosX,int HeroPosY, char GameMap[5][5]);

int main()
{
    int HeroPosX = 0;
    int HeroPosY = 0;
    bool isGameOver = false; 
    char Input = ' '; 
    char GameMap[5][5] = {{'1', '1', '1', '1', '1'},{'1', '1', '1', '1', '1'},{'1', '1', '1', '1', '1'},
    {'1', '1', '1', '1', '1'},{'1', '1', '1', '1', '1'}};
    DrawMap(HeroPosX, HeroPosY, GameMap);
    while (isGameOver == false)
    {
        cin >> Input;
        switch(Input)
        {
            case 'd':
            HeroPosX += 1; 
            break;
            case 'a':
            HeroPosX -= 1;
            break;
            case 'w':
            HeroPosY -= 1;
            break;
            case 's':
            HeroPosY += 1;
            break;
            case 'p':
            isGameOver = true;
            break;
        }
        DrawMap(HeroPosX, HeroPosY, GameMap);
    }
    return 0;
}

void DrawMap (int HeroPosX, int HeroPosY,  char GameMap[5][5]){
    for (int j = 0; j < 5; j++)
    {
        for (int i = 0; i < 5; i++)
        {
            if (i == HeroPosX && j == HeroPosY)
            {
                cout<<'H';
            }
            else
            {
                cout<<GameMap[i][j];
            }
        }
        cout<<endl;
    }
}

Vamos a ello

Despues de Media hora moviendo la funcion (pensando que tenia que acomodar el movimiento en Y), Me di cuenta que solo tocaba agregar w y s, a la variable Hero en plano Y ._.)

#include <iostream>

using namespace std;
void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5]){
for(int i = 0; i < 5; i++)
{
for(int p = 0; p < 5; p++)
{
if(i != HeroPosY)
{
cout << GameMap[p][i];
} else
{
if(p != HeroPosX){

                    cout << GameMap[p][i];

                }else{
                            cout << 'H';
                        }
                    }

                }





        cout << endl;
    }

}

int main()
{
int HeroPosY = 1;
int HeroPosX = 1;
bool isGameOver = false;
char input = ’ ';
char GameMap[5][5] = {
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’}
};

DrawMap(HeroPosX, HeroPosY, GameMap);

while (isGameOver == false){
   cin >> input;

    if (input == 'd')
{
    HeroPosX = HeroPosX + 1;
}   else if (input == 'a')
{
    HeroPosX = HeroPosX - 1;}
        else if (input == 'w')
                {
            HeroPosY = HeroPosY - 1;}
                 else if (input == 's')
                {
                    HeroPosY = HeroPosY + 1;}

                        else if (input == 'p'){
                                isGameOver = true;
                            }

    DrawMap(HeroPosX, HeroPosY, GameMap);

}

}

Terminado

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5]){
	for(int i=0; i<5; i++){
		for(int j=0; j<5; j++){
		
			if(i!=HeroPosY ){
				cout<<GameMap[i][j];
			}
			else{
					if(j!=HeroPosX ){
						cout<<GameMap[i][j];
				}
				else{
						cout<<'H';
					}
			}
		}
		cout << endl;
	}			
}




int main(){
	char GameMap[5][5]={
			{'1','1','1','1','1'},
			{'1','1','1','1','1'},
			{'1','1','1','1','1'},
			{'1','1','1','1','1'},
			{'1','1','1','1','1'},
		};
		
		
	int HeroPosX = 0;
	int HeroPosY = 0;
	bool isGameOver = false;
	
	
	char Input = ' ';
	while(isGameOver==false){
		cin >> Input;
		if(Input == 'd'){
			HeroPosX = HeroPosX + 1;
		} 
		else if(Input == 'a'){
			HeroPosX = HeroPosX - 1;
		}
		if(Input == 'w'){
			HeroPosY = HeroPosY - 1;
		} 
		else if(Input == 's'){
			HeroPosY = HeroPosY + 1;
		}
		else if(Input == 'p'){
			isGameOver = true;
		}
		DrawMap(HeroPosX, HeroPosY, GameMap);
	}
	
	return 0;
}

mi juego

// practica de c++.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

void DrawMap(int posX,int posY) {

	char map[5][5] = {
	{ '1','1','1','1','1' },
	{ '1','1','1','1','1' },
	{ '1','1','1','1','1' },
	{ '1','1','1','1','1' },
	{ '1','1','1','1','1' }
	};
	for (size_t i = 0; i < 5; i++)
	{
		for (size_t O = 0; O < 5; O++)
		{
			if ((posY != i)||(posX != O)) {
				cout << map[O][i];
			}
			else {
				cout << "H";		
			}
			
		}
		cout << endl;
	
	}

}
int clamp(int num, int min, int max) {
	if (num <= min) {
		return min;
	}
	else if (num >= max){
		return max;
	}
	else {
		return num;
	}

	}

int main()
{
	char mover;
	int HeroPosX = 0;
	int HeroPosY = 0;
	bool isGameOver = false;
	DrawMap(HeroPosX, HeroPosY);


	while (!isGameOver) {
		cin >> mover;

		//mueve en el eje X
		if (mover == 'a') {
			HeroPosX--;
		}
		else if (mover == 'd') {
			HeroPosX++;
			//mueve en el eje Y
		}else if (mover == 's') {
			HeroPosY++;
		}
		else if (mover == 'w') {
			HeroPosY--;
		}
		else if (mover == 'p') {
			isGameOver = true;
		}

	    HeroPosX = clamp(HeroPosX, 0, 4);
		HeroPosY = clamp(HeroPosY, 0, 4);
		DrawMap(HeroPosX,HeroPosY);
			
	}
}

kksfskfjsdfjnf



#include <iostream>

using namespace std;

void drawMap(int heroposX,int heroposY, char gameMap[5][5])
{
for (int i = 0; i < 5; i++)
{
for(int n = 0; n < 5; n++)
{
if(i != heroposY)
{
cout << gameMap[n][i];
}else
{
if(n != heroposX)
{
cout << gameMap[n][i];
}else
{
cout << ‘H’;
}

    }
    }
    cout << endl;
}

}

int main()
{
int heroposY = 1;
int heroposX = 0;
bool isGameover = false;
char input = ’ ';
char gameMap [5][5] =
{
{‘1’,‘1’,‘1’,‘1’,‘1’,},
{‘1’,‘1’,‘1’,‘1’,‘1’,},
{‘1’,‘1’,‘1’,‘1’,‘1’,},
{‘1’,‘1’,‘1’,‘1’,‘1’,},
{‘1’,‘1’,‘1’,‘1’,‘1’,},
};

drawMap(heroposX, heroposY, gameMap);

while(isGameover == false)
{
        cin >> input;

if (input == 'd')
{
    heroposX = heroposX + 1;
}else if(input == 'a')
{
    heroposX = heroposX - 1;
}else if ( input == 'w')
{
    heroposY = heroposY - 1;
}else if (input == 's')
{
    heroposY = heroposY + 1;
}else if(input == 'p')
{
    isGameover = true;

}
drawMap(heroposX, heroposY, gameMap);

}
cout << "Gameover";



return 0;

}

Lo resolví en el anterior clase, igual compartó mi código otra vez.

#include <iostream>
#include <cstdlib>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[][])
{
    system("cls");
    for (int i = 0; i < 5; i++)
    {
        for (int p = 0; p < 5; p++)
        {
            if (i != HeroPosY)
            {
                cout << GameMap[p][i];
            }
            else
            {
                if (p != HeroPosX)
                {
                    cout << GameMap[p][i];
                }
                else
                {
                    cout << 'H';
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' ';
    char GameMap[5][5] =
        {
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'},
            {'1', '1', '1', '1', '1'}};
    int rows = sizeof(GameMap) / sizeof(GameMap[0]);
    int columns = sizeof(GameMap[0]) / sizeof(GameMap[0][0]);

    DrawMap(HeroPosX, HeroPosY, GameMap);

    while (isGameOver == false)
    {
        cin >> Input;

        if (Input == 'd')
        {
            HeroPosX++;
        }
        else if (Input == 'a')
        {
            HeroPosX--;
        }
        else if (Input == 'w')
        {
            HeroPosY--;
        }
        else if (Input == 's')
        {
            HeroPosY++;
        }
        else if (Input == 'p')
        {
            isGameOver = true;
        }

        if (HeroPosX > columns - 1)
        {
            HeroPosX = 0;
        }
        else if (HeroPosX < 0)
        {
            HeroPosX = columns - 1;
        }

        if (HeroPosY > rows - 1)
        {
            HeroPosY = 0;
        }
        else if (HeroPosY < 0)
        {
            HeroPosY = rows - 1;
        }
        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}

Les comparto mi solucion del reto 😃

#include <iostream>

using namespace std;

void drawMap(int heroPosX, int heroPosY, char gameMap[5][5])
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (i != heroPosY)
            {
                cout << gameMap[i][j];
            }
            else
            {
                if (j != heroPosX)
                {
                    cout << gameMap[i][j];
                }
                else
                {
                    cout << "o";
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    int heroPosX = 1;
    int heroPosY = 1;
    bool isGameOver = false;
    char input = ' ';

    char gameMap[5][5] =
        {
            {'.', '.', '.', '.', '.'},
            {'.', '.', '.', '.', '.'},
            {'.', '.', '.', '.', '.'},
            {'.', '.', '.', '.', '.'},
            {'.', '.', '.', '.', '.'}};

    drawMap(heroPosX, heroPosY, gameMap);

    while (isGameOver == false)
    {
        cin >> input;

        if (input == 'd')
        {
            heroPosX = heroPosX + 1;
        }
        else if (input == 'a')
        {
            heroPosX = heroPosX - 1;
        }
        if (input == 'w')
        {
            heroPosY = heroPosY - 1;
        }
        else if (input == 's')
        {
            heroPosY = heroPosY + 1;
        }
        else if (input == 'p')
        {
            isGameOver = true;
        }
        drawMap(heroPosX, heroPosY, gameMap);
    }

    return 0;
}

#include <iostream> // Libreria para imprimir los comandos de la consola
using namespace std;// Si en caso se quitara se debe escribir std :: cout llamando a la libreria

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{

for (int i = 0 ; i < 5 ; i++)
{
for (int p = 0 ; p < 5 ; p++)
{
if (i != HeroPosX)
{
cout << GameMap[i][p];
}
else
{
if (p != HeroPosY)
{
cout << GameMap[i][p];
}
else
{
cout << ‘H’;
}
}

        }
        cout << endl;


}

}
int main()

{
int HeroPosX = 0;
int HeroPosY = 0;
char Input = ’ ';
bool GameOver = false;
char GameMap[5][5] =

{
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
};

cout << “Empieza El Juego” << endl;
cout << “Estas listo…” << endl;
cout << “Tu personaje es H, Muevelo de izquierda a derecha (A & D)” << endl;

DrawMap(HeroPosX,HeroPosY,GameMap);

while(GameOver == false)
{
cin >> Input;

if(Input == 'A')
{
    HeroPosY--;
}

else if(Input == 'D')
{
    HeroPosY++;
}

else if(Input == 'S')
{
    HeroPosX++;
}

else if(Input == 'W')
{
    HeroPosX--;
}

else if(Input == 'P')
{
    GameOver=true;
}

DrawMap(HeroPosX,HeroPosY,GameMap);

}

return 0;
}

Hola, aca mi ejemplo. Pd: Estuve investigando sobre formas para limpiar la pantalla y me encontre con una posibilidad usando codigos de escape Ansi
#include <iostream>

using namespace std;


void Clear()
{
    cout << "\x1B[2J\x1B[H";
}


void DrawMap(int HeroPosX,int HeroPosY , char gameMap[5][5]) {
        for(int i =0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if (i != HeroPosY) {
                    cout << gameMap[j][i] ;
                }else {
                    if (j != HeroPosX) {
                        cout << gameMap[j][i] ;
                    }else {
                        cout << 'H';
                    }
                }
            }
            cout << endl;
        }
}
int main()
{
    char GameMap[5][5] = {{ '1','1' ,'1' ,'1' ,'1' }, { '1','1' ,'1' ,'1' ,'1' }, { '1','1' ,'1' ,'1' ,'1' }, { '1','1' ,'1' ,'1' ,'1' }, { '1','1' ,'1' ,'1' ,'1' } };
    char Input = ' ';
    int HeroPosX = 0;
    int HeroPosY = 0;
    bool isGameOver = false;

    cout << "Tutorial Basico: " << endl;
    cout << "a. Mover a la izquiera" << endl;
    cout << "d. Mover a la derecha" << endl;
    cout << "w. Subir" << endl;
    cout << "s. Bajar" << endl;
    cout << "p. Salir del juego" << endl;
    while (isGameOver == false) {
            cout << endl;
        cin >> Input;

        if (Input == 'd') {
            HeroPosX += 1;
        }else if (Input == 'a') {
            HeroPosX -= 1;
        }else if (Input == 'w') {
                HeroPosY -= 1;
        }else if (Input == 's') {
            HeroPosY += 1;
        }else if (Input == 'p') {
            isGameOver = true;
        }

        if (HeroPosX == 5) {
            HeroPosX = 0;
        }

        if (HeroPosY == 5) {
            HeroPosY = 0;
        }

        if (HeroPosX == -1) {
            HeroPosX = 0;
        }

        if (HeroPosY == -1) {
            HeroPosX = 0;
        }
        Clear();
        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}

Agregue la posición Y del “Jugador” en el while y ya me funciono. :3

while(isGameOver == false)
    {
       cin >> input;
       if(input == 'd')
       {
           heroPosX = heroPosX + 1;
       }
      else if(input == 'a')
      {
          heroPosX = heroPosX - 1;
      }
      else if(input == 'w')
      {
          heroPosY = heroPosY - 1;
      }
      else if(input == 's')
      {
          heroPosY = heroPosY + 1;
      }
      else if(input == 'p')
      {
          isGameOver = true;
      }

      DrawMap(heroPosX, heroPosY, gameMap);
    }
#include <iostream>

using namespace std;

void DrawMap (int HeroPosX, int HeroPosY, char GameMap[5][5])
{
     for(int i = 0; i < 5; i =  i + 1)
   {
       for(int j = 0; j < 5; j = j + 1)
       {
       if (i != HeroPosY)
       {
           cout << GameMap[j][i];
       }
       else
       {
           if (j != HeroPosX)
           {
               cout << GameMap[j][i];
           }
           else
           {
               cout << 'H';
           }
       }
       }
       cout << endl;
   }
}

int main()
{
   int HeroPosX = 0;
   int HeroPosY = 0;
   bool IsGameOver = false;
   char Input = ' ';

   cout << "***** Movimiento del personaje *****" << endl;
   cout << "w: Arriba" << endl;
   cout << "s: Abajo" << endl;
   cout << "a: Izquierda" << endl;
   cout << "\n e: Salir \n" << endl;

   char GameMap [5][5] =
   {
        {'.','.','.','.','.'},
        {'.','.','.','.','.'},
        {'.','.','.','.','.'},
        {'.','.','.','.','.'},
        {'.','.','.','.','.'}
   };

   DrawMap(HeroPosX,HeroPosY, GameMap);

   while(IsGameOver == false)
{
    cin >> Input;

   if (Input == 'd')
   {
       HeroPosX = HeroPosX + 1;
   }

   else if(Input == 'a')
   {
       HeroPosX = HeroPosX - 1;
   }

   else if(Input == 's')
   {
       HeroPosY = HeroPosY - 1;
   }

   else if(Input == 'w')
   {
       HeroPosY = HeroPosY + 1;
   }

   else if (Input == 'e')
   {
       cout << "\n Ha salido correctamente" << endl;
       break;
   }

   else if (Input == 'p')
   {
       IsGameOver = true;
   }

   else
   {
       cout << "\n Opcion NO VALIDA" << endl;
   }

   DrawMap(HeroPosX,HeroPosY,GameMap);
}

cout << "\n ***** Fin del Movimiento del personaje *****" << endl;
   return 0;
}
<code>
#include <iostream>

using namespace std;

//Contexto: Eres un pirata, cuyo viaje le lleva a explorar una gran isla, en busca de un tesoro legendario.

void DrawMap(int playerposX,int playerposY, char gameMap[6][6])
{
    for( int i = 0; i < 6; i++)
    {
        for(int f = 0; f < 6; f++)
        {
          if( f != playerposX)
          {
           cout << gameMap[f][i];
          }
          else
          {
           if(i != playerposY)
           {
               cout << gameMap[f][i];
           }
           else
           {
               cout <<"H";
           }
           }
         }
         cout << endl;
    }
}

int generateRandom(){
    return rand() % 3 + 3;}

int main()
{

    int playerposX = 1;
    int playerposY = 4;
    bool isgameover = false;
    char mover = ' ';
    char gameMap[6][6] =
    {
        {'.', '.', '~', '~', '-','-'},
        {'.', '.', '~', '~', '-','-'},
        {'.', '.', '~', '~', '-','-'},
        {'.', '.', '~', '~', '-','-'},
        {'.', '.', '~', '~', '-','-'},
        {'.', '.', '~', '~', '-','-'}

    };

    int treasureX = generateRandom();
    int treasureY = generateRandom();
    gameMap[treasureX][treasureY] = 'X';

    DrawMap(playerposX, playerposY, gameMap);


    while(isgameover == false)
{
    cout <<"\nEncuentra el tesoro, marcado con una X en el mapa " << endl;
    cin >> mover;
    switch (mover)
        {
        case'd':
            playerposX++;
            break;
        case'a':
            playerposX--;
            break;

        case'w':
            playerposY--;
            break;
        case's':
            playerposY++;
            break;

        case'p':
            isgameover = true;
            break;
        default:
            cout<<"No es momento de filosofar pirata"<<endl;
            break;
        }

    DrawMap(playerposX, playerposY, gameMap);


    if (playerposX < 0 || playerposX > 5 || playerposY < 0 || playerposY > 5)
        {
            cout<<"PERDISTE: Hemos perdido un gran camarada"<<endl;
            isgameover = true;
        }
    else if(playerposX == treasureX && playerposY == treasureY)
    {
            cout<<"GANASTE: Lo lograste, bajen las velas! "<<endl;
            isgameover = true;
    }
}

    return 0;
}
using namespace std;
void playerMovement (int PlayerPosX, int PlayerPosY, char mapa[5][5])
{
    for ( int i = 0 ; i < 5 ; i++ )
    {
        for ( int j = 0 ; j < 5 ; j++ )
        {
            if ( i!= PlayerPosX)
            {
                cout << mapa[j][i];
            }
            else
            {
                if ( j != PlayerPosY)
                    {
                        cout << mapa[j][i];
                    }
                else
                    {
                        cout << 'P';
                    }
            }
        }
        cout << endl;
    }
}

int main()
{
    int PlayerPosX = 0;
    int PlayerPosY = 0;
    bool GameOver = false;
    char InputPos = ' ';

    cout << "***** Movimiento del Personaje *****" << endl;
    cout << "w: Arriba" << endl;
    cout << "s: Abajo" << endl;
    cout << "a: Izquierda" << endl;
    cout << "d: Derecha" << endl;
    cout << "\ne: Salir\n" << endl;

    char mapa[5][5] =
    {
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'},
    };

    while (GameOver == false)
    {
        cout << "\nIngrese opcion:";
        cin >> InputPos;

        if(InputPos == 'w')
        {
            PlayerPosX = PlayerPosX - 1;
        }
        else if (InputPos == 's')
        {
            PlayerPosX = PlayerPosX + 1;
        }
        else if (InputPos == 'd')
        {
            PlayerPosY = PlayerPosY + 1;
        }
        else if (InputPos == 'a')
        {
            PlayerPosY = PlayerPosY - 1;
        }
        else if(InputPos == 'e')
        {
            cout << "\nHa salido correctamente" << endl;
            break;
        }
        else
        {
            cout << "\nOpcion no valida" << endl;
        }

        playerMovement(PlayerPosX, PlayerPosY, mapa);
    }
    cout << "\n***** Fin del Movimieto del Personaje *****" << endl;
    return 0;
}
#include <iostream>

using namespace std;

void drawMap(int playerPosX, int playerPosY, char gameMap[5][5])
{
    for(int i = 0; i < 5; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            if(j != playerPosX)
                cout << gameMap[i][j];
            else if (i != playerPosY)
                cout << gameMap[i][j];
            else
                cout << 'H';
        }
        cout << endl;
    }
}

int main()
{
    int playerPosX = 0, playerPosY = 0;
    char mov;
    bool isGameOver = false;
    char gameMap[5][5] =
    {
        {'0', '0', '0', '0', '0'},
        {'0', '0', '0', '0', '0'},
        {'0', '0', '0', '0', '0'},
        {'0', '0', '0', '0', '0'},
        {'0', '0', '0', '0', '0'}

    };

    drawMap(playerPosX, playerPosY, gameMap);

    while(isGameOver == false)
    {
        cin >> mov;
        switch(mov)
        {
            case'w':
                playerPosY--;
                break;
            case's':
                playerPosY++;
                break;
            case'a':
                playerPosX--;
                break;
            case'd':
                playerPosX++;
                break;
            default:
                isGameOver = true;
                break;
        }
        drawMap(playerPosX, playerPosY, gameMap);
    }
    return 0;
}

Reto

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for(int i = 0; i < 5; i++)
    {
        for(int p = 0; p < 5; p++)
        {
            if(i != HeroPosY)
            {
                cout << GameMap[p][i];
            } else
            {
                if(p != HeroPosX)
                {
                    cout << GameMap[p][i];
                } else
                {
                    cout << 'H';
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool IsGameOver = false;
    char Input = ' ';
    char GameMap[5][5] =
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };


    DrawMap(HeroPosX, HeroPosY, GameMap);
    while(IsGameOver == false)
    {
        cin >> Input;
        switch (Input)
        {
            case 'a':
                HeroPosX -= 1;
                break;
            case 'd':
                HeroPosX += 1;
                break;
            case 'w':
                HeroPosY -= 1;
                break;
            case 's':
                HeroPosY += 1;
                break;
            case 'p':
                 IsGameOver = true;
                 break;
            default:
                  break;
        }
        DrawMap(HeroPosX, HeroPosY, GameMap);
    }


    return 0;
}

Ya lo había colocado en la sección de aportes de la clase pero bueno para participar en esta sección

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for(int i = 0; i < 5; i = i + 1)
    {
        for(int p = 0; p < 5; p++)
            if(i != HeroPosY)
            {
                cout << GameMap[p][i];
            }
            else
            {
                if(p != HeroPosX)
                {
                    cout << GameMap[p][i];
                }
                else
                {
                    cout<< 'H';
                }
            }
        cout << endl;
    }
}


int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' d';
    char GameMap[5][5] =
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };




    DrawMap(HeroPosX, HeroPosY,GameMap);

    while(isGameOver == false)
    {
        cin >> Input;

        if(Input == 'd')
        {
            HeroPosX = HeroPosX + 1;
        }
        else if (Input == 'a')
        {
            HeroPosX = HeroPosX - 1;
        }
        else if (Input == 's')
        {
            HeroPosY = HeroPosY + 1;
        }
        else if (Input == 'w')
        {
            HeroPosY = HeroPosY - 1;
        }
        else if (Input == 'p')
        {
            isGameOver = true;
        }
        DrawMap(HeroPosX, HeroPosY, GameMap);
        }
    return 0;
}

Tercer intento más pulido:

#include <iostream>
#include <stdlib.h>

using namespace std;

//Valida si el movimiento es valido viendo si no se desborda de los limites del mapa

bool isValidMovement(int heroPosX, int heroPosY, char mov)
{
    int maxBorder = 4;
    int minBorder = 0;
    switch(mov)
    {
    case 'd':
        if(heroPosX + 1 > maxBorder)
        {
            return false;
        }
        break;

    case 'a':
        if(heroPosX - 1 < minBorder)
        {
            return false;
        }
        break;

    case 'w':
        if(heroPosY - 1 < minBorder)
        {
            return false;
        }
        break;

    case 's':
        if(heroPosY + 1 > maxBorder)
        {
            return false;
        }
        break;


    //Cualquier opción que no sea una de las anteriores
    default:
        return true;
        break;
    }



    return true;
}

//Funcion que dibuja el mapa dependiendo la posicion del heroe y el arreglo del mapa
void DrawMap(int heroPosX, int heroPosY, char gameMap[5][5])
{
    // i columnas, j filas

    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (i != heroPosY)
            {
                cout << gameMap[j][i];
            }
            else
            {
                if(j != heroPosX)
                {
                    cout << gameMap[j][i];
                }
                else
                {
                    cout << 'O';
                }
            }


        }

        cout << endl;
    }





}

int main()
{
    //Declaración de variables
    int heroPosX = 1;
    int heroPosY = 1;
    char input = ' ';
    bool isGameOver = false;
    char gameMap [5][5] =
    {
        {'|','|','|','|','|'},
        {'-','.','.','.','-'},
        {'-','.','.','.','-'},
        {'-','.','.','.','-'},
        {'|','|','|','|','|'}

    };

    //Se inicia el juego
    DrawMap (heroPosX, heroPosY, gameMap);


    // Mientras que no sea gameOver
    while (isGameOver != true)
    {


        //Recibe movimiento
        cin >> input;
        system ("CLS");

        //Evalua las opciones
        if(isValidMovement(heroPosX, heroPosY, input))
        {
            switch(input)
            {
            //Se mueve a la derecha
            case 'd':
                heroPosX ++;
                break;

            //Se mueve a la izquierda
            case 'a':
                heroPosX --;
                break;

            //Se mueve arriba
            case 'w':
                heroPosY --;
                break;

            //Se mueve abajo
            case 's':
                heroPosY ++;
                break;
            //Se termina el juego
            case 'q':
                isGameOver = true;
                break;

            //Cualquier opción que no sea una de las anteriores
            default:
                cout << "Invalid option, try again :)" << endl;
                break;
            }
            //Se dibuja el mapa con el nuevo movimiento

        }
        else
        {
            cout << "Invalid movement in (x,y): " << heroPosX << " " << heroPosY << endl;
        }


        DrawMap (heroPosX, heroPosY, gameMap);
        cout << endl;
    }
    return 0;
}

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for(int i=0; i<5;i++)
    {
        for(int p=0;p<5;p++)
        {
           if(i != HeroPosY)
        {
          cout<<GameMap[p][i];
        }else
        {

            if(p != HeroPosX)
            {
                cout<<GameMap[p][i];
            }else{
        cout << 'H';
            }
        }
        }
cout <<endl;

    }
}


int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char input = ' ';
    char GameMap [5][5]= {
    {'[','[','[','[','['},
    {'[','[','[','[','['},
    {'[','[','[','[','['},
    {'[','[','[','[','['},
     {'[','[','[','[','['}
    };


    DrawMap(HeroPosX, HeroPosY, GameMap);

    while(isGameOver == false)
          {
              cin >> input;

if(input == 'd')
{
    HeroPosX = HeroPosX+1;
}else if (input == 'a')
{
    HeroPosX=HeroPosX-1;
}else if(input == 'p')
{
    isGameOver = true;
}
else if(input == 'z'){
    HeroPosY = HeroPosY + 1;

}else if(input == 'x') {
    HeroPosY = HeroPosY -1;
}
DrawMap (HeroPosX, HeroPosY, GameMap);

          }





    return 0;
}
while(isGameOver == false && heroPosX >= 0 && heroPosX <= 5){
            cin >> user_input;





        switch(toupper(user_input))
        {
        case 'D':
            heroPosX += 1;
            break;

        case 'A':
            heroPosX -= 1;
            break;

        case 'W':
            heroPosY -= 1;
            break;

        case 'S':
            heroPosY += 1;
            break;

        case 'P':
            isGameOver = true;
        }

        system("clear");
        draw_map(heroPosX, heroPosY, gameMap);



}

Pueden agregar el system(“clear”) si estan en Linux, o system(“cls”) si es windows para que asi despues de cada movimiento limpie la consola y se aprecie mejor

Juego listo: refrescado automático de la pantalla, movimiento en las 4 direcciones, contador de vidas y algunos detalles…

#include <iostream>
#include <stdlib.h> // Libreria para funcion de sistema cls
using namespace std;

void DrawMap (int HeroPosX, int HeroPosY, char GameMap[5][5], int sizeMap, int lives, bool leaving){
    system("cls");
    cout << "Welcome to the ARENA" << endl;
    cout << "Use the keys to move through the Map:  \n "
         << "A (LEFT), D (RIGHT), W (UP), S (DOWN)" << endl;
    cout << "Avoid getting off the map!" << endl;
    cout << "Lives: " << lives << endl;
    for (int i = 0; i < sizeMap; i++){
        for (int j = 0; j < sizeMap; j++) {
           if (j == 0) {
                cout << "\t  "
                ; //dibuje un borde
           }
           if (j != HeroPosX || i != HeroPosY){
                cout << GameMap[i][j] << " ";
            }
            else {
                cout << 'H' << " ";
            }
        }
        cout << endl << endl;
    }
    if (leaving) {
        cout << "Careful, you are leaving the map" << endl;
    }
    cout << "PRESS 'C' TO FINISH THE GAME" << endl;
    cout << "\t      ";
}

int main()
{
    bool isGameOver = false;        //Para terminar el juego
    char GameMap [5][5]= { {'1','1','1','1','1'},
                           {'1','1','1','1','1'},
                           {'1','1','1','1','1'},
                           {'1','1','1','1','1'},
                           {'1','1','1','1','1'}};
    int sizeMap = sizeof(GameMap[0]);
    char Input = ' ';               //Para el control del personaje
    int HeroPosX = 0;
    int HeroPosY = 0;
    int lives = 3;                  //Contador de vidas restantes
    bool leaving = false;           //Para controlar si se ha salido del mapa
    DrawMap (HeroPosX, HeroPosY, GameMap, sizeMap, lives, leaving);

    while (!isGameOver) {
        cin >> Input;

        switch (Input) {
            case 'A':
            case 'a':
                if (HeroPosX == 0) {
                    leaving = true;
                    lives--;
                } else {
                    HeroPosX--;
                }
                break;
            case 'd':
            case 'D':
                if (HeroPosX == (sizeMap-1)) {
                    leaving = true;
                    lives--;
                } else {
                    HeroPosX++;
                }
                break;
            case 'w':
            case 'W':
                if (HeroPosY == 0) {
                    leaving = true;
                    lives--;
                } else {
                    HeroPosY--;
                }
                break;
            case 's':
            case 'S':
                if (HeroPosY == (sizeMap-1)) {
                    leaving = true;
                    lives--;
                } else {
                    HeroPosY++;
                }
                break;
            case 'c':
            case 'C':
                isGameOver = true;
            default:
                break;

        }
        DrawMap (HeroPosX, HeroPosY, GameMap, sizeMap, lives, leaving);
        if (lives <= 0) break;
        leaving = false;
    }
    cout << endl;
    cout << "----------GAME OVER----------" << endl;

    return 0;
}
#include <iostream>

using namespace std;

void DrawMap(int HeroPosx, int HeroPosy, char GameMap[5][5])
{
    int i, j;
    for(i = 0; i < 5; i++)
    {
        for(j=0; j<5; j++)
        {
            if(i != HeroPosy)
            {
                cout << GameMap[j][i];
            }else
            {
                if(j != HeroPosx)
                {
                    cout << GameMap[j][i];
                }else
                {                   
                cout << 'X';
                }
            }
        }  
        cout << endl;  
    }
}
int main()
{
    int HeroPosx = 2;
    int HeroPosy = 2;
    bool isGameOver = false;
    char input;
    char GameMap[5][5] = 
    {
        {'O','O','O','O','O'},
        {'O','O','O','O','O'},
        {'O','O','O','O','O'},
        {'O','O','O','O','O'},
        {'O','O','O','O','O'}
        
    };
    DrawMap(HeroPosx, HeroPosy, GameMap);

    while(isGameOver == false)
    {
        cin >> input;

        if(input == 'd'){
            HeroPosx++;
        }else if(input == 'a'){
            HeroPosx--;
        }else if(input == 'w'){
            HeroPosy--;
        }else if(input == 'x'){
            HeroPosy++;
        }else if(input == 'p'){
            isGameOver = true;
        }

        DrawMap(HeroPosx, HeroPosy, GameMap);
    }
    return 0;
}```

Solamente es añadir los nuevos botones 😃 ❤️

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX,int HeroPosY, char GameMap[5][5])
{
    for(int i= 0; i<5; i++)
    {
        for(int j = 0; j<5; j++)
        {
            if( i != HeroPosY)
            {
                cout<<GameMap[j][i];
            }
            else
            {
                if(j != HeroPosX)
                {
                    cout<<GameMap[j][i];
                }
                else
                {
                    cout<<'H';
                }
            }
        }
        cout<<endl;
    }
}


int main()
{
    int HeroPosX = 1;
    int HeroPosy = 1;
    bool isGameOver = false;
    char input = ' ';

    char GameMap[5][5] =
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };

    DrawMap(HeroPosX,HeroPosy,GameMap);

    while(isGameOver == false)
    {
        cin>> input;

        if( input == 'd')
        {
            HeroPosX++;
        }
        else if(input == 'a')
        {
            HeroPosX--;
        }
        else if(input == 'p')
        {
            isGameOver = true;
        }
        else if(input == 'w')
        {
            HeroPosy--;
        }
        else if(input == 'x')
        {
            HeroPosy++;
        }

        DrawMap(HeroPosX,HeroPosy,GameMap);
    }
    return 0;
}

void allo(int HeroPosX,int HeroPosY, char GameMap[5][5]){
for(int i=0;i<5;i++){
for(int p=0;p<5;p++){
if(p!=HeroPosX){
cout<<GameMap[p][i];
}else{
if (i!= HeroPosY){
cout<<GameMap[p][i];
}else{
cout<<‘H’;
}
}
}cout<<endl;
}
}
int main() {
int HeroPosX=0;
int HeroPosY=0;
bool isGameOver=false;
char Imput= ’ ‘;
char GameMap[5][5]={{’.’,’.’,’.’,’.’,’.’},{’.’,’.’,’.’,’.’,’.’},{’.’,’.’,’.’,’.’,’.’},{’.’,’.’,’.’,’.’,’.’},{’.’,’.’,’.’,’.’,’.’}};
allo(HeroPosX,HeroPosY,GameMap);
while(isGameOverfalse){
cin>>Imput;
if(Imput
’d’){
HeroPosX=HeroPosX+1;
}else if(Imput==‘a’){
HeroPosX=HeroPosX-1;
}else if(Imput==‘s’){
HeroPosY=HeroPosY+1;
}else if(Imput==‘w’){
HeroPosY=HeroPosY-1;
}else if (Imput==‘p’){
isGameOver=true;}
allo(HeroPosX,HeroPosY,GameMap);
}
return 0;
}

Lo puse en el anterior, va de nuevo 😉

#include <iostream>

using namespace std;

void dibujaMapa(int heroPosX, int heroPosY, char mapa[5][5])
{
    for(int i = 0; i < 5; i++)
    {
     for(int p = 0; p < 5; p++)
     {
      if (i != heroPosY)
      {
        cout << mapa[p][i];
      }
      else
      {
        if (p != heroPosX)
        {
          cout << mapa[p][i];
        }
        else
        {
          cout << 'H';
        }
      }
     }
     cout << endl;
    }
}

int main() {

    bool gameOver = false;
    char mov = ' ';
    int heroPosX = 1;
    int heroPosY = 1;
    char cont = ' ';
    char mapa[5][5] =
    {
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}
    };

    dibujaMapa(heroPosX, heroPosY, mapa);
    cout << "Elige movimiento (l, r, u, d, g): ";

    while(gameOver == false)
    {
        cin >> mov;
        if(mov == 'r' && heroPosX < 4)
        {
            heroPosX = heroPosX + 1;
        }
        else if(mov == 'l' && heroPosX > 0)
        {
            heroPosX = heroPosX - 1;
        }
        else if(mov == 'd' && heroPosY < 4)
        {
            heroPosY = heroPosY + 1;
        }
        else if(mov == 'u' && heroPosY > 0)
        {
            heroPosY = heroPosY - 1;
        }
        else if(mov == 'g')
        {
            gameOver = true;
            cout << "Game Over :(!";
            break;
        }
        else
        {
            cout << "Movimiento erroneo estas en el limite del mapa" << endl;
        }
        dibujaMapa(heroPosX, heroPosY, mapa);
    }
    return 0;
}

No es mucho pero es trabajo honesto : )

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX,int HeroPosY, char Gamemap[5][5]){
    for (int i = 0; i < 5 ; i++)
    {
        for(int j = 0; j<5;j++)
        {
            if (j != HeroPosX)
            {
                cout << Gamemap[j][i];
            }
            else
            {
                if(i != HeroPosY)
                {
                    cout << Gamemap[j][i];
                }else
                {
                    cout  << 'H';
                }
            }
        }
        cout << endl;
    }

}

int main()
{

    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' ';
    char Gamemap[5][5]=
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };

     DrawMap(HeroPosX,HeroPosY,Gamemap);

     while(isGameOver == false)
    {
        cin >> Input;

        if(Input == 'd'){
            HeroPosX +=1;
        }else if (Input == 'a'){
            HeroPosX -=1;
        }else if(Input == 'w')
        {
            HeroPosY -=1;
        }else if (Input == 's')
        {
            HeroPosY +=1;
        }else if(Input == 'p'){
            isGameOver = true;
        }
        DrawMap(HeroPosX,HeroPosY,Gamemap);
     }


    return 0;
}
#include<iostream>

using namespace std;

void drawMap(int herox,int heroy, char GameMap[5][5])
{
	for(int i=0; i<5;i++)
	{
		for(int p =0;p<5;p++){
   		if(heroy != i ){
 	  	cout<<GameMap[i][p];
	       	}
	   	else{if(herox !=p){
			cout<<GameMap[i][p];}
			else{cout<<'h';}
	       	}
			}
			cout<<endl;
		}

			}


int main(int argc, char *argv[])
{
    cout<<"mueve el heroe"<<endl<<"|a. izquierda| d. derecha| s. arriba| x. abajo|"<<endl;
	bool IsGameOver = false;
	int herox = 0 ;
	int heroy = 1;
	char temp = ' ';
	char GameMap[5][5]={
		 {'1','1','1','1','1'},
		 {'1','1','1','1','1'},
		 {'1','1','1','1','1'},
		 {'1','1','1','1','1'},
		 {'1','1','1','1','1'}
		};

	drawMap(herox, heroy,GameMap);

	while(IsGameOver == false)
	{
	cin >>temp;
	if(temp == 'd')
	{
		if(herox<4)
		{
		herox = herox+1;}
	}
	else if(temp == 'a')
	{   if(herox>0)
    	{herox = herox-1;}
	}


	else if(temp == 's')
		{	if(heroy>0)
		{heroy--;}
		}

	else if(temp == 'x')
		{	if(heroy<4)
			{heroy++;}
		}

	else if(temp== 'p')
	{IsGameOver = true;}


	drawMap(herox,heroy, GameMap);
	}


	return 0;
}```

No es muy elegante pero creo que va bien con el reto

#include <iostream>

using namespace std;

void DrawMap(char gameMap[5][5], int playerPosY, int playerPosX)
{
    for(int i = 0; i < 5; i++)
    {
        for(int p = 0; p < 5; p++)
        {
            if(i == playerPosY && p == playerPosX)
            {
                cout << 'H';
            }

            cout << gameMap[i][p];
        }

        cout << endl;
    }
}

int main()
{
    int playerPosY = 1;
    int playerPosX = 1;
    char input = ' ';

    char map[5][5] =
    {
        {'0','0','0','0','0'},
        {'0','0','0','0','0'},
        {'0','0','0','0','0'},
        {'0','0','0','0','0'},
        {'0','0','0','0','0'}
    };

    while(input != 'p')
    {
        cin >> input;

        if(input == 'd')
        {
            playerPosX++;
        }
        else if(input == 'a')
        {
            playerPosX--;
        }
        else if(input == 'w')
        {
            playerPosY --;
        }
        else if(input == 's')
        {
            playerPosY ++;
        }

        DrawMap(map, playerPosY, playerPosX);
    }
}

<#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
 for(int i = 0; i < 5; i++)
   {for (int p = 0; p < 5; p++)
        if (i != HeroPosY)
        cout << DrawMap[p][i];
        else
          if (p != HeroPosX)
          cout << DrawMap[p][i];
          else
            cout << 'H';
            cout << endl;
   }

}
int main()
{
    int HeroPosY = 1;
    int HeroPosX = 1;
    char Input = ' ';
    bool IsGameOver = false;
    char GameMap[5][5] =
    {
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1}
    };

    DrawMap(HeroPosX, HeroPosY, GameMap);

    while(IsGameOver == false)
    {
    cin >> Input;
    if(Input == 'd' && HeroPosX <=3)
        HeroPosX++;
    else if(Input == 'a' && HeroPosX >= 1)
        HeroPosX = HeroPosX - 1;
    else if(Input == 'w' && HeroPosY >= 1)
        HeroPosY = HeroPosY -1;
        else if(Input == 's' && HeroPosY<=3)
        HeroPosY++;
    else
        IsGameOver = true;
    DrawMap(HeroPosX, HeroPosY, GameMap);
    }
    return 0;
}
>

![](

Aquí mi solución con algo así como manejo de exceptions para los casos donde no debería ser posible el movimiento


#include <iostream>

using namespace std;

void llena(char mapa[5][5]){
    for (int i=0;i<5;i++){
        for (int j=0;j<5;j++){
            mapa[i][j] = '0';
        }
    }
}

void muestra(char mapa[5][5], int posx, int posy){
    for (int i=0;i<5;i++){
        for (int j=0;j<5;j++){
            if (i == posx && j == posy){
                cout << " " << 'H';
            }
            else{
                cout << " " << mapa[i][j];
            }
        }
        cout << endl;
    }
}


int main(int argc, const char * argv[]) {
    // insert code here...
    int posx = 0;
    int posy = 0;
    char mapa [5][5];
    char mov;
    llena(mapa);
    
    cout << "ingresa posicion en x: " << endl ;
    cin >> posx;
    cout << "ingresa posicion en y: " << endl ;
    cin >> posy;
    bool salir = false;
    
    while (!salir){
        muestra(mapa,posx,posy);
        cout << "Mover:" << endl;
        cout << "    U    " << endl;
        cout << "R       L" << endl;
        cout << "    D    " << endl;
        cout << "X -> Salir"<< endl;
        cin >> mov;
        switch (toupper(mov)) {
            case 'U':
                if(posx - 1 < 0){
                    cout << "movimiento no posible";
                }else{
                    posx --;
                }
                break;
            case 'D':
                if(posx + 1 >= 5){
                    cout << "movimiento no posible";
                }else{
                    posx ++;
                }
                break;
            case 'R':
                if(posy + 1 >= 5){
                    cout << "movimiento no posible";
                }else{
                    posy ++;
                }
                break;
            case 'L':
                if(posy - 1 < 0){
                    cout << "movimiento no posible";
                }else{
                    posy --;
                }
                break;
            case 'X':
                salir = true;
                break;
            default:
                cout << "movimiento no posible";
                break;
        }
        cout << endl;
    }

    return 0;
}
 if(Input== 'd')
        {
            HeroPosX=HeroPosX+1;
        }
        else if(Input =='a')
        {
            HeroPosX=HeroPosX-1;
        }
        else if(Input=='w')
        {
            HeroPosY = HeroPosY-1;
        }
        else if(Input == 's')
        {
            HeroPosY = HeroPosY+1;

        }else if(Input =='p')
        {
            GameOver = true;
        }
while (!isGameOver) {
        cin >> Input;
        if (Input == 'd') {
        HeroPosX = HeroPosX + 1;
        } else if (Input == 'a') {
            HeroPosX = HeroPosX - 1;
        } else if (Input == 'p') {
            isGameOver = true;
        } else if (Input == 'w') {
            HeroPosY -= 1;
        } else if (Input == 'c') {
            HeroPosY += 1;
        }

        DrawMap(HeroPosX, HeroPosY, GameMap);

    }

#include <iostream>
using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
	for (int i = 0; i < 5; i++)
	{
		for (int f = 0; f < 5; f++)
		{
			if (i != HeroPosY)
			{
				cout << GameMap[f][i];
			}
			else
			{
				if (f != HeroPosX)
				{
					cout << GameMap[f][i];
				}
				else
				{
					cout << 'H';
				}
			}
		}
		cout << endl;
	}

}

int main()
{
	int HeroPosX = 1;
	int HeroPosY = 1;
	bool isGameOver = false;
	char input = ' ';
	char GameMap[5][5] =
	{
		{'0','0','0','0','0'},
		{'0','0','0','0','0'},
		{'0','0','0','0','0'},
		{'0','0','0','0','0'},
		{'0','0','0','0','0'}
	};

	DrawMap(HeroPosX, HeroPosY, GameMap);

	while (isGameOver == false)
	{
		cin >> input;

		if (input == 'd')
		{
			HeroPosX = HeroPosX + 1;
		}

		else if (input == 'a')
		{
			HeroPosX = HeroPosX - 1;
		}

		else if (input == 'w')
		{
			HeroPosY = HeroPosY - 1;
		}

		else if (input == 's')
		{
			HeroPosY = HeroPosY + 1;
		}

		else if (input == 'p')
		{
			isGameOver = true;
		}

		DrawMap(HeroPosX, HeroPosY, GameMap);

		return 0;
	}
#include <iostream>
using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[][5])
{
    for(int i = 0; i < 5; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            if(i == HeroPosX && j == HeroPosY)
            {
                cout << "H";
            }
            else
            {
                cout << GameMap[i][j];
            } 
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' ';

    char GameMap[5][5] = 
    {  
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}
    };

    DrawMap(HeroPosX, HeroPosY, GameMap);
    cout << "Usa las teclas w (arriba), a (izquierda), d (derecha) y s (abajo)." << endl;
    cout << "Para salir, presiona p." << endl;
    while(isGameOver == false)
    {
        cin >> Input;
        
        switch (Input)
        {
            case 'd':
                if(HeroPosY < 4)
                    HeroPosY++;
                break;
            case 'a':
                if(HeroPosY > 0)
                    HeroPosY--;
                break;
            case 'w':
                if(HeroPosX > 0)
                    HeroPosX--;
                break;
            case 's':
                if(HeroPosX < 4)
                    HeroPosX++;
                break;
            case 'p':
                isGameOver = true;
                break;
            default:
                cout << "Opcion Invalida" << endl;
                break;
        }
        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}
<code>
#include <iostream>

using namespace std;
void draw_Map(int heroPosX, int heroPosY,char GameMap[5][5])
{
    for (int y=0;y<5;y++)
    {
        for(int x=0;x<5;x++)
        {
            if (x==heroPosX && y==heroPosY)
            {
                cout << '#';
            }else
            {
                cout << GameMap[y][x];
            }
        }
        cout << endl;
    }
}
int main()
{
    char driveGame = ' ';
    char GameMap[5][5]={{'.','.','.','.','.'},
                        {'.','.','.','.','.'},
                        {'.','.','.','.','.'},
                        {'.','.','.','.','.'},
                        {'.','.','.','.','.'}};

    int heroPosX = 2, heroPosY = 1;
    bool isGameOver = false;
    do
    {
        draw_Map(heroPosX, heroPosY,GameMap);
        cin >> driveGame;
        switch (driveGame)
        {
            case 'd':
            case 'D':
                heroPosX++;
                if (heroPosX>4)
                    heroPosX=4;
                break;

            case 'a':
            case 'A':
                heroPosX--;
                if (heroPosX<0)
                    heroPosX=0;
                break;
            case 'w':
            case 'W':
                heroPosY--;
                if (heroPosY<0)
                    heroPosY=0;
                break;
            case 's':
            case 'S':
                heroPosY++;
                if (heroPosY>4)
                    heroPosY=4;
                break;
            default:
                isGameOver=true;
                break;
        }
    }while(!isGameOver);
    return 0;
}
#include <iostream>

using namespace std;

void DrawMap(int HeroPosY, int HeroPosX, char GameMap[5][5])
{
    for(int Y = 0; Y < 5; Y++)
    {
        for (int X = 0; X < 5; X++)
        {
            if(Y != HeroPosY)
            {
                cout << GameMap[Y][X];
            }else
            {
                if(X != HeroPosX)
                {
                    cout << GameMap[Y][X];
                }else
                {
                   cout << 'H';
                }

            }
        }
        cout << endl;
    }

}

int main()
{
    int HeroPosY = 2;
    int HeroPosX = 2;
    char GameMap[5][5] =
    {
     {'1','1', '1', '1', '1'},
     {'1','1', '1', '1', '1'},
     {'1','1', '1', '1', '1'},
     {'1','1', '1', '1', '1'},
     {'1','1', '1', '1', '1'}
    };

    char Input = ' ';
    bool IsGameOver = false;

    DrawMap(HeroPosY, HeroPosX, GameMap);

    while(IsGameOver == false)
    {
            cin >> Input;

        if(Input == 'd')
        {
            HeroPosX++;
        }
        else if(Input == 'a')
        {
            HeroPosX--;
        }
        else if(Input == 'w')
        {
            HeroPosY--;
        }
        else if(Input == 's')
        {
            HeroPosY++;
        }
        else if (Input == 'p')
        {
            IsGameOver = true;
        }

        DrawMap(HeroPosY, HeroPosX, GameMap);
    }




    return 0;
}```

hola, dejo mi programa, impde que el heroe se salga del tablero y el tamaño del arreglo puede ser variable, conservando las mismas medidas de lineas y columnas.

#include <iostream>
using namespace std;
void DrawMap (int MapExt)
{
//inicializar mapa con unos
char Map [MapExt] [MapExt];
int PosX = 0;
int PosY = 0;
char m;
bool GameOver = true;
cout << " arriba w"<< endl;
cout << " abajo z"<< endl;
cout << " derecha s"<< endl;
cout << " izquierda a"<< endl;
cout << " salir p"<< endl;
while (GameOver == true)
{

    for (int i = 0;i < MapExt; i++ )
    {
        for (int p = 0;p < MapExt; p++)
        {
            Map [i][p] = '1';
            if (i==PosY && p==PosX)
                Map [i] [p] = 'H';
            cout << Map [i][p];
        }
    cout << endl;
    }
cin >> m;
            if (m=='p')
            GameOver = false;
            //arriba
            if (m=='w')
            {
                if (PosY==0)
                    PosY=MapExt-1;
                else
                PosY--;
            }
            //abajo
            if (m=='z')
            {
                if  (PosY==MapExt-1)
                    PosY=0;
                else
                PosY++;
            }
            //derecha
            if (m=='s')
             {
                 if (PosX==MapExt-1)
                    PosX=0;
                 else
                 PosX++;
             }
            //izquierda
            if (m=='a')
            {
                if (PosX==0)
                    PosX=MapExt-1;
                else
                PosX--;
            }
}

}

int main()
{
int MapExt = 0;
cout <<“Mapa del Laberinto 1” << endl;
cout << “De cuantas filas sera el laberinto?” << endl;
cin >> MapExt;
DrawMap (MapExt);
return 0;
}

#include <iostream>

using namespace std;

void DrawMap (int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for(int i = 0; i < 5; i++)
    {
        for(int p = 0; p < 5; p++)
        {
                if (i != HeroPosY)
                {
                    cout<<GameMap[p][i];
                }else
                {
                if (p != HeroPosX)
                {
                    cout<<GameMap[p][i];
                }else
                {
                    cout<<'H';
                }

                }
        }
        cout<<endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' ';
    char GameMap[5][5] =
    {
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}
    } ;

    DrawMap(HeroPosX, HeroPosY,GameMap);

    while (isGameOver == false)
    {
         cin>>Input;
        if (Input == 'd')
        {
            HeroPosX = HeroPosX + 1;
        }else
        if (Input == 'a')
        {
            HeroPosX = HeroPosX - 1;
        }else
        if (Input == 'p')
        {
            isGameOver = true;
        }else
        if (Input == 'x')
        {
            HeroPosY = HeroPosY + 1;
        }else
        if (Input == 'w')
        {
            HeroPosY = HeroPosY - 1;
        }

        DrawMap(HeroPosX, HeroPosY,GameMap);
    }


    return 0;
}```

Optimicé el código ya que me parecía que un programa imprimiendo todo el tiempo el mapa precisa de más procesos. Qué hice? Dibujé el mapa aparte para que solo se requiera imprimir una vez y listo. El héroe borra su posicion anterior y se dibuja dependiendo de si pulsaste W, A, S o D usando coordenadas X y Y gracias a una instrucción de la libreria windows.h, que hace que el cursor se mueva hacia cualquier parte de la consola que yo le especifique. Para que no se salga de los bordes ni la H rompa los 0, que son las paredes, le especifiqué que si la siguiente casilla es 0 (columna 1 o fila 1), o es 9 (columna nueve o fila nueve, ya que mi mapa es 10x10), el personaje se volverá a dibujar en la misma casilla y no se moverá de allí.

#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>

using namespace std;

void gotoxy(int HeroPosX, int HeroPosY){            
      HANDLE hcon;
      hcon = GetStdHandle(STD_OUTPUT_HANDLE);
      COORD dwPos;
      dwPos.X = HeroPosX;
      dwPos.Y= HeroPosY;
      SetConsoleCursorPosition(hcon,dwPos);

        }


void DibujaMapa (char GameMap [10][10]) {

for (int i = 0; i < 10; i++){

            for (int j = 0; j < 10; j++){


                cout << GameMap[i][j];

               }

            cout<<endl;
               }

            }



int main()
{
    int HeroPosX = 4;
    int HeroPosY = 4;
    char input;

    bool gameOver = false;
    char control;
    char GameMap[10][10] = {
                    {'0','0','0','0','0','0','0','0','0','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0',' ',' ',' ',' ',' ',' ',' ',' ','0'},
                    {'0','0','0','0','0','0','0','0','0','0'}
                    };

    DibujaMapa (GameMap);
    gotoxy(HeroPosX, HeroPosY);
    cout<<"H";


    while (gameOver == false){

    gotoxy(4, 14);

    cin>> control;

    if (control == 'a' || control == 's' || control == 'd' || control == 'w'){


    switch(control){

    case 'w':

        if (HeroPosY - 1 == 0){

        gotoxy(HeroPosX, HeroPosY);
        cout<<"H";

        }else {

        gotoxy(HeroPosX, HeroPosY);
        cout<<" ";

        HeroPosY--;
        gotoxy(HeroPosX, HeroPosY);
        cout<<"H"; }

        break;


    case 'a':

        if (HeroPosX - 1 == 0){

        gotoxy(HeroPosX, HeroPosY);
        cout<<"H";

        }else {


        gotoxy(HeroPosX, HeroPosY);
        cout<<" ";

        HeroPosX--;
        gotoxy(HeroPosX, HeroPosY);
        cout<<"H"; }

    break;

    case 's':


        if (HeroPosY + 1 == 9){

        gotoxy(HeroPosX, HeroPosY);
        cout<<"H";

        }else {

        gotoxy(HeroPosX, HeroPosY);
        cout<<" ";

        HeroPosY++;
        gotoxy(HeroPosX, HeroPosY);
        cout<<"H"; }

    break;

    case 'd':


        if (HeroPosX + 1 == 9){

        gotoxy(HeroPosX, HeroPosY);
        cout<<"H";

        }else {

        gotoxy(HeroPosX, HeroPosY);
        cout<<" ";

        HeroPosX++;
        gotoxy(HeroPosX, HeroPosY);
        cout<<"H"; }

    break;

    case 'p':

        gameOver = true;

    break;

    default:
    break;

    }

    }


                             }




}


#include <iostream>

using namespace std;

void DrawMap (int HeroPosX, int HeroPosY, char map[5][5])
{
for(int i = 0; i<5;i++){
for(int p =0;p<5;p++){
if(i != HeroPosY){
cout<<map[p][i];
}else{
if(p != HeroPosX){
cout<<map[p][i];
}else{
cout<<‘x’;
}
}
}

	cout<<endl;
	
}

}

int main(){
int HeroPosX = 2;//Este numero es la posicion de nuestro personaje
int HeroPosY = 2;
char input= ’ ';
bool isGameOver = false;
char map[5][5] = {
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’}
};

while(isGameOver == false){
	DrawMap(HeroPosX,HeroPosY,map);
	cin>>input;

if(input=='d'){
	HeroPosX++;
}else if(input=='a'){
	HeroPosX--;
}else if(input=='w'){
	HeroPosY--;
}else if(input=='s'){
	HeroPosY++;
}else if(input='p'){
	isGameOver= true;
}
 

	
}




return 0;

}

#include <iostream>
#include <stdlib.h>

using namespace std;


void DramMap(int Heroposx, int Heroposy, char map[5][5])
{

     for(int i=0; i<5; i++)
   {
       for(int a=0; a<5; a++)
       {
        if(i !=Heroposy)
        {
            cout<<map[a][i];
        }
        else
        {
             if(a !=Heroposx)
            {
            cout<<map[a][i];
            }
            else
            {
                cout<<'H';
            }
        }
       }
    cout<<endl;
   }

}

int main()
{

    int Heroposx=1;
    int Heroposy=1;
    bool gameisover=false;
    char Input=' ';
    char map[5][5]=
    {
          {'1','1','1','1','1'},
          {'1','1','1','1','1'},
          {'1','1','1','1','1'},
          {'1','1','1','1','1'},
          {'1','1','1','1','1'},
    };

    DramMap(Heroposx, Heroposy, map);

    while(gameisover==false)
    {
     cin>>Input;

        if(Input=='d')
        {
            Heroposx++;
        }
        else if(Input=='a')
        {
            Heroposx--;
        }
         else if(Input=='s')
        {
            Heroposy--;
        }
         else if(Input=='w')
        {
            Heroposy++;
        }
        else if(Input=='p')
        {
            gameisover=true;
        }

    DramMap(Heroposx, Heroposy, map);

    }




return 0;
}

Acá está mi tarea del Reto 3:

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
for (int i =0; i< 5 ; i++)
{
for (int p= 0; p < 5; p++)
{
if (i!= HeroPosY)
{

			cout<< GameMap[i][p];
		}
		else 
		{
			if (p!= HeroPosX)
			{
				cout<< GameMap[i][p];	
			}
			else
			{
				cout<< 'H';		
			}
		}
	}
	cout<<endl;
	
}	

}

int main ()
{
char GameMap[5] [5] =
{

{'1','1','1','1','1'},
{'1','1','1','1','1'},
{'1','1','1','1','1'},
{'1','1','1','1','1'},
{'1','1','1','1','1'},
};
int HeroPosX = 1;
int HeroPosY = 1;
char Input = ' ';
bool isGameOver = false;



while (isGameOver==false)
{
	DrawMap(HeroPosX, HeroPosY,GameMap);
	cin>>Input;
	
	if(Input =='d')
	{
		HeroPosX = HeroPosX + 1;
	}
	else if (Input=='a')
	{
		HeroPosX = HeroPosX - 1;
	}
	else if(Input == 'w')
	{
		HeroPosY = HeroPosY - 1;
	}
	else if(Input == 'x')
	{
		HeroPosY = HeroPosY + 1;
	}
	else if (Input == 'p')
	{
		isGameOver= true;
	}
	system("cls");	
}


return 0;

}

Aqui esta mi reto! Tambien aplique lo del reto de la clase pasada, no se puede salir del mapa.

#include <iostream>

using namespace std;

void printMap (int heroPosX, int heroPosY, char gameMap[5][5]) {

    for (int i = 0; i < 5; i++) {

        for (int j = 0; j < 5; j++) {

            if (i != heroPosX) {

                cout << gameMap[j][i];

            } else if (j != heroPosY) {

                cout << gameMap[j][i];

            } else {

                cout << 'H';

            } // fin if

        } // fin for j

        cout << endl;

    } // fin for i



} // funcion


int main()
{
    int heroPosX = 1;
    int heroPosY = 1;

    bool isGameOver = false;
    char Input = ' ';

    char GameMap[5][5] = {

        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}

    };


    printMap(heroPosX, heroPosY, GameMap);

    while (isGameOver == false){

        cin >> Input;

        if (Input == 'd') {

            if (heroPosX != 4) {

                heroPosX++;

            }

        } else if (Input == 'a') {

            if (heroPosX != 0) {

                heroPosX--;

            }

        } else if (Input == 'l') {

            if (heroPosY != 0) {

                heroPosY--;

            }

        } else if (Input == 'r') {

            if (heroPosY != 4) {

                heroPosY++;

            }

        } else if (Input == 'p') {

            isGameOver = true;

        }

        printMap(heroPosX, heroPosY, GameMap);

    }

    return 0;
}
#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (i !=HeroPosY)
            {
                cout << GameMap[i][j];
            }else
            {
                if (j != HeroPosX)
                {
                    cout << GameMap[i][j];
                }else
                {
                    cout << 'H';
                }
                
            }
        }
        cout << endl;
    }
}



int main(int argc, char const *argv[])
{
    int HeroPosX = 2;
    int HeroPosY = 0;
    bool isGameOver = false;
    char input = ' ';
    char GameMap[5][5] = {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };

    DrawMap(HeroPosX, HeroPosY, GameMap);

   

    while (isGameOver == false)
    {

        cin >> input;
        if (input == 'd')
        {
            HeroPosX++;
        }
        else if (input == 'a')
        {
            HeroPosX--;
        }
        else if (input == 'w')
        {
            HeroPosY--;
        }
        else if (input == 's')
        {
            HeroPosY++;
        }
        else
        {
            isGameOver = true;
        }
        
        DrawMap(HeroPosX, HeroPosY, GameMap);
    }
    

    cout << endl;
    return 0;
}

Me está costando un poco pero voy mejorando jejeje.

#include <iostream>
// libreria de funciones y comandos

using namespace std;
// funcion cin, cout, etc.
// de lo contrario hay que poner std::cout

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{

    for(int i=0;i<5;i++) //siempre y cuando i sea menor a 5, y despues de cada vuelta, sumar 1
    {//columnas
        for(int j=0; j<5;j++)
        {//filas
           if(i != HeroPosY) //si i no es igual a la posicion del heroe, dibuje mapa
            {
                cout << GameMap[j][i];
            }else
            {
                if(j != HeroPosX)
                {
                    cout << GameMap[j][i];
                }else
                {
                     cout<<'H';
                }

            }
        }
        cout<<endl;// debido a que aca terminan las filas
    }



}

int main() //funcion principal.
{
    int HeroPosX = 0;
    int HeroPosY = 0;
    bool isGameOver = false;
    char Input =' '; //valor a ingresar por el usuario
    char GameMap[5][5] = {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
        };

    DrawMap(HeroPosX,HeroPosY,GameMap);

    while(isGameOver == false)
    {
    cin>> Input;

    if(Input == 'd') // si el usuario presiona d, la pos del hero es = a si misma +1
    {

        HeroPosX++;


    }else if(Input == 'a')
    {

        HeroPosX--;


    }else if(Input == 's')
    {

        HeroPosY++;


    }else if(Input == 'w')
    {

        HeroPosY--;


    }
    else if(Input == 'p')
    {
        isGameOver = true;
    }

    DrawMap(HeroPosX,HeroPosY,GameMap);
    }






    return 0;
}

Decidí cambiarlo por switch, saludos.

RETO CUMPLIDO 😄
(Solo se agregan los controles del HeroPosY)

#include <iostream>
#include <stdlib.h>

using namespace std;

//DIBUJAR MAPA
void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5]){
    system("cls");
    for (int i = 0; i < 5; i++){
        for (int p = 0; p < 5; p++){
            if (i != HeroPosY){
                cout << GameMap[i][p];
                cout << ' ';
            } else {
                if (p != HeroPosX){
                    cout << GameMap[i][p];
                    cout << ' ';
                } else {
                    cout << 'H';
                    cout << ' ';
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    //POSICIONES DEL HEROE
    int HeroPosX = 0;
    int HeroPosY = 0;

    char Input;
    bool isGameOver = false;

    char GameMap[5][5] =
    {
        {'0','0','0','0','0'},
        {'0','0','0','0','0'},
        {'0','0','0','0','0'},
        {'0','0','0','0','0'},
        {'0','0','0','0','0'}
    };

    DrawMap(HeroPosX, HeroPosY, GameMap);

    while (isGameOver == false){
        cin >> Input;

        if (Input == 'd'){
            HeroPosX++;
        } else if (Input == 'a'){
            HeroPosX--;
        } else if (Input == 'w'){
            HeroPosY--;
        } else if (Input == 's'){
            HeroPosY++;
        } else if (Input == 'p'){
            isGameOver = true;
        }

        DrawMap(HeroPosX, HeroPosY, GameMap);
    }



    return 0;
}

#include <iostream>

using namespace std;

void dibujodemapa(int posicionheroex,int posicionheroey, char map[5][5] )
{
    for(int i = 0; i<5; i++)
    {
        for(int f = 0; f<5; f++)
        {
                if(i != posicionheroey)
            {
                cout<<map[f][i];
            }
                else
                {
                    if(f != posicionheroex)
                    {
                        cout<<map[f][i];
                    }
                    else
                    {
                        cout<<'H';
                    }
        
                }
        }
        cout<<endl;
    }
}
int main()
{
    int posicionheroex = 2;
    int posicionheroey = 2;
    bool gameover = false;
    char input = ' ';
    
    char map[5][5]=
    {
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
    };
    
    dibujodemapa(posicionheroex,posicionheroey,map);
    
    while(gameover == false)
    {
        cin>>input;
        
        if(input == 'd')
        {
            posicionheroex = posicionheroex + 1;
        }
        else if(input == 'a')
        {
            posicionheroex = posicionheroex -1;
        }
        else if(input == 'w')
        {
            posicionheroey = posicionheroey -1;
        }
        else if(input == 's')
        {
            posicionheroey = posicionheroey +1;
        }
        else if(input == 'p')
        {
            gameover = true;
        }
        
        dibujodemapa(posicionheroex,posicionheroey,map);
    }
    
    return 0;
}

Además de agregar la “W y S” para controlar la posición en Y del personaje, cargué otra librería para hacer uso de system (“CLS”) y de esta manera refrescar la pantalla antes de redibujar el mapa y el personaje… como para mejorar la experiencia del jugador. Esto googleando un poco.

#include <iostream>
#include <stdlib.h>

using namespace std;

void DrawMap (int HeroPosX, int HeroPosY, char WorldMap [5][5])
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (i != HeroPosY)
            {
                cout << WorldMap [j][i];
            }
            else
            {
                if (j != HeroPosX)
                {
                    cout << WorldMap [j][i];
                }
                else
                {
                    cout << 'H';
                }

            }
        }

        cout << endl;

    }
}

int main()
{
    bool IsGameOver = false;
    char UserInput = ' ';
    char HeroPosX = 0;
    char HeroPosY = 0;
    char WorldMap [5][5] =
    {
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'},
        {'.', '.', '.', '.', '.'}
    };

    DrawMap(HeroPosX, HeroPosY, WorldMap);

    while (IsGameOver == false)
    {
         cin >> UserInput;

        if (UserInput == 'd')
        {
            HeroPosX += 1;
        }
        else if (UserInput == 'a')
        {
            HeroPosX -= 1;
        }
        else if (UserInput == 'w')
        {
            HeroPosY -= 1;
        }
        else if (UserInput == 's')
        {
            HeroPosY += 1;
        }
        else if (UserInput == 'p')
        {
            IsGameOver = true;
        }

        system("CLS");
        DrawMap(HeroPosX, HeroPosY, WorldMap);
    }


    return 0;
}

![](
![](
![](

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX,int HeroPosy, char GameMap[5][5]);

int main()
{
    int HeroPosX=1;
    int HeroPosY=1;
    bool isGameOver=false;
    char Input=' ';
    char GameMap[5][5];
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            GameMap[i][j]='1';
        }
    }

    DrawMap(HeroPosX,HeroPosY,GameMap);

    while(isGameOver==false){
        cin>>Input;

        if(Input=='d'){
            HeroPosX++;
        }
        else if(Input=='a'){
            HeroPosX--;
        }
        else if(Input=='w'){
            HeroPosY--;
        }
        else if(Input=='s'){
            HeroPosY++;
        }
        else if(Input== 'p'){
            isGameOver=true;
        }
        DrawMap(HeroPosX,HeroPosY,GameMap);
    }
    return 0;
}

void DrawMap(int HeroPosX,int HeroPosY, char GameMap[5][5]){
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            if(i!= HeroPosY){
                cout<<GameMap[j][i];
            }
            else{
                if(j!=HeroPosX){
                    cout<<GameMap[j][i];
                }
                else{
                    cout<<'H';
                }
            }
        }
        cout<<endl;
    }
}

Hola, este es mi código

#include <iostream>

using namespace std;

void DrawMap (int HeroPosX, int HeroPosY, char GameMap [5][5]){
    for (int i = 0; i < 5; i++){
            for (int p = 0; p < 5; p++){
                if (i != HeroPosX){
                    cout << GameMap[p][i];
                }
                else {
                    if (p != HeroPosY)
                    {
                        cout << GameMap[p][i];

                    }else
                    {
                        cout << 'H';
                    }
                }

            }
            cout << endl;
    }
}

int main(){
    char Input = ' ';
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;

    char GameMap [5][5]=
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
    };

    DrawMap (HeroPosX, HeroPosY, GameMap);

    while (isGameOver == false){
        cin >> Input;

        if (Input == 'd'){
            HeroPosY = HeroPosY + 1;
        }else if (Input == 'a'){
            HeroPosY = HeroPosY -1;
        } else if (Input == 'w'){
            HeroPosX = HeroPosX - 1;
        }else if (Input == 's')
        {
           HeroPosX = HeroPosX + 1;
        } else if (Input == 'p'){
            isGameOver = true;
        }
        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}```

Reto Cumplido 😃

#include <iostream>
using namespace std;


void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
  for (int i = 0; i < 5; i++)
  {
    for (int j = 0; j < 5; j++)
    {
      if (i != HeroPosY)
      {
        cout << GameMap[j][i];
      }else
      {
        if (j != HeroPosX)
        {
          cout << GameMap[j][i];
        }else
        {
          cout << "H";
        }
      }
    }
    cout << endl;
        
  }
    
}

int main()
{
  int HeroPosX = 1;
  int HeroPosY = 1;
  bool IsGameOver = false;
  char Input = ' ';
  char GameMap[5][5] = 
  {
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
  };

  DrawMap(HeroPosX,HeroPosY,GameMap);

  while (IsGameOver == false)
  {
    cin >> Input;

    if (Input == 'd')
    {
      HeroPosX ++;
    }
    else if (Input == 'a')
    {
      HeroPosX --;
    }
    else if (Input == 'w')
    {
      HeroPosY --;
    }
    else if (Input == 's')
    {
      HeroPosY ++;
    }
    else if (Input == 'p')
    {
      IsGameOver = true;
    }
    

    DrawMap(HeroPosX,HeroPosY,GameMap);
  }
  

  return 0;
}```

este es mi codigo

#include <iostream>

using namespace std;
void DrawMap (int HeroPosX,int HeroPosY,char GameMap[5][5]){
    for (int i = 0; i < 5; i++){
            for (int j = 0; j<5; j++){
                  if (j != HeroPosX){
                cout << GameMap[i][j] ;
            }
            else {
                cout << 'H';
            }
              if (i != HeroPosY){
                cout << GameMap[i][j] ;
            }
            else {
                cout << 'H';
            }

        }
        cout<<endl;
    }

}
int main()
{
    int HeroPosX = 2;
    int HeroPosY = 2;
    bool GameOver = false;
    char input = ' ';
    char GameMap [5][5] = {
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
    };

    DrawMap(HeroPosX,HeroPosY,GameMap);
        while (GameOver == false){
            cin >> input;
            if (input == 'd'){
             HeroPosX++;
            DrawMap(HeroPosX, HeroPosY, GameMap);
            }
            else if (input == 'a'){
                HeroPosX--;
                DrawMap(HeroPosX, HeroPosY, GameMap);
            }
            else if (input == 'w'){
                HeroPosY++;
                DrawMap(HeroPosX, HeroPosY, GameMap);
            }
            else if (input == 's'){
                HeroPosY--;
                DrawMap(HeroPosX, HeroPosY, GameMap);
            }
            else if (input == 'p'){
                GameOver = true;
            }

        }

        return 0;
}
#include <iostream>

using namespace std;

void drawMap(char gameMap[5][5], int heroPosX, int heroPosY, string hero) {
    for (int i = 0; i < 5; i++) {

        for (int p = 0; p < 5; p++) {
            if(i != heroPosY)
                cout << gameMap[p][i];
            else
                if (p != heroPosX)
                    cout << gameMap[p][i];
                else
                    cout << hero;
        }

        cout << endl;
    }
}

int main()
{

    int heroPositionX = 0;
    int heroPositionY = 0;
    string hero = "P";
    bool gameOver = false;

    char mapa[5][5] =
    {
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}
    };

    char input = ' ';

    //draw map
    drawMap(mapa, heroPositionX, heroPositionY, hero);

    while (!gameOver) {
        cin >> input;

        switch (input) {
            case 'd':
                heroPositionX++;
                break;
            case 'a':
                heroPositionX--;
                break;
            case 'w':
                heroPositionY--;
                break;
            case 's':
                heroPositionY++;
                break;
        }

        drawMap(mapa, heroPositionX, heroPositionY, hero);
    }

    return 0;
}

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX,int HeroPosY, char GameMap[5][10])
{
    for(int filas = 0; filas < 5; filas = filas + 1)
    {
        for(int columnas = 0; columnas < 10; columnas = columnas + 1)
        {
            if(columnas != HeroPosX)
            {
                cout << GameMap[filas][columnas];
            }
            else
            {
                if(filas != HeroPosY)
                {
                    cout << GameMap[filas][columnas];
                }
                else
                {
                    cout << 'H';
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 1;
    int HeroPosY = 1;
    bool isGameOver = false;
    char Input = ' ';

    char GameMap[5][10] =
    {
        {'~','~','~','~','~','~','~','~','~','~'},
        {'~','~','~','~','~','~','~','~','~','~'},
        {'~','~','~','~','~','~','~','~','~','~'},
        {'~','~','~','~','~','~','~','~','~','~'},
        {'~','~','~','~','~','~','~','~','~','~'}
    };


    DrawMap(HeroPosX, HeroPosY, GameMap);

    while(isGameOver == false)
    {
        cin >> Input;

        switch (Input)
        {
        case 'w':
            HeroPosY = HeroPosY - 1;
        break;

        case 'a':
            HeroPosX = HeroPosX - 1;
        break;

        case 's':
            HeroPosY = HeroPosY + 1;
        break;

        case 'd':
            HeroPosX = HeroPosX + 1;
        break;

        case 'p':
            isGameOver = true;
        break;
        }

        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}





#include <iostream>

using namespace std;

void Draw(int JuanBoss, int JuanBossY, char mapa[5][5])
{
for(int i=0;i<5;i++)
{
for(int c =0; c<5;c++){
if(i!=JuanBossY)
{
cout<< mapa[c][i];
}else
{
if(c!=JuanBoss)
{
cout<< mapa[c][i];
}else
cout<< ‘H’;
}

} cout<< endl;
}

}

int main()
{

int JuanBoss=0;
int JuanBossY=0;
char input=' ';
bool GameOver= false;
char mapa[5][5]={
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
};


Draw(JuanBoss,JuanBossY,mapa);
while(GameOver==false){
    cin >> input;

    if (input=='d')
    {
        JuanBoss= JuanBoss+1;
    }
    else if ( input=='a')
    {
        JuanBoss=JuanBoss-1;
    }
    else if ( input=='s')
    {
        JuanBossY=JuanBossY+1;
    }
    else if ( input=='w')
    {
        JuanBossY=JuanBossY-1;
    }
    else if ( input=='p')
    {
        GameOver= true;
    }
    Draw(JuanBoss,JuanBossY,mapa);
}

return 0;

}

<#include <iostream>

using namespace std;


void mapeo(int personajeX,int personajeY, char map[20][20])
{
    for (int i = 0; i < 20; i=i+1)
    {
        for (int p=0; p < 20; p=p+1)
        {
            if( i !=personajeY)
            {
                cout << map[p][i];
            }else
            {
            if( p !=personajeX)
                {
                 cout << map[p][i];
                }else
                {
                 cout << 'O';
                }
            }
        }
        cout << endl;
    }
}

int main()
{

    int personajeX = 1;
    int personajeY = 1;
    int personajeU = 1;
    int personajeB = 1;
    bool gameOver= false;
    char input = ' ';
    char map[20][20]=
    {
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'},
        {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'}
    };


    mapeo(personajeX,personajeY,map);

    while(gameOver==false)
    {
        cin >> input;

        if (input == 'd')
        {
            personajeX=personajeX+1;
        }
        else if (input=='a')
        {
            personajeX=personajeX-1;
        }
        else if (input =='w')
        {
              personajeY=personajeY-1;
        }
        else if (input =='s')
        {
              personajeY=personajeY+1;
        }
         else if (input='p')
        {
            gameOver= true;
        }

        mapeo(personajeX, personajeY,map);
    }

    return 0;
}
>

Saludos, reto completado en mapa de 5 x 5, validando que se presionen solo las teclas indicadas, y evitando que el jugador salga del mapa establecido. Uso del comando clear y la función sleep() para que solo aparezca un mapa y se puedan leer los mensajes.

#include <iostream>
#include <stdlib.h>
#include <unistd.h>

void MapWarning()
{
  std::cout << "Estas saliendo del mapa y te puedes perder\n" << std::endl;
  sleep(2);
}

void InvalidKey()
{
  std::cout << "Tecla invalida, intenta nuevamente\n";
  sleep(2);
}

void Abandon()
{
  std::cout << "\nHas decidido abandonar el juego.\n";
  sleep(2);
}

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
  for(int i=0; i < 5; i++)
  {
    for(int j=0; j < 5; j++)
    {
      if(i != HeroPosY)
      {
        std::cout << GameMap[j][i];
      }
      else
      {
        if(j!=HeroPosX)
        {
          std::cout << GameMap[j][i];
        }
        else
        {
          std::cout << 'H';
        }
      }
    }
    std::cout << std::endl;
  }
}

int main() 
{
  int HeroPosX = 0;
  int HeroPosY = 0;
  bool IsGameOver = false;
  char Input = ' ';
  char GameMap [5][5] = 
  {
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
  };  

  DrawMap(HeroPosX, HeroPosY, GameMap);
  std::cout << "\nHola! Para mover tu avatar, usa las teclas: \n\n a - izquierda \n d - derecha \n w - arriba \n s - abajo \n p - para salir\n\n No te salgas del mapa!\n:";

  while(IsGameOver == false)
  {
    std::cin >> Input;

    switch(Input)
    {
      case 'd':
        if(HeroPosX < 4)
          HeroPosX++;
        else
          MapWarning();
        break;
      case 'a':
        if(HeroPosX > 0)
          HeroPosX--;
        else
          MapWarning();  
        break;
      case 's':
        if(HeroPosY < 4)
          HeroPosY++;
        else
          MapWarning();  
        break;
      case 'w':
        if(HeroPosY >0)
          HeroPosY--;
        else
          MapWarning();  
        break;
      case 'p':
        IsGameOver = true;
        Abandon();
        break;
      default:
        InvalidKey();    
    }

    system("clear");
    DrawMap(HeroPosX, HeroPosY, GameMap);
  }
}

En esta liga funciona.

#include <iostream>

using namespace std;

void DrawMap(int heroposx, int heroposy , char gamemap[5][5])
{
for(int i=0; i<5; i++){
for(int p=0; p<5;p++){

    if(i != heroposy){
    cout<<gamemap[p][i];
    }else{
     if(p != heroposx) {
        cout<<gamemap[p][i];
     }  else{
        cout<<'h';
     }

    }
}

cout << endl;

}

}
int main()
{
int heroposx =1;
int heroposy =1;
bool isGameOver = false;
char input ;

char gamemap [5][5] =
{
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
};

DrawMap(heroposx,heroposy, gamemap);
while(isGameOver==false){


cin >> input;

if (input == 'd'){

    heroposx = heroposx+1;
}else if(input=='a'){
    heroposx=heroposx-1;
}else if(input=='w'){
    heroposy=heroposy-1;
}else if(input=='s'){
    heroposy=heroposy+1;
}
else if(input=='p'){
    isGameOver = true;
}

DrawMap(heroposx, heroposy, gamemap);

else if(input==‘a’){
heroposx=heroposx-1;
}
}

return 0;
}

listo

#include <iostream>
using namespace std;
void drawmap(int heroposX,int heroposY, char gamemap[5][5] )
{
for (int i =0; i<5; i++)
    {
        for(int p=0; p<5; p++)
        {
            if(i !=heroposY)
        {
            cout<<gamemap[p][i];
        }else
        {
            if(p != heroposX)
            {
                cout<<gamemap[p][i];
            }else
            {
                cout<<'H';
            }
        }
        }
        cout<<endl;
    }
}
int main()
{
    int heroposX = 0;
    int heroposY = 0;
    char input=' ';
    bool isgameover =false;
    char gamemap[5][5]=
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
    };
    drawmap(heroposX,heroposY,gamemap);
    while(isgameover == false)
    {
    cin>>input;
    if(input=='d')
    {
        heroposX=heroposX + 1;
    }else if(input=='a')
    {
        heroposX=heroposX - 1;
    }
    else if(input == 's')
    {
        heroposY=heroposY + 1;
    }
    else if(input == 'w')
    {
        heroposY=heroposY - 1;
    }
    else if(input == 'p')
    {
        isgameover = true;
    }
    drawmap(heroposX,heroposY,gamemap);
    }
    return 0;
}

#include <iostream>

using namespace std;
void DrawMap(int HeroPosX, int HeroPosY, char Gamemap[5][5])
{
for(int i = 0; i < 5; i ++)
{
for (int p = 0; p < 5; p ++)
{
if(i != HeroPosY)
{
cout << Gamemap[p][i];
}
else
{
if(p != HeroPosX)
{
cout << Gamemap[p][i];
}
else
{
cout << ‘H’;
}
}
}
cout << endl;
}
}

int main()
{
int HeroPosX = 1;
int HeroPosY = 1;
bool IsGameOver = false;
char Input = ’ ';

char Gamemap[5][5]=
{
    {'1', '1', '1', '1', '1'},
    {'1', '1', '1', '1', '1'},
    {'1', '1', '1', '1', '1'},
    {'1', '1', '1', '1', '1'},
    {'1', '1', '1', '1', '1'},
};

DrawMap(HeroPosX, HeroPosY, Gamemap);

while(IsGameOver == false)
{
  cin >> Input;

  if(Input == 'd')
{
    HeroPosY = HeroPosY + 1;
}
else if (Input == 'a')
{
    HeroPosY = HeroPosY - 1;
}

if(Input == 'w')
{
    HeroPosX = HeroPosX + 1;
}
else if (Input == 'x')
{
    HeroPosX = HeroPosX - 1;
}
else if (Input == 'p')
{
    IsGameOver = true;
}
    DrawMap(HeroPosX, HeroPosY, Gamemap);
}

return 0;

}

Curiosamente lo hice antes de que nos dijera cual era el reto :v
Aquí esta el código con mi solución 😄

#include <iostream>
#include <ctype.h>

using namespace std;

void draw_map(int char_posx, int char_posy, char game_map[5][5]){
    for(int i = 0; i < 5 ; i++){
        for(int j = 0; j < 5 ; j++){
            if( j != char_posx ){
                cout << game_map[j][i];
            }else{
                if( i != char_posy ){
                    cout << game_map[j][i];
                }else {
                    cout << 'H';
                }
            }
        }
        cout << endl;
    }
}


int main(){
    int char_posx = 0;
    int char_posy = 0;

    char input;
    bool game_over = false;
    char game_map[5][5] = {
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}
    };


    draw_map(char_posx, char_posy, game_map);

    while(game_over == false){
        cout << endl;
        cin >> input;
        input = toupper(input);
        if (input == 'D'){
            char_posx += 1;
        }else if(input == 'S'){
            char_posy += 1;
        }else if(input == 'W'){
            char_posy -= 1;
        }else if (input == 'A'){
            char_posx -= 1;
        }else if (input == 'P'){
            game_over = true;
        }
    draw_map(char_posx, char_posy, game_map);
    }

    return 0;
}

Uff este ejercicio estuvo buenísimo 😄

#include <iostream>
using namespace std;

void drawMap(int heroPosX,int heroPosY,char gameMap[5][5]){
  for (int c = 0; c < 5; c++)
  {
    for (int f = 0; f < 5; f++)
    {
      if (c !=  heroPosX)
      {
        cout << gameMap[c][f];
      }
      else
      {
        if( f != heroPosY){
          cout << gameMap[c][f];
        }else
        {
          cout << 'H';
        }
      }
    }
    cout << "\n";
  }
}

int main(int argc, char const *argv[])
{
  int heroPosX = 1; 
  int heroPosY = 1; 
  bool isGameOver = false;

  char inputUser;
  char gameMap[5][5] = 
  {
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'},
    {'1','1','1','1','1'}
  };

  drawMap(heroPosX, heroPosY, gameMap);

  while (isGameOver == false)
  {
    cin >> inputUser;
    if (inputUser == 'd')
    {
      heroPosY++;
    }
    else if (inputUser == 'i')
    {
      heroPosY--;
    }
    else if (inputUser == 's')
    {
      heroPosX--;
    }
    else if (inputUser == 'b')
    {
      heroPosX++;
    }
    else if( inputUser == 'p')
    {
      isGameOver = true;
      cout << "GAME OVER!!!\n";
    }
    drawMap(heroPosX, heroPosY, gameMap);
  }

  return 0;
}

Dejo por acá mi código, por si ayuda a alguien 😃

#include <iostream>

using namespace std;

void drawMap(int heroPosX, int heroPosY, char gameMap[5][5])
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
        if (i != heroPosY)
        {
            cout << gameMap[j][i];
        } else if (j != heroPosX)

        {
            cout << gameMap[j][i];
        } else
        {
            cout << 'H';
        }
        }
        cout << endl;
    }
}

int main()
{
    int heroPosX = 1;
    int heroPosY = 1;
    bool isGameOver = false;
    char input = ' ';
    char gameMap[5][5] =
    {
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}
    };

    drawMap(heroPosX, heroPosY, gameMap);
    cout << endl;

    while(isGameOver == false)
    {
        cin >> input;

        if (input == 'a')
        {
            heroPosX = heroPosX - 1;
        } else if (input == 'd')
        {
            heroPosX = heroPosX + 1;
        } else if (input == 's')
        {
            heroPosY = heroPosY + 1;
        } else if (input == 'w')
        {
            heroPosY = heroPosY - 1;
        } else if (input == 'p')
        {
            isGameOver = true;
            cout << "Game Over";
        }

        if (isGameOver == false)
        {
            drawMap(heroPosX, heroPosY, gameMap);
        }

    }

    return 0;
}

Comparto mi código, decidí usar un switch para el input y cambiar un poco la función que dibuja el mapa.

#include <iostream>

using namespace std;

void drawMap(int heroPosX, int heroPosY, char gameMap[5][5] ) {
  for (int i = 0; i < 5; i++)
  {
    for(int j=0; j < 5; j++){
      if (i == heroPosY && j == heroPosX)
      {
        cout << 'H' << " ";
      }
      else
      {
        cout << gameMap[i][j] << " ";
      }
    }
    cout << endl;
  }
}

int main() {

  int heroPosX = 0;
  int heroPosY = 0;
  bool gameOver = false;
  char Inpt = ' ';
  char gameMap[5][5] = 
  {
      {'1', '1', '1', '1', '1'},
      {'1', '1', '1', '1', '1'},
      {'1', '1', '1', '1', '1'},
      {'1', '1', '1', '1', '1'},
      {'1', '1', '1', '1', '1'},
  };

  drawMap(heroPosX, heroPosY, gameMap);

  while(gameOver == false) {
    cout << endl;
    cin >> Inpt;


    switch (Inpt)
    {
    case 'd':
      heroPosX++;
      break;
    case 'a':
      heroPosX--;
      break;
    case 'w':
      heroPosY--;
      break;
    case 's':
      heroPosY++;
      break;
    case 'p':
      gameOver = true;
      break;
    default:
      gameOver = true;
      break;
    }

    drawMap(heroPosX, heroPosY, gameMap);
  }
  

  return 0;
}
#include <iostream>

using namespace std;



void DrawMap(int Positionx, int Positiony, char GameMap[5][5])
{
    for(int y=0; y<5; y++)
    {
        for(int x=0; x<5; x++)
        {
            if(Positiony != y)
            {
                cout<< GameMap[x][y];
            }
            else
            {
                if(Positionx != x)
                {
                    cout<< GameMap[x][y];
                }
                else
                {
                    cout<< 'H';
                }
            }
        }
        cout<<endl;
    }
}

int main()
{
    int Positionx = 1, Positiony = 1;
    char In_User = ' ';
    char GameMap[5][5] =
    {
        {'^','^','^','^','^'},
        {'^','^','^','^','^'},
        {'^','^','^','^','^'},
        {'^','^','^','^','^'},
        {'^','^','^','^','^'}
    };

    bool isGameOver = false;

    DrawMap(Positionx, Positiony, GameMap);

    while(isGameOver == false)
    {
        cin>> In_User;

        if(In_User == 'd')  //DERECHA
        {
            Positionx++;
            DrawMap(Positionx, Positiony, GameMap);
            if(Positionx > 4)
            {
                isGameOver = true;
            }
        }
        else if(In_User == 'a') //IZQUIERDA
        {
            Positionx--;
            DrawMap(Positionx, Positiony, GameMap);
            if(Positionx < 0)
            {
                isGameOver = true;
            }
        }
        else if(In_User == 's') //ABAJO
        {
            Positiony++;
            DrawMap(Positionx, Positiony, GameMap);
            if(Positiony > 4)
            {
                isGameOver = true;
            }
        }
        else if(In_User == 'w') //ARRIBA
        {
            Positiony--;
            DrawMap(Positionx, Positiony, GameMap);
            if(Positiony < 0)
            {
                isGameOver = true;
            }
        }
    }
    return 0;
}
#include <iostream>

using namespace std;

void MovePoint(int posX, int posY, char GameMap[5][5]){
  GameMap[posX][posY]='*';

  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      cout<<GameMap[i][j];    
    }
    cout<<endl;
  }

  GameMap[posX][posY]='|';
}


int main() {
  char GameMap[5][5]={
    {'|','|','|','|','|'},
    {'|','|','|','|','|'},
    {'|','|','|','|','|'},
    {'|','|','|','|','|'},
    {'|','|','|','|','|'}
  };

  int posX=0;
  int posY=0;
  char opc=' ';
  char com=' ';
  bool isGameOver=false;
  
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      cout<<GameMap[i][j];
    } 
    cout<<endl;
  }
  
  do{
    cout<<"Iniciar el juego: "<<endl;
    cout<<"[i]INICIAR"<<endl;
    cout<<"[s]SALIR"<<endl;
    cout<<"Opcion: ";
    cin>>opc;

    if(opc=='i'){
      MovePoint(posX,posY,GameMap);
      //Inicializando posX=0,posY=0

      while(isGameOver!=true){
        cout<<"Comando: ";
        cin>>com;
    
        switch(com){
          case 'd':
            posY++;
            if(posY==5){
              posY=0;
              posX++;
              if(posX==5){
                posX=0;
              }
            }
            MovePoint(posX,posY,GameMap);
          break;
          case 'a':
            posY--;
            if(posY==-1){
              if(posX==0){
                posY=4;
                posX=4;
              }else{
                posY=4;
                posX--;
              }
            }
            MovePoint(posX,posY,GameMap);
          break;
          case 'q':
            isGameOver=true;
            break;
        }
      }
    }

  }while(opc!='s');

  cout<<"----- G A M E  O V E R -----";
}

#include <iostream>

using namespace std;

void dibujando(int JuegoPosX,int JuegoPosY, char Juego[5][5])
{
for(int i=0; i<5;i++)
{
for(int j=0;j<5;j++)
{
if(i!=JuegoPosY)
{
cout<<Juego[j][i];
}
else
{
if(j!=JuegoPosX)
{
cout<<Juego[j][i];
}
else
{
cout<<’/’;
}
}
}
cout<<endl;
}

}

int main()
{
char Juego[5][5]={
{’+’,’+’,’+’,’+’,’+’},
{’+’,’+’,’+’,’+’,’+’},
{’+’,’+’,’+’,’+’,’+’},
{’+’,’+’,’+’,’+’,’+’},
{’+’,’+’,’+’,’+’,’+’}
};

int JuegoPosX=1;
int JuegoPosY=1;
char ingreso=’ ';
bool GameOver=false;

dibujando(JuegoPosX,JuegoPosY,Juego);
while(GameOver==false)
{
cin>>ingreso;

if(ingreso=='6')
{
    if (JuegoPosX<4)
    JuegoPosX++;
}

else if(ingreso=='4')
{
    if (JuegoPosX>0)
    JuegoPosX--;
}
else if(ingreso=='2')
{
    if (JuegoPosY<4)
    JuegoPosY++;
}
else if(ingreso=='8')
{
    if (JuegoPosY>0)
    JuegoPosY--;
}
else if(ingreso=='s')
{
GameOver=true;
}

dibujando(JuegoPosX,JuegoPosY,Juego);

}

return 0;

}

#include <iostream>

using namespace std;
void drawmap(int heroPosX, int heroPosY,char gameMap[5][5])
{
     for(int i=0;i<5;i++)
    {
        for(int j=0;j<5;j++)
        {
            if(i != heroPosY )
            {
            cout<<gameMap[j][i];
            }else if(j != heroPosX )
                {
                cout<<gameMap[j][i];
                }else
                    {
                    cout<<'H';
                    }
        }

    cout<<endl;
    }
}

int main()
{
    int heroPosX=0;
    int heroPosY=0;
    bool isgameover=false;
    char input=' ';
    char gameMap[5][5]=
    {
      {'1','1','1','1','1',},
      {'1','1','1','1','1',},
      {'1','1','1','1','1',},
      {'1','1','1','1','1',},
      {'1','1','1','1','1',}
    };

    drawmap(heroPosX,heroPosY,gameMap);

    while(isgameover==false)
    {
        cin>>input;
        if(input=='d')
        {
        heroPosX=heroPosX+1;
        }else if(input=='a')
        {
        heroPosX=heroPosX-1;
        }else if(input=='w')
        {
         heroPosY=heroPosY-1;
        }else if(input=='s')
        {
         heroPosY=heroPosY+1;
        }
        else if(input=='p')
        {
            isgameover=true;
        }
        drawmap(heroPosX,heroPosY,gameMap);
    }

    return 0;
}

Mi Reto

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
    for(int i = 0; i < 5; i++)
    {
        for(int p = 0; p < 5; p++)
        {
            if(i != HeroPosY)
            {
                cout << GameMap[p][i];
            }
            else
            {
                if(p != HeroPosX)
                {
                    cout << GameMap[p][i];
                }else
                {
                    cout << 'H';
                }
            }
        }
        cout << endl;
    }
}

int main()
{
    int HeroPosX = 0;
    int HeroPosY = 0;
    char Input = ' ';
    bool isGameOver = false;
    char GameMap[5][5] = {
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'},
        {'1', '1', '1', '1', '1'}
    };

    DrawMap(HeroPosX, HeroPosY, GameMap);

    while(isGameOver == false)
    {
        cin >> Input;

        if(Input == 'd')
        {
            HeroPosX = HeroPosX + 1;
        }else if(Input == 'a')
        {
            HeroPosX = HeroPosX - 1;
        }else if(Input == 's')
        {
            HeroPosY = HeroPosY + 1;
        }else if(Input == 'w')
        {
            HeroPosY = HeroPosY - 1;
        }else if(Input == 'p')
        {
            isGameOver = true;
        }

        DrawMap(HeroPosX, HeroPosY, GameMap);
    }

    return 0;
}
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

void drawMap(int heroPos[2], char gameMap[5][5])
{
    for(int i = 0; i < 5 ; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            if((i != heroPos[0])||(j != heroPos[1]))
            {
                cout << gameMap[i][j];
            }else
            {
                cout << 'H';
            }
        }
        cout << endl;
    }
}


int main()
{
    int heroPos[2] = {1,2};
    bool isGameOver = false;
    char input = ' ';
    char gameMap[5][5] =
    {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };

    drawMap(heroPos,gameMap);
    while(isGameOver==false)
    {
        cin >> input;

        if (input == 'd')//derecha
        {
            heroPos[1]++;
        }else if(input == 'a')//izquierda
        {
            heroPos[1]--;
        }else if(input == 'f')//salir
        {
            isGameOver=true;
        }else if(input == 'w')//arriba
        {
            heroPos[0]--;
        }else if(input == 's')//abajo
        {
            heroPos[0]++;
        }
        drawMap(heroPos,gameMap);
    }

    return 0;
}

El reto un poco diferente

<
#include <iostream>
#include <stdlib.h>// usar función system("cls||clear");
#include <conio.h> //usar función getch();
#include <ctype.h> //convertir a minúsculas
using namespace std;
char character = 'x';
int positionX = 0;
int positionY = 0;
char move;//guarda el comando para moverse
char map[5][5] = {
  {'0', '0', '0', '0', '0'},
  {'0', '0', '0', '0', '0'},
  {'0', '0', '0', '0', '0'},
  {'0', '0', '0', '0', '0'},
  {'0', '0', '0', '0', '0'},
};

void draw(char move) {
  move = tolower(move); //convierte a minúsculas
  switch (move) {
    case 'a':
      positionX--;
      break;
    case 'd':
      positionX++;
      break;
    case 'w':
      positionY--;
      break;
    case 's':
      positionY++;
      break;
    default:
      break;
  }
  if (positionX > 4) { //if's para establecer los límites
    positionX = 4;
  } else if (positionX < 0) {
    positionX = 0;
  }
  if (positionY > 4) {
    positionY = 4;
  } else if (positionY < 0) {
    positionY = 0;
  }
  system("cls||clear"); //borra lo que hay en la pantalla
  for (int i = 0; i <= 4; i++) {
    for (int j = 0; j <= 4; j++) {
      if (positionX == j && positionY == i) {
        cout << character;
      }
      else {
        cout << map[i][j];
      }
    }
    cout << endl;
  }
  cout << "\n\n\npress x to end";
}

int main() {
  cout << "press C to start";
  while (move != 'c') { //el juego inicia hasta pulsar la letra c
    move = _getch();
    move = tolower(move);
  }
  draw(move);
  while (move != 'x') {
    move = _getch(); //getch() nos evita presionar enter
    draw(move);
  }
  return 0;
}
>

#include <iostream>

using namespace std;

void DrawMap(int HeroPosX, int HeroPosY, char GameMap[5][5])
{
for (int i = 0; i<5; i = i + 1)
{
for(int p = 0; p < 5; p = p + 1)
{
if(i != HeroPosY)
{
cout << GameMap[p][i];
}
else
{
if(p != HeroPosX)
{
cout << GameMap[p][i];
}else
{
cout << ‘H’;
}

        }
    }
    cout  << endl;
}

}

int main()
{
int HeroPosX = 0;
int HeroPosY = 0;
bool isGameOver = false;
char Input = ’ ';
char GameMap [5][5] =
{
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’},
{‘1’,‘1’,‘1’,‘1’,‘1’}
};

DrawMap(HeroPosX, HeroPosY, GameMap);

while (isGameOver == false)
{
    cin >> Input;

    if (Input == 'd')
    {
        HeroPosX = HeroPosX  + 1;
    }else if(Input == 'a')
    {
        HeroPosX = HeroPosX - 1;
    }
    else if (Input == 'w')
    {
        HeroPosY = HeroPosY  + 1;
    }else if(Input == 's')
    {
        HeroPosY = HeroPosY - 1;
    }
    else if (Input == 'p')
    {
        isGameOver = true;
    }

    DrawMap(HeroPosX, HeroPosY, GameMap);

}


return 0;

}

![](

este reto me fue un poco mas laborioso de lo habitual ya que tube problemas para imprimir en pantalla lo que queria lo intente con punteros con muchas condicionales y al final me di cuenta que usando un IF que igualaras las coordenadas con las variables de los FOR se imprimía el resultado que quería haaaaaaa me habia complicado tanto con algo que era muy simple XD
como siempre les comparto mi archivo por si lo quieren checar
https://drive.google.com/file/d/1zo3jTgMBR_KU-gCUi8yaWRKDkRGl7WEd/view?usp=sharing

#include <iostream>

using namespace std;

void GPS (int X,int Y, char mapa[5][5])     {
    for (int i = 0;i<5; i++)              {
            for (int j = 0; j<5;j++)      {
                if (j == X && i == Y)     {
                    cout <<"  "<<'O';          }
                else{cout <<"  "<< mapa [j][i];}}
        cout << endl;                     } }

void StatusGame(bool *EsElFinDelJuego)  {
   *EsElFinDelJuego = true;
   cout <<endl <<  "Geme Over"<< endl;  }

int main()
{
    int heroCorX = 0,
        heroCorY = 0;
    char input = ' ';
    bool GameOver = false;
    char mapadeljuego[5][5]={{'*','*','*','*','*'},
                             {'*','*','*','*','*'},
                             {'*','*','*','*','*'},
                             {'*','*','*','*','*'},
                             {'*','*','*','*','*'}};

    while (!GameOver)                    {
        cin >> input;
        switch (input)        {
            case 'd':
                heroCorX++;
                break;
            case 'a':
                heroCorX--;
                break;
            case 's':
                heroCorY++;
                break;
            case 'w':
                heroCorY--;
                break;
            default:
                StatusGame(&GameOver);
                break;          }

        if (heroCorX < 0 || heroCorX > 4 ||
            heroCorY < 0 || heroCorY > 4) {
                StatusGame(&GameOver);    }
        if (!GameOver)                          {
            GPS(heroCorX,heroCorY,mapadeljuego);}}
    return 0;
}```
#include <iostream>

using namespace std;

void drawMap(int heroPos[2],char gameMap[5][5])
{
    for (int i = 0; i<5;i++){
        for(int j=0;j<5;j++){
            if(i == heroPos[0] && j == heroPos[1]){
                cout<<'H';
            }else{
                cout<<gameMap[i][j];
            }
        }
            cout<<endl;
    }
}

int main()
{
    int heroPos[2] ={1,2};
    bool isGameOver=false;
    char input = ' ';
    char gameMap[5][5] = {
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'},
        {'1','1','1','1','1'}
    };

    drawMap(heroPos,gameMap);
    while(!isGameOver){
        cin>>input;
        switch(input){
        case 'd':
            heroPos[1]++;
            break;
        case 'a':
            heroPos[1]--;
            break;
        case 'w':
            heroPos[0]--;
            break;
        case 's':
            heroPos[0]++;
            break;
        case 'p':
            isGameOver=true;
            break;
        }

        drawMap(heroPos,gameMap);
    }

    return 0;
}

#include<iostream>
using namespace std;
char Mapa[5][5]{
	{'1','1','1','1','1'},
	{'1','1','1','1','1'},
	{'1','1','1','1','1'},
	{'1','1','1','1','1'},
	{'1','1','1','1','1'},
};
void generarMostrar(int *HeroeX,int *HeroeY ,char **mapa) {
	
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			mapa[i][j] = Mapa[i][j];
		}

	}

	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (i != (*HeroeY)) {
				cout << mapa[i][j];
			}
			else {
				if (j != (*HeroeX))
					cout << mapa[i][j];
				else {
					cout << "*";
				}
			}		
		}
		cout << endl;
	}
}
void MoverPersonaje() {
	char **mapa = new char*[5];
	for (int i = 0; i < 5; i++) {
		mapa[i] = new char[5];
	}
	int *HeroeX = new int;
	int *HeroeY = new int;
	*HeroeY = 3;
	*HeroeX = 3;
	char *input = new char;
	generarMostrar(HeroeX, HeroeY, mapa);
	do {
		cin >> *input;
		if (*input == 'A')
			(*HeroeX) -= 1;
		else {
			if (*input == 'D')
				(*HeroeX) += 1;
			else {
				if (*input == 'W')
					(*HeroeY) -= 1;

				else {
					if (*input == 'S')
						(*HeroeY) += 1;
				}
			}

		}
		generarMostrar(HeroeX, HeroeY, mapa);
	} while (*input = 'P');
}
int main() {
	MoverPersonaje();
	system("pause");
	return(0);
}