In your code, you shouldn't be looping over random numbers between 0 and 9999 in a double nested loop. instead x should be a random number between 0 and screen width, and y a random number between 0 and screen height. you only need one loop between 0 and 19 where you initialize each enemy as you go. Hope that makes sense. My demo key above has a function that does about what you are looking for.