#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void matriz( int v[ ] [ 30 ] , int i, int j, int bomb) ;
int main( )
{
int maze
[ 30 ] [ 30 ] , i
, j
, bomb
= rand ( ) % 70 ; puts ( "Ola, Benvindo ao Maze game.\n Os comandos sao simples\n W para cima\n A para a esquerda\n S para baixo\n D para direita\n Voce comeca na primeira posicao e devera chegar ate a ultima\n sem passar por cima de nenhum 1 ou 2 mas, voce EXPLODIR o 2 apertando 'b'\n (Sendo que vc so pode usar uma determinada qtd de bombas!)\n MAXIMIZE a tela, tecle enter e divirta-se" ) ; for ( i = 0 ; i < 30 ; i++ )
{
for ( j = 0 ; j < 30 ; j++ )
{
if ( i == 29 && j == 29 )
{
maze[ i] [ j] = 0 ;
} else if ( i == 0 && j == 0 )
{
maze[ i] [ j] = 5 ;
} else
{
}
}
}
printf ( "\n voce tem %d bombas\n " , bomb
) ; i = j = 0 ;
matriz( maze, i, j, bomb) ;
return 0 ;
}
void matriz( int v[ ] [ 30 ] , int i, int j, int bomb)
{
int a, b;
char direcao;
do
{
switch ( direcao)
{
case 'w' :
v[ i] [ j] = 0 ;
i--;
break ;
case 'a' :
v[ i] [ j] = 0 ;
j--;
break ;
case 's' :
v[ i] [ j] = 0 ;
i++;
break ;
case 'd' :
v[ i] [ j] = 0 ;
j++;
break ;
case 'b' :
if ( bomb == 0 )
{
direcao = 0 ;
} else {
bomb--;
if ( v[ i + 1 ] [ j] == 2 )
{
v[ i + 1 ] [ j] = 0 ;
}
if ( v[ i - 1 ] [ j] == 2 )
{
v[ i - 1 ] [ j] = 0 ;
}
if ( v[ i] [ j + 1 ] == 2 )
{
v[ i] [ j + 1 ] = 0 ;
}
if ( v[ i] [ j - 1 ] == 2 )
{
v[ i] [ j - 1 ] = 0 ;
}
}
break ;
default :
direcao = 0 ;
}
} while ( direcao) ;
if ( i < 0 || j < 0 || i > 29 || j > 29 || v[ i] [ j] == 1 || v[ i] [ j] == 2 )
{
} else if ( i == 29 && j == 29 )
{
v[ i] [ j] = 5 ;
for ( a = 0 ; a < 30 ; a++ )
{
for ( b = 0 ; b < 30 ; b++ )
{
}
}
puts ( "Parabens Voce venceu!!!" ) ; } else
{
v[ i] [ j] = 5 ;
}
for ( a = 0 ; a < 30 ; a++ )
{
for ( b = 0 ; b < 30 ; b++ )
{
}
}
printf ( "\n voce tem %d bombas\n " , bomb
) ; matriz( v, i, j, bomb) ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCnZvaWQgbWF0cml6KGludCB2W11bMzBdLCBpbnQgaSwgaW50IGosIGludCBib21iKTsKCmludCBtYWluKCkKewpzcmFuZCh0aW1lKE5VTEwpKTsKaW50IG1hemVbMzBdWzMwXSwgaSwgaiwgYm9tYiA9IHJhbmQoKSU3MDsKcHV0cygiT2xhLCBCZW52aW5kbyBhbyBNYXplIGdhbWUuXG5PcyBjb21hbmRvcyBzYW8gc2ltcGxlc1xuVyBwYXJhIGNpbWFcbkEgcGFyYSBhIGVzcXVlcmRhXG5TIHBhcmEgYmFpeG9cbkQgcGFyYSBkaXJlaXRhXG5Wb2NlIGNvbWVjYSBuYSBwcmltZWlyYSBwb3NpY2FvIGUgZGV2ZXJhIGNoZWdhciBhdGUgYSB1bHRpbWFcbnNlbSBwYXNzYXIgcG9yIGNpbWEgZGUgbmVuaHVtIDEgb3UgMiBtYXMsIHZvY2UgRVhQTE9ESVIgbyAyIGFwZXJ0YW5kbyAnYidcbihTZW5kbyBxdWUgdmMgc28gcG9kZSB1c2FyIHVtYSBkZXRlcm1pbmFkYSBxdGQgZGUgYm9tYmFzISlcbk1BWElNSVpFIGEgdGVsYSwgdGVjbGUgZW50ZXIgZSBkaXZpcnRhLXNlIik7CmdldGNoYXIoKTsKZmZsdXNoKHN0ZGluKTsKc3lzdGVtKCJjbHMiKTsKZm9yIChpID0gMDsgaSA8IDMwOyBpKyspCnsKICAgIGZvciAoaiA9IDA7IGogPCAzMDsgaisrKQogICAgewogICAgICAgIGlmIChpID09IDI5ICYmIGogPT0gMjkpCiAgICAgICAgewogICAgICAgICAgICBtYXplW2ldW2pdID0gMDsKICAgICAgICB9IGVsc2UgaWYoaSA9PSAwICYmIGogPT0gMCkKICAgICAgICB7CiAgICAgICAgICAgIG1hemVbaV1bal0gPSA1OwogICAgICAgIH1lbHNlCiAgICAgICAgewogICAgICAgICAgICBtYXplW2ldW2pdID0gcmFuZCgpJTM7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiJWQgIiwgbWF6ZVtpXVtqXSk7CiAgICB9CiAgICBwdXRzKCIiKTsKfQpwcmludGYoIlxudm9jZSB0ZW0gJWQgYm9tYmFzXG4iLCBib21iKTsKaSA9IGogPSAwOwptYXRyaXoobWF6ZSwgaSwgaiwgYm9tYik7CnJldHVybiAwOwp9Cgp2b2lkIG1hdHJpeihpbnQgdltdWzMwXSwgaW50IGksIGludCBqLCBpbnQgYm9tYikKewppbnQgYSwgYjsKY2hhciBkaXJlY2FvOwpkbwp7CiAgICBkaXJlY2FvID0gZ2V0Y2hhcigpOyAvL0FRVUkhCiAgICBzd2l0Y2goZGlyZWNhbykKICAgIHsKICAgICAgICBjYXNlICd3JzoKICAgICAgICAgICAgdltpXVtqXSA9IDA7CiAgICAgICAgICAgIGktLTsKICAgICAgICAgICAgcHJpbnRmKCJXIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgJ2EnOgogICAgICAgICAgICB2W2ldW2pdID0gMDsKICAgICAgICAgICAgai0tOwogICAgICAgICAgICBwcmludGYoIkEiKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAncyc6CiAgICAgICAgICAgIHZbaV1bal0gPSAwOwogICAgICAgICAgICBpKys7CiAgICAgICAgICAgICBwcmludGYoIlMiKTsKICAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICdkJzoKICAgICAgICAgICAgdltpXVtqXSA9IDA7CiAgICAgICAgICAgIGorKzsKICAgICAgICAgICAgcHJpbnRmKCJEIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgJ2InOgogICAgICAgICAgICBpZiAoYm9tYiA9PSAwKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBkaXJlY2FvID0gMDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHByaW50ZigiXDciKTsKICAgICAgICAgICAgYm9tYi0tOwogICAgICAgICAgICBpZiAodltpICsgMV1bal0gPT0gMikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdltpICsgMV1bal0gPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh2W2kgLSAxXVtqXSA9PSAyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB2W2kgLSAxXVtqXSA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHZbaV1baiArIDFdID09IDIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHZbaV1baiArIDFdID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodltpXVtqIC0gMV0gPT0gMikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdltpXVtqIC0gMV0gPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcHJpbnRmKCJCIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGRpcmVjYW8gPSAwOwogICAgfQp9IHdoaWxlKGRpcmVjYW8pOwppZiAoaSA8IDAgfHwgaiA8IDAgfHwgaSA+IDI5IHx8IGogPiAyOSB8fCB2W2ldW2pdID09IDEgfHwgdltpXVtqXSA9PSAyKQp7CiAgICBwdXRzKCJHQU1FIE9WRVIhISEiKTsKICAgIGV4aXQoMSk7Cn0gZWxzZSBpZiAoaSA9PSAyOSAmJiBqID09IDI5KQp7CiAgICBzeXN0ZW0oImNscyIpOwogICAgdltpXVtqXSA9IDU7CiAgICBmb3IgKGEgPSAwOyBhIDwgMzA7IGErKykKICAgIHsKICAgICAgICBmb3IgKGIgPSAwOyBiIDwgMzA7IGIrKykKICAgICAgICB7CiAgICAgICAgICAgIHByaW50ZigiJWQgIiwgdlthXVtiXSk7CiAgICAgICAgfQogICAgICAgIHB1dHMoIiIpOwogICAgfQogICAgcHV0cygiUGFyYWJlbnMgVm9jZSB2ZW5jZXUhISEiKTsKICAgIGV4aXQoMCk7Cn0gZWxzZQp7CiAgICB2W2ldW2pdID0gNTsKfQpzeXN0ZW0oImNscyIpOwpmb3IgKGEgPSAwOyBhIDwgMzA7IGErKykKewogICAgZm9yIChiID0gMDsgYiA8IDMwOyBiKyspCiAgICB7CiAgICAgICAgcHJpbnRmKCIlZCAiLCB2W2FdW2JdKTsKICAgIH0KCgogICAgcHV0cygiIik7Cn0KcHJpbnRmKCJcbnZvY2UgdGVtICVkIGJvbWJhc1xuIiwgYm9tYik7Cm1hdHJpeih2LCBpLCBqLCBib21iKTsKfQ==