Hi. I'm workin on space shooter. Trying to spawn enemy ships top of screen with random X position. If enemy ship not explodes and goes outside the window, I want to random it again(the x position) and position it outside (top, like y = -100.0f) the window. First random is good, lets say 155, the next randoms are 165, 175,185... etc.
i have enemy class and Init function
its basically;
void Init(){
srand(time(NULL));
enemyShip.setPosition(rand()%350 + 50, -100.0f);
}
and i check enemy's y position in everyframe. if y pos > 750 -> init the same ship with random X and -100.0f y position.
screen width:400, height:700, enemyship size x,y = 50.0f