Added auto-shoot!

This commit is contained in:
Alberto De Nardis 2025-11-07 13:37:00 +01:00
parent 9d662a1509
commit 22c3c33305

11
main.c
View file

@ -41,6 +41,7 @@ int main() {
int pause = 0;
int max_height;
int max_width;
int auto_shoot = 0;
// Giocatore
struct game_obj player = {};
@ -124,7 +125,7 @@ int main() {
player.x += 2;
} else if (input == KEY_LEFT && !pause && 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].y = player.y - 1;
bullet[next_bullet].active = 1;
@ -132,6 +133,14 @@ int main() {
pause = !pause;
} else if (input == 'q') {
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