# Problem with Flyer Game

Well this is something that you should be able to do on your own I’ll provide the solution but first we should understand what’s really going on first don’t you think?

Why won’t my enemies re-spawn?

Let’s take a look at the instances of rock that you made

``````var rock1 = createSprite(-50, randomNumber(0, 400));
rock1.setAnimation("rock1");
rock1.scale = .2;
rock1.velocityX = 5; // this is what we care about on both of them
var rock = createSprite(randomNumber(0, 400), -50);
rock.setAnimation("rock");
rock.velocityY = 5; // this one as well
rock.scale = .2;
``````

by looking at this sample of your code you should be able to deduce that rock1 is traveling on the x-plane while rock is traveling on the y-plane, now lets also look at the loop in which you want the enemies to re-spawn

``````// LOOPING
if (rock.x > 450) {
rock.x = 50;
rock.y = randomNumber(50, 350);
}
if (rock1.y > 450) {
rock1.y = 50;
rock1.x = randomNumber(50, 350);
}
``````

What’s actually wrong with my program?

figure it out yet? if not here your doing the exact opposite comparisons on the velocity that your started your rocks in which means rock.x will never reach 450 & rock1.y will never reach 450 either so you either have to

1:) swap comparisons or change the spawn position of both rocks along with the set velocities at the start

2:) modify comparisons in the loop

Solution Example

since you wanted the loop explicitly fixed here I will do the 2nd option i provided in my explanation

``````if (rock.y > 450) {
rock.y = 0;
rock.x = randomNumber(50, 350);
}
if (rock1.x > 450) {
rock1.x = 0;
rock1.y = randomNumber(50, 350);
}
``````

Hope this helps!