Hi! I am working on a game right now and spawn "baubles". I used an Array to check if a spawnpoint is already occupied to prevent overlapping of baubles. First it seems to work fine and the array saves the data where baubles spawned and the array entries are set back to 0 when an bauble despawns or gets destryed by a touch. But when it runs for a while (normal speed or with increased speed in debgger) some values in the array stay at 1 and are not re-set.
This is my very first time I used an array, maybe I made a mistake somewhere? Can an experienced user take a look at the following code to see if I did something wrong, please?
Spawning (checks array if spawnpoint is empty or get a new one if already occupied):
<img src="http://img5.fotos-hochladen.net/uploads/baublespawnarra7vnw03z4gq.jpg" border="0" />
(Note: only problem I see right now is the while loop, if all array entries are 1 it creates an endless loop - still thinking about a solution but it "should" never happen because baubles despawn after a few seconds)
Destroyin (resetting array value, same for despawning when lifetime reaches zero):
<img src="http://img5.fotos-hochladen.net/uploads/baublespawnarrazodc81psrv.jpg" border="0" />
After letting it run for a whil this is shown in the debugger:
<img src="http://img5.fotos-hochladen.net/uploads/arrayonespawne7s2gkh4yip.jpg" border="0" />
4 slots are occupied (entries with 1) but only 1 bauble is spawned right now.
Thanks in advance!