feat: add up dow through nunchuk

This commit is contained in:
valvin 2024-02-18 14:04:17 +01:00
parent 810745b483
commit 8a307b6435
1 changed files with 4 additions and 5 deletions

View File

@ -131,6 +131,7 @@ void display_game() {
void init_game(){
score = 0;
max_score = 0;
posX = INIT_X;
posY = INIT_Y;
for ( short i = 0 ; i < 8; i++){
@ -174,8 +175,6 @@ void compute_fishes_position(){
max_score = score;
}
}
Serial.print("score: ");
Serial.println(score);
}
}
}
@ -217,7 +216,7 @@ void compute_cat_position() {
}
//compute jump
//detect a new jump
if(nunchuk.zButton == 1 && !jump && !jumpBack && posY > 0){
if((nunchuk.zButton == 1 || nunchuk.analogY > 160) && !jump && !jumpBack && posY > 0){
Serial.println("jump!");
//tone1.play(NOTE_B4,500);
jump = true;
@ -244,7 +243,7 @@ void compute_cat_position() {
}
}
if(nunchuk.cButton == 1 && !jump && !jumpBack && posY < 48){
if((nunchuk.cButton == 1 || nunchuk.analogY < 100) && !jump && !jumpBack && posY < 48){
Serial.println("jump bottom!");
//tone1.play(NOTE_B2,500);
jumpBack = true;
@ -313,7 +312,7 @@ void loop(void) {
// Serial.print(nunchuk.analogX, DEC);
// Serial.print(' ');
// Serial.println(nunchuk.analogY, DEC);
//Serial.print(' ');
// Serial.print(' ');
// Serial.print(nunchuk.accelX, DEC);
// Serial.print(' ');
// Serial.print(nunchuk.accelY, DEC);