diff --git a/library/World/world.c b/library/World/world.c index 6c9a357cae0bac302212eb7d86866121accf83cf..19e60a0a531ab0f8c83f2d3718e87af3159cda33 100644 --- a/library/World/world.c +++ b/library/World/world.c @@ -24,6 +24,7 @@ void update_data(world_t *world){ collide(world->vaisseau, world->ligneArriver, world); if (world->vaisseau->y < world->ligneArriver->y){ world->gamestate = 1; + restart(world); } if (timer_update_s(world) != 0){ world->temps_str[0] = '\0'; @@ -183,7 +184,7 @@ void init_shop(world_t * world){ void collide(sprite_t *sp1, sprite_t *sp2, world_t *world){ if (sprites_collide(sp1, sp2)){ - if (strcmp(sp2->id, "1") == 0){ + if (strcmp(sp2->id, "1") == 0){ // Si le sprite est un mur world->gamestate = 1; restart(world); }else if(strcmp(sp2->id, "2") == 0){ @@ -200,7 +201,7 @@ void collide(sprite_t *sp1, sprite_t *sp2, world_t *world){ break; } remove_wall(world, sp2->indice); - }else if(strcmp(sp2->id, "z") == 0){ + }else if(strcmp(sp2->id, "z") == 0){ // Si le sprite est la ligne d'arrivée world->gamestate = 1; restart(world); }else if(strcmp(sp2->id, "3") == 0){ diff --git a/library/World/world.h b/library/World/world.h index abb2e66077b500adb389bc992153a993163c1609..d13d4134b7e4cdf06ef5928b317feeaf6bba76d2 100644 --- a/library/World/world.h +++ b/library/World/world.h @@ -118,6 +118,13 @@ typedef struct world_s world_t; void init_data(world_t * world); +/** + * @brief La fonction qui initialise les données du monde + * + * @param world + */ +void restart(world_t *world); + /** * \brief La fonction met à jour les données en tenant compte de la physique du monde * \param les données du monde diff --git a/library/World/world.o b/library/World/world.o index f44466a0cfb20b27ccab08bdcdc428e9760236ee..08e7b91b67ae1671b4c7ecc3dbfc3667890e980b 100644 Binary files a/library/World/world.o and b/library/World/world.o differ diff --git a/main.c b/main.c index d37cf484a3a5ad9da3593006958e68f3f87c6627..82b2601f9c2e30fdc06bb4b03424da77637eff0c 100644 --- a/main.c +++ b/main.c @@ -53,7 +53,6 @@ void handle_events(SDL_Event *event,world_t *world){ case SDLK_z: if (world->speed_h < INITIAL_SPEED+6){ world->speed_h += 1; - printf("%f\n", world->speed_h); updateProgressBarre(world->pgb, 100.0/(float)(INITIAL_SPEED+6)*(world->speed_h)); } @@ -79,10 +78,10 @@ void handle_events(SDL_Event *event,world_t *world){ if (event->type == SDL_MOUSEBUTTONDOWN){ if (world->gamestate == 1){ if (event->button.button == SDL_BUTTON_LEFT){ - printf("mouse(%d, %d) world rect (%d %d %d %d)\n", world->mouseX, world->mouseY, world->play->rect.x,world->play->rect.y,world->play->rect.w,world->play->rect.h ); if (collidePoint(world->play, world->mouseX, world->mouseY)){ modify_str(world->coins_str, int_to_str(world->money)); world->gamestate = 0; + } if (collidePoint(world->magasin, world->mouseX, world->mouseY)){ world->gamestate = 2; @@ -116,7 +115,6 @@ void handle_events(SDL_Event *event,world_t *world){ } } if (collidePoint(world->exit_shp, world->mouseX, world->mouseY)){ - printf("exit"); world->gamestate=1; } } @@ -176,7 +174,7 @@ int main( int argc, char* args[] ) frameTime = SDL_GetTicks() - ticks; //gestion des évènements handle_events(&event,&world); - + printf("gamestate : %d\n", world.gamestate); //mise à jour des données liée à la physique du monde update_data(&world); diff --git a/main.o b/main.o index 698b9ed955e32c71e4f4594e7ef9a076b8f50b5a..407e1dad3af00d39d568befb79ceb6530d923074 100644 Binary files a/main.o and b/main.o differ diff --git a/spacecorridor.exe b/spacecorridor.exe index 7d24cf169dcd63f6da1f4b14f7e2b046650f958e..6904e6b0852d03ddb62bc560c547f4ccfb932730 100644 Binary files a/spacecorridor.exe and b/spacecorridor.exe differ