Skip to content
Snippets Groups Projects
Commit 4659d8eb authored by SmallIshMink's avatar SmallIshMink
Browse files

FIN (SmallishMink : Moulias Mattheo)

parent c64b5b95
Branches master
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ void update_data(world_t *world){ ...@@ -24,6 +24,7 @@ void update_data(world_t *world){
collide(world->vaisseau, world->ligneArriver, world); collide(world->vaisseau, world->ligneArriver, world);
if (world->vaisseau->y < world->ligneArriver->y){ if (world->vaisseau->y < world->ligneArriver->y){
world->gamestate = 1; world->gamestate = 1;
restart(world);
} }
if (timer_update_s(world) != 0){ if (timer_update_s(world) != 0){
world->temps_str[0] = '\0'; world->temps_str[0] = '\0';
...@@ -183,7 +184,7 @@ void init_shop(world_t * world){ ...@@ -183,7 +184,7 @@ void init_shop(world_t * world){
void collide(sprite_t *sp1, sprite_t *sp2, world_t *world){ void collide(sprite_t *sp1, sprite_t *sp2, world_t *world){
if (sprites_collide(sp1, sp2)){ 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; world->gamestate = 1;
restart(world); restart(world);
}else if(strcmp(sp2->id, "2") == 0){ }else if(strcmp(sp2->id, "2") == 0){
...@@ -200,7 +201,7 @@ void collide(sprite_t *sp1, sprite_t *sp2, world_t *world){ ...@@ -200,7 +201,7 @@ void collide(sprite_t *sp1, sprite_t *sp2, world_t *world){
break; break;
} }
remove_wall(world, sp2->indice); 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; world->gamestate = 1;
restart(world); restart(world);
}else if(strcmp(sp2->id, "3") == 0){ }else if(strcmp(sp2->id, "3") == 0){
......
...@@ -118,6 +118,13 @@ typedef struct world_s world_t; ...@@ -118,6 +118,13 @@ typedef struct world_s world_t;
void init_data(world_t * world); 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 * \brief La fonction met à jour les données en tenant compte de la physique du monde
* \param les données du monde * \param les données du monde
......
No preview for this file type
...@@ -53,7 +53,6 @@ void handle_events(SDL_Event *event,world_t *world){ ...@@ -53,7 +53,6 @@ void handle_events(SDL_Event *event,world_t *world){
case SDLK_z: case SDLK_z:
if (world->speed_h < INITIAL_SPEED+6){ if (world->speed_h < INITIAL_SPEED+6){
world->speed_h += 1; world->speed_h += 1;
printf("%f\n", world->speed_h);
updateProgressBarre(world->pgb, 100.0/(float)(INITIAL_SPEED+6)*(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){ ...@@ -79,10 +78,10 @@ void handle_events(SDL_Event *event,world_t *world){
if (event->type == SDL_MOUSEBUTTONDOWN){ if (event->type == SDL_MOUSEBUTTONDOWN){
if (world->gamestate == 1){ if (world->gamestate == 1){
if (event->button.button == SDL_BUTTON_LEFT){ 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)){ if (collidePoint(world->play, world->mouseX, world->mouseY)){
modify_str(world->coins_str, int_to_str(world->money)); modify_str(world->coins_str, int_to_str(world->money));
world->gamestate = 0; world->gamestate = 0;
} }
if (collidePoint(world->magasin, world->mouseX, world->mouseY)){ if (collidePoint(world->magasin, world->mouseX, world->mouseY)){
world->gamestate = 2; world->gamestate = 2;
...@@ -116,7 +115,6 @@ void handle_events(SDL_Event *event,world_t *world){ ...@@ -116,7 +115,6 @@ void handle_events(SDL_Event *event,world_t *world){
} }
} }
if (collidePoint(world->exit_shp, world->mouseX, world->mouseY)){ if (collidePoint(world->exit_shp, world->mouseX, world->mouseY)){
printf("exit");
world->gamestate=1; world->gamestate=1;
} }
} }
...@@ -176,7 +174,7 @@ int main( int argc, char* args[] ) ...@@ -176,7 +174,7 @@ int main( int argc, char* args[] )
frameTime = SDL_GetTicks() - ticks; frameTime = SDL_GetTicks() - ticks;
//gestion des évènements //gestion des évènements
handle_events(&event,&world); handle_events(&event,&world);
printf("gamestate : %d\n", world.gamestate);
//mise à jour des données liée à la physique du monde //mise à jour des données liée à la physique du monde
update_data(&world); update_data(&world);
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment