Comparing 2 types

Blitz3D Forums/Blitz3D Beginners Area/Comparing 2 types

Okay...what is blue\collision?

a "pointer" to a specific entity or some sort of value (ie. 1= moveing left, 2= moveing up, etc..)

What is red\handle?

A "pointer" (to itself)? Or some other value (1=move left, etc..)

What are the ranges of these values if they arn't pointers?


The way you have that code set up...if there were 100 blue entities and another 100 red entities....the innermost section of the loop (the if-then) would execute 10,000 times (100 * 100)

If you can reduce the values tested to something with a small range (ie. red\handle can only be 0,1,2,3,4,5,6,7,8,9...same for blue\collision) then you could greatly speed up the routine by useing arrays and such...

for example if red\handle can only be in the range of 0 to 9...during your update red routine simply "report" the instance to an array

DIM array%(9)

For red.red_s = each red_s

array(red\handle)=array(red\handle)+1

Next



then to do the thing with the blues

For blue.blue_s = each blue_s

blue\collisions = blue\collisions + array(blue\collision)

Next

Otherwise if blue\collision is a pointer

for blue.blue_s = each blue_s

red = blue\collision

if red <> null then blue\collisions = blue\collisions + 1

next