|
|
Re: objects placed into arrays
|
Posted: Dec 6, 2005 10:46 PM
|
|
The list just stores every valid startpoint to insert objects of a certain length.
But don't worry, it wouldn't have worked anyway since a) it only stores points to insert objects horizontally and b) now I know that you want to play battle ships and need to insert objects of a variable length.
It would have been a good solution for storing many objects fast and without a endless loop
So forget all about the list.
1) Create a random point (x,y) and create a random direction (values from 0 to 3). 2) check if the random point and the n fields in the given direction are not occpied. If they are, return to 1). 3) occupy the fields with your ship.
Since you have only a few ships, you won't end in a endless loop.
|
|