EntityInView with types

Blitz3D Forums/Blitz3D Programming/EntityInView with types

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

At a quick glance, this is your problem:
Function ColourShips()
For CurrentShip.ship = Each ship
If CurrentShip\seen
EntityColor CurrentShip\geom,100,255,255
shipseen=1
Else
shipseen=0
EntityColor CurrentShip\geom,100,100,100
EndIf
Next
End Function


Imagine you can see the first ship in the collection -- shipseen gets set to one and all is well. But now imagine the next ship is out of view, the code says to set shipseen to zero if this is the case -- in effect you are telling shipseen to forget about every result except the very last.

What you really want to do is set shipseen to zero before you enter the For...Each loop, and then the only change you make to shipseen within the loop is to set it to one should the current ship be in view; if not, just leave it.