So I am making a doodle jump like game where there are platforms scrolling by but right now how I have platforms spawning is completely random. I would like the platforms to be spread apart so they weren't touching but don't have much of an idea to implement it. I was thinking of using the distance formula to check to make sure that they were apart but I was thinking that as I was creating those object I would have to check with all the previous objects before to see if they weren't colliding. Does anyone have any ideas on how to make this work efficiently?
You could keep it simple.
Randomly generate platforms, if a newly generated platform's position is overlapping, simply don't use it and randomize another position. It will work unless the platforms are very dense which they should not be.
Another way to do it is to use slots across the Y-axis and never use the same Y slot. For instance if the height of the screen is 100 units and a platform's height is 5 units, divide the screen into 20 discrete logical slots and pick one at random and never pick the same one twice. This could be accomplished by storing the empty slots in a pool.
In general arrays are not very fast
O(N) when you need to remove a random item. To be able to quickly remove items from an array, you may want to shuffle the array and only pick items from the end. In your specific case the size of the array should be
< 1000 so it will likely have no noticeable effect.
You may also simply want to shuffle the array and then iterate on the array in order, never reusing items your previously picked.