format
This commit is contained in:
18
display.c
18
display.c
@@ -1,17 +1,17 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void screenDisplay( unsigned short int **tab,int size)
|
void
|
||||||
|
screenDisplay (unsigned short int **tab, int size)
|
||||||
{
|
{
|
||||||
//puts("0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 ");
|
// puts("0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 ");
|
||||||
char element[7] ={' ','#','S','.','*','@','+'} ;
|
char element[7] = { ' ', '#', 'S', '.', '*', '@', '+' };
|
||||||
for(int i=0;i<size;++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
for(int j=0;j<size;++j)
|
for (int j = 0; j < size; ++j)
|
||||||
{
|
{
|
||||||
printf("%c ",element[tab[i][j]]);
|
printf ("%c ", element[tab[i][j]]);
|
||||||
}
|
}
|
||||||
puts("");
|
puts ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,10 +180,7 @@ move (unsigned short int **tab, vect *playerPos, vect direction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
inGameLoop (unsigned short int **tab2d,
|
inGameLoop (unsigned short int **tab2d, int N, vect *playerPos, vect *targets,
|
||||||
int N,
|
|
||||||
vect *playerPos,
|
|
||||||
vect *targets,
|
|
||||||
int nbr_targets)
|
int nbr_targets)
|
||||||
{
|
{
|
||||||
vect direction = { 0, 0 };
|
vect direction = { 0, 0 };
|
||||||
|
|||||||
33
main.c
33
main.c
@@ -1,28 +1,29 @@
|
|||||||
#include <stdio.h>
|
#include "display.h"
|
||||||
#include <time.h>
|
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "read.h"
|
#include "read.h"
|
||||||
#include "display.h"
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#define SIZE_PLAY 24
|
#define SIZE_PLAY 24
|
||||||
|
|
||||||
int main()
|
int
|
||||||
|
main ()
|
||||||
{
|
{
|
||||||
vect *playerPos = (vect *)malloc(sizeof(vect));
|
vect *playerPos = (vect *)malloc (sizeof (vect));
|
||||||
vect *targets;
|
vect *targets;
|
||||||
int nbr_targets;
|
int nbr_targets;
|
||||||
score playerScore;
|
score playerScore;
|
||||||
playerScore.before = time(NULL);
|
playerScore.before = time (NULL);
|
||||||
unsigned short int **tab2d = creatArea2D(SIZE_PLAY);
|
unsigned short int **tab2d = creatArea2D (SIZE_PLAY);
|
||||||
targets = fileToTab2D("test.txt", tab2d, SIZE_PLAY, playerPos, &nbr_targets);
|
targets
|
||||||
screenDisplay(tab2d, SIZE_PLAY);
|
= fileToTab2D ("test.txt", tab2d, SIZE_PLAY, playerPos, &nbr_targets);
|
||||||
inGameLoop(tab2d, SIZE_PLAY, playerPos, targets, nbr_targets);
|
screenDisplay (tab2d, SIZE_PLAY);
|
||||||
|
inGameLoop (tab2d, SIZE_PLAY, playerPos, targets, nbr_targets);
|
||||||
|
|
||||||
|
playerScore.after = time (NULL);
|
||||||
playerScore.after = time(NULL);
|
printf ("%ld\n", playerScore.after - playerScore.before);
|
||||||
printf("%ld\n", playerScore.after - playerScore.before);
|
free2D (tab2d, SIZE_PLAY);
|
||||||
free2D(tab2d, SIZE_PLAY);
|
free (playerPos);
|
||||||
free(playerPos);
|
free (targets);
|
||||||
free(targets);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
2
read.c
2
read.c
@@ -48,6 +48,6 @@ fileToTab2D (const char *name_file, unsigned short int **tab, const unsigned N,
|
|||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose (file);
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|||||||
4
read.h
4
read.h
@@ -1,6 +1,6 @@
|
|||||||
#ifndef READ_H
|
#ifndef READ_H
|
||||||
#define READ_H
|
#define READ_H
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
vect* fileToTab2D(const char* name_file, unsigned short int **tab,
|
vect *fileToTab2D (const char *name_file, unsigned short int **tab,
|
||||||
const unsigned N, vect *player, int *nbr_targets);
|
const unsigned N, vect *player, int *nbr_targets);
|
||||||
#endif // !READ_H
|
#endif // !READ_H
|
||||||
|
|||||||
Reference in New Issue
Block a user