RPiPico-Holonome2023/Score.c
2023-05-20 03:41:02 +02:00

49 lines
1001 B
C

#include "pico/stdlib.h"
#include "i2c_annexe.h"
#include "Score.h"
#define SCORE_INITIAL 5
uint32_t Score_nb_cerises=0;
uint32_t Score_nb_points=0;
uint32_t Score_funny_action=0;
uint32_t Score_gateau=0;
uint32_t Score_pieds_dans_plat=0;
void Score_recalcule(){
Score_nb_points = SCORE_INITIAL;
if(Score_nb_cerises > 0){
Score_nb_points += Score_nb_cerises + 5;
}
Score_nb_points += Score_funny_action;
Score_nb_points += Score_pieds_dans_plat;
Score_nb_points += Score_gateau;
}
void Score_actualise(){
Score_recalcule();
i2c_annexe_envoie_score(Score_nb_points);
}
void Score_ajout_gateau(uint32_t nb_gateau){
Score_gateau += nb_gateau;
Score_actualise();
}
void Score_set_funny_action(){
Score_funny_action = 5;
Score_actualise();
}
void Score_set_pieds_dans_plat(){
Score_pieds_dans_plat = 15;
Score_actualise();
}
void Score_ajout_cerise(uint32_t nb_cerises){
Score_nb_cerises += nb_cerises;
Score_actualise();
}