/* Voit si une action peut etre accomplie*/ void action(Pacman *pac, Fantome *ftm, score_message **msg_list) { int i, col; SDL_Rect pos = get_case(pac->position, pac->cur_direction); //Gagne une vie if(pac->score && (pac->score)%10000 == 0 && pac->nb_lives < 5) { pac->nb_lives++; pac->score+=100; } //Verifie si pacman et fantomes se rencontrent for(i=0; i<NB_GHOST; i++) { col=check_colision(pac, ftm[i]); if(col==1) { pac_death(pac); //Pacman est mort :( for(i=0; i<NB_GHOST; i++) ghost_restart(ftm+i); return; } if(col==2) { ghost_death(ftm+i); //Fantome meurt pac->ghost_eaten++; pac->score+=200*(pac->ghost_eaten); add_new_message(msg_list, 9+pac->ghost_eaten, pos); return; } } if( LEVEL[pos.y][pos.x].type == BONUS && dans_case(pac->position) ) { if(LEVEL[pos.y][pos.x].elt_type==0) //Super Pac-gomme { set_ghosts_eatable(ftm); pac->counter=SDL_GetTicks(); } else if(LEVEL[pos.y][pos.x].elt_type==1) pac->score+=100; //Cerise else if(LEVEL[pos.y][pos.x].elt_type==2) pac->score+=300; //Fraise else if(LEVEL[pos.y][pos.x].elt_type==3) pac->score+=500; //Orange else if(LEVEL[pos.y][pos.x].elt_type==4) pac->score+=700; //Pomme else if(LEVEL[pos.y][pos.x].elt_type==5) pac->score+=1000; //Melon else if(LEVEL[pos.y][pos.x].elt_type==6) pac->score+=2000; //Galboss else if(LEVEL[pos.y][pos.x].elt_type==7) pac->score+=3000; //Cloche else if(LEVEL[pos.y][pos.x].elt_type==8) { //Clé pac->score+=5000; pac->nb_keys++; } if(LEVEL[pos.y][pos.x].elt_type==9) POINTS--; //Pac-gomme add_new_message(msg_list, LEVEL[pos.y][pos.x].elt_type, pos); LEVEL[pos.y][pos.x].type=RIEN; //On l'a mangé bravo! } }
static void feed_ghosts(t_server *s) { t_player *tmp_g; t_player *dead; tmp_g = s->game.ghosts; while (tmp_g) { if (tmp_g->bag[FOOD] == 0) { dead = tmp_g; tmp_g = tmp_g->next_g; ghost_death(s, dead); } else { tmp_g->bag[FOOD] -= 1; tmp_g = tmp_g->next_g; } } }