feat: add bomb fish
This commit is contained in:
parent
b8d78b2620
commit
04d24f0f9e
|
@ -142,6 +142,9 @@ void display_game() {
|
|||
else if(fishes[i][2] == FT_LIFE){
|
||||
u8g2.drawXBMP(fishes[i][0], fishes[i][1], 16, 16, fish_life);
|
||||
}
|
||||
else if(fishes[i][2] == FT_BOMB){
|
||||
u8g2.drawXBMP(fishes[i][0], fishes[i][1], 16, 16, fish);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,19 +174,11 @@ void init_game(){
|
|||
}
|
||||
}
|
||||
|
||||
void compute_fishes_position(){
|
||||
short fish_step = (200 + score)/200;
|
||||
for (int i = 0; i < NUM_FISHES; i++) {
|
||||
if(fishes[i][0] != NULL){
|
||||
//fish alive
|
||||
if(fishes[i][0] <= fish_step)
|
||||
{
|
||||
fishes[i][0] = random(MAX_X+1,255);
|
||||
void missed_or_bomb(){
|
||||
score = score - 10;
|
||||
lives = lives - 1;
|
||||
|
||||
play_sound(NOTE_B1,300);
|
||||
//end game
|
||||
if (score <= 0 || lives == 0){
|
||||
play_sound(NOTE_G1,300);
|
||||
play_sound(NOTE_F1,300);
|
||||
|
@ -193,6 +188,17 @@ void compute_fishes_position(){
|
|||
game_init = true;
|
||||
}
|
||||
}
|
||||
|
||||
void compute_fishes_position(){
|
||||
short fish_step = (200 + score)/200;
|
||||
for (int i = 0; i < NUM_FISHES; i++) {
|
||||
if(fishes[i][0] != NULL){
|
||||
//fish alive
|
||||
if(fishes[i][0] <= fish_step)
|
||||
{
|
||||
fishes[i][0] = random(MAX_X+1,255);
|
||||
missed_or_bomb();
|
||||
}
|
||||
//move fish to the left
|
||||
else{
|
||||
fishes[i][0] = fishes[i][0] - fish_step;
|
||||
|
@ -201,25 +207,34 @@ void compute_fishes_position(){
|
|||
if( (posX > (fishes[i][0] - 8) && posX < (fishes[i][0] + 8) )
|
||||
&& (posY > (fishes[i][1] - 8) && posY < (fishes[i][1] + 8) )
|
||||
){
|
||||
if(fishes[i][2] == FT_LIFE){
|
||||
lives = lives + 1;
|
||||
}
|
||||
fishes[i][0] = random(128,255);
|
||||
//random type
|
||||
short rdm_type = random(1,100);
|
||||
if(rdm_type < 90){
|
||||
fishes[i][2] = FT_NORMAL;
|
||||
if(fishes[i][2] == FT_BOMB){
|
||||
missed_or_bomb();
|
||||
}
|
||||
else{
|
||||
fishes[i][2] = FT_LIFE;
|
||||
}
|
||||
|
||||
play_sound(NOTE_B5,100);
|
||||
score = score + 10;
|
||||
if (score > max_score){
|
||||
max_score = score;
|
||||
}
|
||||
}
|
||||
|
||||
if(fishes[i][2] == FT_LIFE){
|
||||
lives = lives + 1;
|
||||
}
|
||||
fishes[i][0] = random(MAX_X+1,255);
|
||||
//random type
|
||||
short rdm_type = random(1,100);
|
||||
if(rdm_type < 80){
|
||||
fishes[i][2] = FT_NORMAL;
|
||||
}
|
||||
else if (rdm_type >= 80 and rdm_type < 90){
|
||||
fishes[i][2] = FT_LIFE;
|
||||
}
|
||||
else{
|
||||
fishes[i][2] = FT_BOMB;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue