Here I am trying to get a rectangle to disapear behind a circle using sorting and the Compare Method, but I can only get it to use the x and y points which are at the top of each object, so if one object is smaller than another it has to move much further upwards to move behind the larger object. the example code below explains it better, look at the small rectangles in the corner of both objects, when they reach the same level only then does one move behind the other, I need to make it detect the bottom of the objects.
Strict Type Entity Field x:Float,y:Float,z:Float Field width:Int,height:Int,depth:Int Field green:Int,red:Int,blue:Int Method Update() Abstract Method Compare(other:Object) If Entity(other).z > z Return -1 Return 1 End Method End Type Type Rectangle Extends Entity Function Create:Rectangle(green,red,blue,x,y,z) Local ent:Rectangle = New Rectangle ent.x = x ent.y = y ent.z = z '+ y ent.green = green ent.red = red ent.blue = blue entity_list.AddLast(ent) Return ent End Function Method Update() SetColor red,green,blue DrawRect x,z,100,100 SetColor 255,255,255 DrawRect x,y,2,2 DrawText z,0,0 DrawText y,0,15 If KeyDown(KEY_RIGHT) x = x +1 EndIf If KeyDown(KEY_LEFT) x = x -1 EndIf If KeyDown(KEY_DOWN) y = y +1 z = z +1 EndIf If KeyDown(KEY_UP) y = y -1 z = z -1 EndIf If KeyHit(KEY_SPACE) Jump() EndIf End Method Method Jump() y=y-(Cos(40)*5) End Method End Type Type Circle Extends Entity Function Create:Circle(green,red,blue,x,y,z) Local ent:Circle = New Circle ent.x = x ent.y = y ent.z = z ent.green = green ent.red = red ent.blue = blue entity_list.AddLast(ent) Return ent End Function Method Update() SetColor red,green,blue DrawOval x,y,200,200 SetColor 255,255,255 DrawRect x,y,2,2 End Method End Type Graphics 640,480,0 Global entity_list:TList = CreateList() Global rectangle1:Rectangle = Rectangle.Create(255,0,0,60,220,220) Global circle1:Circle = Circle.Create(0,255,0,120,100,100) While Not KeyHit(KEY_ESCAPE) SortList entity_list For Local e:Entity = EachIn entity_list e.Update() Next Flip Cls Wend