Basically I am looking for a fresh set of eyes here to see what I cannot, the code is below:
Code: Select all
Procedure GetMinimum(lval1.l , lval2.l);
  If lval1 < lval2;
    ProcedureReturn lval1;
  Else;
    ProcedureReturn lval2;
  EndIf;
EndProcedure;
Procedure GetMaximum(lval1.l , lval2.l);
  If lval1 > lval2;
    ProcedureReturn lval1;
  Else;
    ProcedureReturn lval2;
  EndIf;
EndProcedure;
Procedure SDLPixelTransparent(sprObject.l, lx.l, ly.l, lTransColour.l);
  Define lw.l = SpriteWidth(sprObject) , lh.l = SpriteHeight(sprObject);
  lTransparent = #False;
  
  If lx < lw And ly < lh ; Make sure the user put the right params in.
      StartDrawing(SpriteOutput(sprObject));
        If Point(lx, ly) =  lTransColour;
          lTransparent = #True;
        EndIf;
      StopDrawing();
  Else;
      lTransparent = #True;
  EndIf;
  
  ProcedureReturn lTransparent;
EndProcedure;
Procedure SDLCollision(sprObject1.l, lx1.l, ly1.l,  sprObject2.l, lx2.l, ly2.l);
  Define lCollision = #True;                                 We assume they are intersecting by default
  Define lw1.l = SpriteWidth(sprObject1) , lh1.l = SpriteHeight(sprObject1) , lw2.l = SpriteWidth(sprObject2) , lh2.l = SpriteHeight(sprObject2);
  
  If lx1 + lw1 < lx2 Or lx1 > lx2 + lw2;              Now we find why they might not be intersecting.
    lCollision = #False;
  ElseIf  ly1 + lh1 < ly2 Or ly2 + lh2 < ly1;
    lCollision = #False;
  EndIf;
  
  ProcedureReturn lCollision;                          Unless they didn't intersect, it will always return true.
EndProcedure;
Procedure SDLPixelCollision(sprObject1.l, lx1.l, ly1.l,  sprObject2.l, lx2.l, ly2.l, lTransColour.l);
  Define lCollision = #False;                          We assume they are not intersecting by default
  Define lw1.l = SpriteWidth(sprObject1) , lh1.l = SpriteHeight(sprObject1) , lw2.l = SpriteWidth(sprObject2) , lh2.l = SpriteHeight(sprObject2);
  Define lStartX.l , lStopX.l , lStartY.l , lStopY.l;
  
  If lx1 + lw1 < lx2 Or lx1 > lx2 + lw2 Or ly1 + lh1 < ly2 Or ly2 + lh2 < ly1;;              Now we find why they might be intersecting.
  Else;
    lStartX.l = GetMinimum(lx1 , lxl2);
    lStartY.l = GetMinimum(ly1 , lyl2);
    
     lStopX.l = GetMaximum(lx1 +  lw1, lxl2 + lw2);
     lStopY.l = GetMaximum(ly1 +  lh1, lyl2 + lh2);
     
     
     For x = lStartX To lStopX;
      For y = lStartY To lStopY;
      
        If SDLPixelTransparent(sprObject1, x + lx1, y + ly1, lTransColour)=0 And SDLPixelTransparent(sprObject2, x + lx2, y + ly2, lTransColour)=0;
          lCollision = #True;
          ProcedureReturn lCollision; 
        EndIf;
        
      Next y;
    Next x;
    
  EndIf;
  ProcedureReturn lCollision;                          Unless they did intersect, it will always return false.
EndProcedure;





