Enviado em 23/06/2019 - 20:18h
galera estou tendo dificuldades para desenvolver a programação de um labirinto alguém pode me ajudar?#include <stdio.h>
#include <stdlib.h>
#define CHAO 0
#define PAREDE 1
#define VOCE 4
#define BORDA 5
#define PORTA 2
#define ENIGMA 3
#define OK 1
#define ERRO 2
#define LIMPARTELA “clear”
int coluna_atual = 4, linha_atual = 4;
int mapa[30][60] = {
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,0,0,1,1,1,1,1,5,
5,1,0,0,0,0,0,0,1,1,2,2,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
};
int desenhar_mapa(){
int linha,coluna;
for (linha=0;linha<30;linha++) {
for (coluna=0;coluna<60;coluna++) {
if ((linha == linha_atual) && (coluna == coluna_atual)) {
printf("@");
continue;
}
if (mapa[linha][coluna] == CHAO)
printf(" “);
if (mapa[linha][coluna] == PAREDE)
printf(”#");
if (mapa[linha][coluna] == BORDA)
printf("#");
if (mapa[linha][coluna] == PORTA)
printf("!");
if (mapa[linha][coluna] == ENIGMA)
printf("?");
}
printf("\n");
}
return OK;
}
int main(){
char movimento;
while ((movimento != ‘x’) && (movimento != ‘X’)) {
system(LIMPARTELA);
desenhar_mapa();
printf("\n\n (W)\n(A)+(D)\n (S)\n\n");
if ((scanf("%c",&movimento))==0) {
printf(“mensagem de erro…\n”);
getchar();
return ERRO;
}
if ((movimento == ‘w’) || (movimento == ‘W’)) {
linha_atual = linha_atual - 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
linha_atual = linha_atual + 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
if ((movimento == 's') || (movimento == 'S')) {
linha_atual = linha_atual + 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
linha_atual = linha_atual - 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
if ((movimento == 'd') || (movimento == 'D')) {
coluna_atual = coluna_atual + 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
coluna_atual = coluna_atual - 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
if ((movimento == 'a') || (movimento == 'A')) {
coluna_atual = coluna_atual - 1;
if (mapa[linha_atual][coluna_atual] != CHAO) {
coluna_atual = coluna_atual + 1;
printf("\n\nups.. ali não =)\n");
getchar();
}
}
}
}
Compartilhando a tela do Computador no Celular via Deskreen
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
Como renomear arquivos de letras maiúsculas para minúsculas
Imprimindo no formato livreto no Linux
Vim - incrementando números em substituição
Efeito "livro" em arquivos PDF
Como resolver o erro no CUPS: Unable to get list of printer drivers
Vou voltar moderar conteúdos de Dicas e Artigos (2)
Melhorando a precisão de valores flutuantes em python[AJUDA] (8)
[Python] Automação de scan de vulnerabilidades
[Python] Script para analise de superficie de ataque
[Shell Script] Novo script para redimensionar, rotacionar, converter e espelhar arquivos de imagem
[Shell Script] Iniciador de DOOM (DSDA-DOOM, Doom Retro ou Woof!)
[Shell Script] Script para adicionar bordas às imagens de uma pasta