Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function checkTrace(ByVal enemiePosition As Point, ByVal playerPosition As Point, ByVal playerYaw As Single, ByRef fraction As Single) As Boolean
- For radius As Integer = 0 To 50
- Dim punkt As Point = RotatePoint(playerPosition, New Point(playerPosition.X, playerPosition.Y - radius), playerYaw + 180)
- If (enemiePosition.X = punkt.X) And (enemiePosition.Y = punkt.Y) Then
- Return True
- End If
- For Each building In buildings
- If (building.x = punkt.X) Or (building.x + building.width = punkt.X) Or (building.x < punkt.X And building.x + building.width <= punkt.X) Then
- If (building.y = punkt.Y) Or (building.y + building.height = punkt.Y) Or (building.y < punkt.Y And building.y + building.height <= punkt.Y) Then
- fraction -= building.fraction
- If fraction <= 0 Then
- Return False
- Else
- Continue For
- End If
- End If
- End If
- Next
- Next
- Return False
- End Function
- Shared Function RotatePoint(ByVal Point1 As Point, ByVal Point2 As Point, ByVal Rotation As Integer) As Point
- Dim LineLenght As Integer = CInt(Math.Sqrt((Point1.X - Point2.X) * (Point1.X - Point2.X) + (Point1.Y - Point2.Y) * (Point1.Y - Point2.Y)))
- Point2.X = CInt(Math.Sin(Rotation * (Math.PI / 180)) * LineLenght + Point1.X)
- Point2.Y = CInt(Math.Cos(Rotation * (Math.PI / 180)) * LineLenght + Point1.Y)
- Return Point2
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement