Edge
Previous Top Next

Returns a number that represents the boundary that the sprite collided with.
Syntax: Edge As Int32
This value should be used inside the CollisionEdge event sub.

Edge values:
1 - East wall
2 - Southeast corner
3 - South
4 - Southwest
5 - West
6 - Northwest
7 - North
8 - NorthEast

Example:
Sub gw_CollisionEdge
'This event occurs when a sprite hits one of the boundaries.
      sprite.Value = gw.Sprite1 'Get the sprite.
      If gw.SpriteIndex(sprite.Value) = 0 Then Return 'Ignore the explode sprite.
      Select gw.Edge 'Check the edge value and set the new direction accordingly.
    Case 1 'east
      iMinAngle = 135 : iMaxAngle = 225
    Case 2 'southeast
      iMinAngle = 180 : iMaxAngle = 270
    Case 3 'south
      iMinAngle = 225 : iMaxAngle = 315
    Case 4 'southwest
      iMinAngle = 270 : iMaxAngle = 359
    Case 5 'west
      iMinAngle = 0 : iMaxAngle = 45
    Case 6 'northwest
      iMinAngle = 0 : iMaxAngle = 90
    Case 7 'north
      iMinAngle = 45 : iMaxAngle = 135
    Case 8 'northeast
      iMinAngle = 90 : iMaxAngle = 180
      End Select
      angle = Rnd(iMinAngle,iMaxAngle)
      sprite.Direction = angle 'Set the new direction.
      Sound("bounce.wav") 'Play the sound.
End Sub