<?xml version='1.0'?>
<?xml:stylesheet type="text/xsl" href="function.xsl" ?>
<function-list>
  <function>
    <name>SpriteCollisionEdge Event</name>
    <description>This event is fired when a sprite hits the edge of the Game Control window.</description>
    <syntax>Game1_SpriteCollisionEdge(ByVal lSpriteNum As Long, ByVal iEdges as Integer)</syntax>
    <param-list>
      <param>
        <name>lSpriteNum</name>
	    <description>Long. Unique sprite ID of the sprite involved in the collision.</description>
      </param>
      <param>
        <name>iEdges</name>
	    <description>Long. Tells which edges the sprite collided with (see below for values).</description>
      </param>
    </param-list>
	<remarks>To diminish the rectangle that triggers collision events, use the SpriteDiminishCollisionRect method.</remarks>
	<example>
' Values for iEdges parameter:
' 0 = collided with right (east) side
' 1 = collided with bottom right (southeast) side
' 2 = collided with bottom (south) side)
' 3 = collided with bottom left (southwest) side
' 4 = collided with left (west) side
' 5 = collided with top left (northwest) side
' 6 = collided with top (north) side
' 7 = collided with top right (northeast) side

Private Sub Game1_SpriteCollisionEdge(ByVal lSpriteNum As Long, ByVal iEdges As Integer)
    ' Sprite has left the viewport, make it bounce
    ' (change it's angle and velocity)
    Dim iMinAngle As Integer, iMaxAngle As Integer
    Dim iAngle As Integer, iVelocity As Integer
    
    Select Case iEdges
        Case 1:
            iMinAngle = 135: iMaxAngle = 225
        Case 2:
            iMinAngle = 180: iMaxAngle = 270
        Case 3:
            iMinAngle = 225: iMaxAngle = 315
        Case 4:
            iMinAngle = 270: iMaxAngle = 359
        Case 5:
            iMinAngle = 0: iMaxAngle = 45
        Case 6:
            iMinAngle = 0: iMaxAngle = 90
        Case 7:
            iMinAngle = 45: iMaxAngle = 135
        Case 8:
            iMinAngle = 90: iMaxAngle = 180
    End Select
    iAngle = Int((iMaxAngle - iMinAngle + 1) * Rnd + iMinAngle)
    iVelocity = Int((9) * Rnd + 2)
    Game1.SpriteSetDirection lSpriteNum, iAngle, iVelocity
End Sub

	</example>
  </function>
</function-list>
