Hello, I am a newbie.
I have problem with my program,i make a program to spawn some object falling from top with random area, but my object spawn together,can you teach me how to make my object spawn with some delay. Thanks
My Code
#include <SFML/Graphics.hpp>
#include <stdlib.h>
#include <time.h>
using namespace sf;
int main()
{
srand(time(0));
RenderWindow window(VideoMode(1200,600),"PROJECT");
int k = 0;
float x[50],xb[50],y[50];
for(int i = 0; i < 50; i++){
x[i] = 0;
y[i] = 0;
}
Texture buah1,latar;
buah1.loadFromFile("pir.png");
latar.loadFromFile("background.png");
Sprite pir(buah1),background(latar);
while(window.isOpen()){
Event tutup;
while(window.pollEvent(tutup)){
if(tutup.type == Event::Closed)
window.close();
}
window.clear(Color::White);
window.draw(background);
for(int i = 0; i < 50; i++){
if(k == i){
xb[i] = rand() % 1200;
x[i] = xb[i];
k++;
break;
}
else continue;
}
for(int i = 0; i < 50; i++){
pir.setScale(0.2, 0.2);
pir.setPosition(x[i],y[i]);
y[i] += 0.5;
window.draw(pir);
}
window.display();
}
return EXIT_SUCCESS;
}