ShapeHitShape
State = ShapeHitShape(ShapeIndex1, ShapeX1#, ShapeY1#, ShapeIndex2, ShapeX2#, ShapeY2#)
 
Parameters:

    ShapeIndex1 = The index of the first shape you wish to test
    ShapeX1# = The base X position of the test shape1
    ShapeY1# = The base Y position of the test shape1
    ShapeIndex2 = The index of the second shape you wish to test
    ShapeX2# = The base X position of the test shape2
    ShapeY2# = The base Y position of the test shape2
Returns:

    State = The hit state of the circle (0 = outside of shape, 1 = intersects shape)
 

      The ShapeHitShape function checks if a Shape overlaps / intersects another vector shape. It will return a True (1) when they intersect, or a False(0) when it does not.



FACTS:


      * None



Mini Tutorial:


      This example checks if a hollowed shape positioned at the mouse pointer position, hits a moving shape.

  
; Create a convert shape to check collisions against
  MyShape=NewConvexShape(50,7)
  
; Init some variables to hold our shapes position
  ShapeX#=100
  ShapeY#=100
  
; Create another hollow shape to test collisions with
  TempShape=NewConvexShape(80,10)
  
  CollisionShape = NewConvexShape(100,10)
  MergeShape TempShape,CollisionShape
  
; delete the Temp shape
  DeleteShape TempShape
  
; Start a Do/Loop
  Do
   ; Clear the sreen
     Cls RGB(0,0,0)
     
   ; Display a message
     Print "Testing Shape Collision"
     
   ; Rotate our test shape
     RotateShape MyShape,Angle#,1
     
   ; Bump the Rotation angle
     Angle#=WrapAngle(angle#,1)
     
   ; Move and clip the Shapes position
     Shapex#=Mod(Shapex#+1,GetScreenWidth())
     
   ; Read the mouse pointers position
     x#=MouseX()
     y#=MouseY()
     
   ; Draw the test Collision Shape
     DrawShape CollisionShape,x#,y#,2
     
     
   ; Check if a Box hits the shape
     If ShapeHitShape(CollisionShape,x#,y#,MyShape,Shapex#,Shapey#)=true
        
      ; Set the pen's ink colour to yellow
        Ink RGB(255,255,0)
        
      ; display a message
        Print "Shapes are touching"
        
      ; set the ink colour to RED
        Ink RGB(255,0,0)
        
     Else
        
      ; If the box didn't hit the shape, then
      ; Set then ink colour to White
        Ink RGB(255,255,255)
        
     EndIf
     
   ; Draw the filled shape
     DrawShape MyShape,ShapeX#,ShapeY#,2
     
     
   ; Display the screen
     Sync
   ; loop back to the do
  Loop
  
  




      This example outputs,





 
Related Info: BoxHitShape | CircleHitShape | LineHitShape | PointHitShape :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com