Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sf::Clock enemyTime;
- sf::Texture birdTexture; //load bird texture
- sf::Sprite birdImage; //bird image
- if (!birdTexture.loadFromFile("images/bird1.png")){
- std::cout << "Could not load bird image\n";
- }
- std::vector<sf::Sprite> enemy(100, sf::Sprite(birdTexture));
- std::vector<sf::FloatRect> enemybounds(100);
- for (int i = 0; i < 10; i++){
- enemybounds[i] = enemy[i].getGlobalBounds();
- }
- float eTime = enemyTime.restart().asSeconds();
- for (int i = 0; i<10; i++)
- {
- float x = rand() % 10 + 1; // dist is the visible width of the screen
- enemy[i].setPosition(x, 180);
- }
- float enemyspeed = 200.f;
- for (int i = 0; i < 10; i++){
- enemy[i].move(0.f, enemyspeed * eTime);
- }
- for (int i = 0; i<10; i++){
- window.draw(enemy[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment