diff --git a/carrot_game/carrot_game.ino b/carrot_game/carrot_game.ino index 051c0bf..920624e 100644 --- a/carrot_game/carrot_game.ino +++ b/carrot_game/carrot_game.ino @@ -9,8 +9,8 @@ #include "sound.h" const bool SOUND_ENABLE = false; -const short initX = 0; -const short initY = 48; +const short INIT_X = 0; +const short INIT_Y = 48; const unsigned long display_interval = 100; const unsigned long nunchuk_interval = 100; @@ -21,9 +21,9 @@ U8G2_ST7920_128X64_2_SW_SPI u8g2(U8G2_R0, /* clock=*/ 2, /* data=*/ 10, /* cs=*/ ArduinoNunchuk nunchuk = ArduinoNunchuk(); Tone tone1; -short posX = initX; -short posY = initY; -unsigned int nextLaneY = initY - 16; +short posX = INIT_X; +short posY = INIT_Y; +unsigned int nextLaneY = INIT_Y - 16; unsigned long last_display = millis(); unsigned long last_nunchuck = millis(); unsigned long last_note = millis(); @@ -110,9 +110,10 @@ void display_game() { } void compute_fishes_position(){ + short fish_step = (200 + score)/100; for (int i = 0; i < 8; i++) { if(fishes[i][0] != NULL){ - if(fishes[i][0] <= 2) + if(fishes[i][0] <= fish_step) { fishes[i][0] = 128; score = score - 10; @@ -128,7 +129,7 @@ void compute_fishes_position(){ } } else{ - fishes[i][0] = fishes[i][0] - (200 + score)/100; + fishes[i][0] = fishes[i][0] - fish_step; } //does carrot eat the fish if( (posX > (fishes[i][0] - 8) && posX < (fishes[i][0] + 8) ) && (posY > (fishes[i][1] - 8) && posY < (fishes[i][1] + 8) )){ @@ -148,11 +149,11 @@ void compute_cat_position() { posX = posX + 2; } else { - posX = initX; + posX = INIT_X; if (posY < 48) { posY = posY + 16; } else { - posY = initY; + posY = INIT_Y; } } } @@ -258,8 +259,8 @@ void loop(void) { if(game_init){ game_init = false; //set default pos to avoid issue - posX = initX; - posY = initY; + posX = INIT_X; + posY = INIT_Y; } } }