Last active
November 17, 2024 17:41
-
-
Save rkTinelli/be533edabf44e13e6366549081d10897 to your computer and use it in GitHub Desktop.
Jogo FogeFoge (Pacman) Funcional feito em linguagem C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void libera_mapa(); | |
| void le_mapa(); | |
| void aloca_mapa(); | |
| void imprime_mapa(); | |
| int acabou(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include "foge.h" | |
| char** mapa; //[5][10+1]; //10+1 para que seja identificado o \0 no final de cada linha | |
| int linhas; | |
| int colunas; | |
| void le_mapa(){ | |
| FILE* f; | |
| f = fopen("mapa.txt","r"); | |
| if (f==0){ //tratamentto de erro | |
| printf("Erro de leitura do arquivo do mapa! \n"); | |
| } | |
| fscanf(f,"%d %d",&linhas,&colunas); | |
| aloca_mapa(); | |
| int i; | |
| for (i = 0; i<5; i++){ | |
| fscanf(f,"%s",mapa[i]); | |
| } | |
| fclose(f); | |
| } | |
| void aloca_mapa(){ | |
| mapa = malloc(sizeof(char*)*linhas); | |
| int j; | |
| for (j=0;j<linhas;j++){ | |
| mapa[j] = malloc(sizeof(char*)*(colunas+1)); | |
| } | |
| } | |
| void libera_mapa(){ | |
| int i; | |
| for (i=0;i<linhas;i++){ | |
| free(mapa[i]); | |
| } | |
| free(mapa); | |
| } | |
| void imprime_mapa(){ | |
| int i; | |
| for (i = 0; i<5; i++){ | |
| printf("%s\n",mapa[i]); | |
| } | |
| } | |
| int acabou(){ | |
| return 0; | |
| } | |
| int main(){ | |
| le_mapa(); | |
| imprime_mapa(); | |
| libera_mapa(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 5 10 | |
| |--------| | |
| |...|..-.| | |
| |.._|.@..| | |
| |......_.| | |
| |--------| |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pac-man game.
Working !