Added auto-shoot!
This commit is contained in:
parent
9d662a1509
commit
22c3c33305
1 changed files with 11 additions and 2 deletions
13
main.c
13
main.c
|
|
@ -41,6 +41,7 @@ int main() {
|
||||||
int pause = 0;
|
int pause = 0;
|
||||||
int max_height;
|
int max_height;
|
||||||
int max_width;
|
int max_width;
|
||||||
|
int auto_shoot = 0;
|
||||||
|
|
||||||
// Giocatore
|
// Giocatore
|
||||||
struct game_obj player = {};
|
struct game_obj player = {};
|
||||||
|
|
@ -124,7 +125,7 @@ int main() {
|
||||||
player.x += 2;
|
player.x += 2;
|
||||||
} else if (input == KEY_LEFT && !pause && player.x > 2) {
|
} else if (input == KEY_LEFT && !pause && player.x > 2) {
|
||||||
player.x -= 2;
|
player.x -= 2;
|
||||||
} else if (input == ' ' && bullet_attivi < BULLET_N && !pause) {
|
} else if (!auto_shoot && input == ' ' && bullet_attivi < BULLET_N && !pause) {
|
||||||
bullet[next_bullet].x = player.x;
|
bullet[next_bullet].x = player.x;
|
||||||
bullet[next_bullet].y = player.y - 1;
|
bullet[next_bullet].y = player.y - 1;
|
||||||
bullet[next_bullet].active = 1;
|
bullet[next_bullet].active = 1;
|
||||||
|
|
@ -132,6 +133,14 @@ int main() {
|
||||||
pause = !pause;
|
pause = !pause;
|
||||||
} else if (input == 'q') {
|
} else if (input == 'q') {
|
||||||
player.active = 0;
|
player.active = 0;
|
||||||
|
} else if (input == 'g') {
|
||||||
|
auto_shoot= !auto_shoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto_shoot && bullet_attivi < BULLET_N && !pause) {
|
||||||
|
bullet[next_bullet].x = player.x;
|
||||||
|
bullet[next_bullet].y = player.y - 1;
|
||||||
|
bullet[next_bullet].active = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aggiorna proiettile
|
// Aggiorna proiettile
|
||||||
|
|
@ -238,4 +247,4 @@ int main() {
|
||||||
endwin();
|
endwin();
|
||||||
printf("Gioco terminato.\n");
|
printf("Gioco terminato.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue