choix map fonctionne, a faire : score , affichage lose et win, custom.
Petit fix pour la lose 1 touché
This commit is contained in:
@@ -24,37 +24,66 @@ int main ()
|
||||
initSDL (&display_user);
|
||||
|
||||
vect *playerPos = (vect *)malloc (sizeof (vect));
|
||||
vect *targets;
|
||||
vect *targets = {0};
|
||||
int nbr_targets;
|
||||
score playerScore;
|
||||
score playerScore = {0};
|
||||
char **tab2d = creatArea2D (SIZE_PLAY, SIZE_PLAY);
|
||||
|
||||
score score_user = {0, 0, 0,0};
|
||||
vect dim = {SIZE_PLAY, SIZE_PLAY};
|
||||
int output = -1;
|
||||
|
||||
vect dim_menu = {0, 0};
|
||||
vect pos = {4, 1};
|
||||
char**menu = generatorMenu("maps", &dim_menu, &pos);
|
||||
printf("x %d, y %d\n", dim_menu.x, dim_menu.y);
|
||||
|
||||
screenDisplay(menu, dim_menu.x, dim_menu.y);
|
||||
|
||||
|
||||
targets
|
||||
= fileToTab2D ("maps/original_1.txt", tab2d, SIZE_PLAY, playerPos, &nbr_targets);
|
||||
inGameLoop (menu, &dim_menu, &pos, targets, nbr_targets,
|
||||
|
||||
vect null = {0, 0};
|
||||
printf("output : %d\n", output);
|
||||
output = inGameLoop (menu, &dim_menu, &pos, &null , 1,
|
||||
&display_user, &score_user, true);
|
||||
nullScore(&score_user);
|
||||
SDL_RenderClear(display_user.renderer);
|
||||
vect dim = {SIZE_PLAY, SIZE_PLAY};
|
||||
inGameLoop (tab2d, &dim, playerPos, targets, nbr_targets,
|
||||
&display_user, &score_user, false);
|
||||
|
||||
|
||||
while(output != 0)
|
||||
{
|
||||
SDL_RenderClear(display_user.renderer);
|
||||
if(output == -1)
|
||||
{
|
||||
menu = generatorMenu("maps", &dim_menu, &pos);
|
||||
pos.x = 4; pos.y = 1;
|
||||
output = inGameLoop(menu, &dim_menu, &pos, &null, 1, &display_user, &score_user, true);
|
||||
nullScore(&score_user);
|
||||
}
|
||||
else
|
||||
{
|
||||
char txt[30] = "";
|
||||
if(output <= 3)
|
||||
{
|
||||
snprintf(txt, 30, "maps/original_%d.txt", output);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(txt, 30, "maps/custom_%d.txt", output - 4);
|
||||
}
|
||||
if (targets != NULL) free(targets);
|
||||
if (tab2d != NULL) free2D(tab2d, SIZE_PLAY);
|
||||
tab2d = creatArea2D(SIZE_PLAY, SIZE_PLAY);
|
||||
targets = fileToTab2D(txt, tab2d, SIZE_PLAY, playerPos, &nbr_targets);
|
||||
output = inGameLoop(tab2d, &dim, playerPos, targets, nbr_targets, &display_user, &score_user, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//screenDisplay(tab2d, SIZE_PLAY, SIZE_PLAY);
|
||||
SDL_DestroyWindow (display_user.window);
|
||||
SDL_DestroyRenderer (display_user.renderer);
|
||||
free2D (tab2d, SIZE_PLAY);
|
||||
free (playerPos);
|
||||
free (targets);
|
||||
if (tab2d != NULL)free2D (tab2d, SIZE_PLAY);
|
||||
if (playerPos != NULL)free (playerPos);
|
||||
if (targets != NULL)free (targets);
|
||||
SDL_Quit ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user