I have a collision detection problem: In my prog I have 3 nested for loops. In the central loop I have a OBJECT HIT(Obj num,0) command that triggers an IF block to increment a counter. The three nested loops cycle some coords for a test object, which I test against other objects.
My problem is that if the collision detection should come out non-zero on two consecutive loops, the second one always fails. Here is the code:
count=0
for aa = -1 to 1
for bb = -1 to 1
for cc = -1 to 1
color object 65000,rgb(255,0,255)
POSITION OBJECT 65000,aa#+aa,bb#+bb,cc#+cc
oh = object hit(65000,0)
do
set cursor 0,0
print oh
sync
if rightkey() then exit
loop
wait 1
if oh>0
inc count
color object 65000,rgb(0,0,255)
endif
oh = 0
mmouse()
rem wait 1
rem sync
next cc
next bb
next aa
Sorry about the mess with rems and so on - I've been debugging but have got nowhere.
I have programmed before, but this escapes me.
If it helps, the code is part of the neighbour counting function for a 3d cellular automata prog, alias LIFE.