Skip to content

Commit

Permalink
add iniciar tabueiro
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiorosa1 committed Jan 31, 2019
1 parent 9700bba commit c3868b8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ int main(int argc, char* argv[]){
printf("Vazia: %c\n",vazia);
printf("Table Size: %d\n",tableSize);

tGame game[tableSize][tableSize]; // not working yet
//inicializa tabuleiro
tGame** game = inicia_tabuleiro(tableSize);

int i=0,j=0;
do
{
// lendo cada caractere
char c = fgetc(filePointer);
if(c == '1'){
game[i][j].state =0;
game[i][j].content = bomba;
//game[i][j].state =0;
//game[i][j].content = bomba;
}

// sai do loop quando eh o fim do arquivo
Expand Down
Binary file modified minesweeper
Binary file not shown.
8 changes: 8 additions & 0 deletions tGame.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ void printPosition(tGame* g){
}
printf("Estado: %d\n",g->state);
printf("Conteudo: %c\n",g->content);
}

tGame** inicia_tabuleiro(int sz){

tGame **tabuleiro = (tGame**) malloc(sz*sizeof(tGame*));
// alocar espaco para of ponteiros itself

return tabuleiro;
}
3 changes: 3 additions & 0 deletions tGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ typedef struct tgame tGame;
// inicia a posicao com o estado e o conteudo
tGame* inicia_tGame(int s,int c);

// aloca memoria para o tabuleiro
tGame** inicia_tabuleiro(int sz);

// prints a specific position
void printPosition(tGame* g);

Expand Down

0 comments on commit c3868b8

Please sign in to comment.