Jump to content
Fórum Script Brasil
  • 0

Jogo Zelda em C


SadesTorm
 Share

Question

ola estou com muitas dificuldades em progamar um joguinho simples, porém muito difícil, o nome do jogo se chama zelda. O jogo e progamado em uma matriz 8x8, e o conteudo da matriz tem que ser o dobro do numero antecessor. tanto para linha como para coluna. e tem que ser comandado por WSAD w=cima, S=baixo, A=esquerda e D=direita. Cada casa q ele percorre ele recebe o valor da posiçao na matriz. Algiem me ajude por favor.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;

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

int main () {
    char mapa[16][17] = {
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "},
        {"                "}

    };
    
    
    for ( int y = 0; y < 16; y++ ) {
        for ( int x = 0; x < 16; x++ ) {
            cout << mapa[y][x];
        }
        cout << endl;
    }
    
    int x = 0;
    int y = 0;
    int cx = 0;
    int cy = 0;
    
    //inicia em:
    gotoxy ( 0, 0 );
    printf ( "Z" );
    
    int ch;
    while ( ( ch = _getch() ) ) {
        if ( ch == 27 ) {
            return 0;
        }
        if ( ch == 72 ) {
            //ACIMA
            if ( y > 0 ) {
                gotoxy ( x, y );
                printf ( " " );
                y--;
                gotoxy ( x, y );
                printf ( "Z" );
            }
            
        } else if ( ch == 75 ) {
            //ESQUERDA
            if ( x > 0 ) {
                gotoxy ( x, y );
                printf ( " " );
                x--;
                gotoxy ( x, y );
                printf ( "Z" );
            }
            
        } else if ( ch == 77 ) {
            //DIREITA
            if ( x <= 15 ) {
                gotoxy ( x, y );
                printf ( " " );
                x++;
                gotoxy ( x, y );
                printf ( "Z" );
            }
            
            
        } else if ( ch == 80 ) {
            //ABAIXO
            if ( y <= 15 ) {
                gotoxy ( x, y );
                printf ( " " );
                y++;
                gotoxy ( x, y );
                printf ( "Z" );
            }
            
        } else {
            gotoxy ( x, y );
            printf ( " " );
            cx = x;
            cy = y;
            gotoxy ( x, y );
            printf ( "Z" );
            x = cx;
            y = cy;
        }
        
    }
    
    cin.ignore();
    return 0;
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.1k
    • Total Posts
      647.1k
×
×
  • Create New...