Code archives/Algorithms/Homing physics ( 2D )

Blitz3D Forums/Blitz3D Programming/Code archives/Algorithms/Homing physics ( 2D )

techjunkie(Posted 2004) [#1]
Ehhh... Maybe a stupid question but what does the lines,

For ee.enemy=Each enemy

If ee<>e

dex#=(e\x-ee\x)
dey#=(e\y-ee\y)

do?

ee isn't declared in the code?!?!


techjunkie(Posted 2004) [#2]
Is it the old value of e?


BlitzSupport(Posted 2004) [#3]

For ee.enemy=Each enemy

If ee<>e

dex#=(e\x-ee\x)
dey#=(e\y-ee\y)

do?

ee isn't declared in the code?!?!



It is -- look at the For ee... line. He's using ee.enemy to cycle through the list of enemies. It's being compared against the outer For e... loop to check each entry against all the others:

; Run through list of 'enemies' in this outer loop...

For e.enemy = each enemy

    ; OK, inside that loop, we have another loop to check each list entry against the current 'e'...

    For ee.enemy = each enemy

        ; But if e = ee we're looking at the same entry, so ignore it...

        If e <> ee
            Blah ()
        EndIf

    Next

Next



techjunkie(Posted 2004) [#4]
Ahhh... I understand... It's an internal loop, within the loop - just to check the values against all enemies...

Thanks!!!


poopla(Posted 2004) [#5]
You could Interpolate the position of the homing item by the coordinates of the two objects.