Open sesquipedalian-dev opened 7 years ago
A side effect of this is that the asteroids can sometimes hit the player pretty easily on initial load - maybe they start outside the exclusion area, but because there's a few frames the user doesn't get to see, they sometimes get hit right away. Solutions to that (apart from fixing the slow spawning issue):
Added a caching system to this, but it still takes hella time on load. Maybe fork it off as a background process?
The asteroid spawner calculates a random position for the asteroid by trying not to collide with anything else. The current thing constructs a valid range by taking all possible x/y coords, pulling out any coords that are contained with an existing asteroid's polygon, pulling out an exclusion zone around the player, and then randomly shuffling that collection and pulling one out of it. This seems to take a good 4-5 seconds on initial start up.
Optimization ideas: