PointHitShape
State = PointHitShape(PointX#, PointY#, ShapeIndex, ShapeX#, ShapeY#)
 
Parameters:

    PointX# = The X coordinate of the test point
    PointY# = The Y coordinate of the test point
    ShapeIndex = The index of the shape you wish to test
    ShapeX# = The X coordinate of the test shape
    ShapeY# = The Y coordinate of the test shape
Returns:

    State = The hit state of the point (0 = outside of shape, 1 = inside shape)
 

     The PointHitShape function checks if a point is inside a vector shape. It will return a true (1) when the point is inside, or a false.



FACTS:


     * None



Mini Tutorial:


      This example checks if the mouse pointer ever hits a moving shape.

  
; Limit the Speed of the program to 100fps or less
  SetFPS 100
  
; Create a convert shape to check collisions against
  MyShape=NewConvexShape(50,7)
  
; Init some variables to hold our shapes position
  ShapeX#=100
  ShapeY#=100
  
  
; Start a So/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()
     
   ; Check if the Mouse POinter hits the shape
     If PointHitShape(x#,y#,MyShape,Shapex#,Shapey#)=true
        
      ; Set the pen's ink colour to yellow
        Ink RGB(255,255,0)
        
      ; display a message
        Print "Point Hit Shape"
      ; set the ink colour to RED
        Ink RGB(255,0,0)
     Else
      ; If the point 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 when the mouse is over the shape.





 
Related Info: BoxHitShape | CircleHitShape | LineHitShape | ShapeHitShape :
 


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