Programming A Random Star Sky

Hello,
I would like to have something like this:
generated automatically; a predefined (number = n% of the screen size) amount of coordinates - efficiently.
My naive approach is
and is vastly inefficient.
Any ideas?
I would like to have something like this:
generated automatically; a predefined (number = n% of the screen size) amount of coordinates - efficiently.
My naive approach is
- {l Code}: {l Select All Code}
while (listOfCoordinates < number)
randomCoordinates = generateRandomCoordinates()
if (randomCoordinates is not in listOfCoordinates)
insert randomCoordinates into listOfCoordinates
and is vastly inefficient.
Any ideas?