Meteoryty są spawnowane automatycznie co 1 sekunde, max 5 meteorytów na plansze

This commit is contained in:
2024-11-20 14:57:40 +01:00
parent 1cd9f9b950
commit f1a3449d47
6 changed files with 32 additions and 12 deletions

View File

@@ -1,5 +1,4 @@
#include <iostream>
#include <random>
#include "SFML/Graphics.hpp"
#include "headers/Player.h"
@@ -65,13 +64,9 @@ int main()
if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) ship.shoot();
if(sf::Mouse::isButtonPressed(sf::Mouse::Right)) ship.alternate_shoot();
// TODO: Meteory na jednym poziomie ze statkiem
// TODO: Kolizje
// Generate a new meteor at a random position at the top of the screen
if (sf::Keyboard::isKeyPressed(sf::Keyboard::M)) {
plansza.spawn_meteor();
}
plansza.spawn_meteor();
// Update and draw meteors
for (auto& meteor : plansza.getMeteors()) {
@@ -84,6 +79,7 @@ int main()
window.draw(bullet.getSprite());
}
plansza.update_meteors();
ship.updateBullets();
window.draw(ship.getSprite());