Help with a map made with arrangements and classes c ++

0

I am doing a program with a ship in which you must move on the screen but I must add a map which must be a box stuck to the left and another to the right and that the ship has a space to pass through and must be done with a class and arrangement, I'm giving error and I'm a bit lost, I require your support with some explanation, here I leave my code:

#include <iostream>
#include <conio.h>
#include "windows.h"
#include <stdio.h>

#define ARRIBA 72
#define ABAJO 80
#define IZQUIERDA 75
#define DERECHA 77

using namespace std;

int x=37, y=20;

void gotoxy(int x, int y){
    HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X = x;
    dwPos.Y = y;
    SetConsoleCursorPosition(hcon,dwPos);
}

class Mapa{
    private:
        int cx, cy;
        int color;
        int arr[40];
    public:
        void MostrarLimite();
        void ArregloMapa();
};

void Mapa::MostrarLimite(){


}

void Mapa::ArregloMapa(){
    int n;
    for(int i=0; i<39; i++){
        gotoxy(i,0); printf("&c",205);
    }
}


void imprimir(){
    gotoxy(x,y); printf("  %c  ",202);
    gotoxy(x,y+1); printf(" %c%c%c ",91,207,93);
    gotoxy(x,y+2); printf("%c%c %c%c",174,206,206,175);
}

void borrar(){
    gotoxy(x,y); cout<<"     ";
    gotoxy(x,y+1); cout<<"     ";
    gotoxy(x,y+2); cout<<"     ";
}

void OcultarCursor(){
    HANDLE hCon;
    hCon = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO cci;
    cci.dwSize = 100;
    cci.bVisible = FALSE;
    SetConsoleCursorInfo(hCon, &cci);
}

int main()
{
    system("mode con: cols=100 lines=50");
    system("color 0B");

    Mapa mapa1();
    mapa1.ArregloMapa();

    char opc;
    imprimir();
    while(opc!='y'){
    OcultarCursor();
    if(kbhit()){
        char tecla = getch();
        borrar();
        if(tecla == ARRIBA &&y>0) y--;
        if(tecla == ABAJO &&y<47) y++;
        if(tecla == IZQUIERDA &&x>0) x--;
        if(tecla == DERECHA &&x<95) x++;
        imprimir();
    }

    }

    return 0;
}
    
asked by Axel A 01.11.2017 в 05:38
source

0 answers