Public Sub MoveShips()
Dim i
As Long, d2
As Double, Px
As Double, Py
As Double, j
As Long
Dim VPx1
As Double, VPy1
As Double, VNx1
As Double, VNy1
As Double
Dim VPx2
As Double, VPy2
As Double, VNx2
As Double, VNy2
As Double
Dim t
As Long, Hitten
As Boolean, RandomAngle
As Double, Random
As Double
Dim u
As Long, X
As Double, Y
As Double
t = Rnd * 99 + 1
For i = 1
To MaxPlayers
With Player(i)
If .FramesToRespawn = 0
And .Exist
Then
.X = .X + .FX
.Y = .Y + .FY
If .PushedBy > 0
Then .PushedByTime = .PushedByTime - 1
If .PushedByTime = 0
Then .PushedBy = 0
If Sqr(.FY ^ 2 + .FX ^ 2) > .Speed
Then
.FX = Cos(AngleFromTwoPoints(.X, .Y, .X + .FX, .Y + .FY) / 180 * Pi) * .Speed
.FY = Sin(AngleFromTwoPoints(.X, .Y, .X + .FX, .Y + .FY) / 180 * Pi) * .Speed
Else
'If Abs(.LastFX - .FX) <= 0.001 Then .FX = .FX * 0.8
'If Abs(.LastFY - .FY) <= 0.001 Then .FY = .FY * 0.8
End If
.LastFX = .FX
.LastFY = .FY
If Abs(.FX) <= 0.075
Then .FX = 0
If Abs(.FY) <= 0.075
Then .FY = 0
If .HP > 0
Then
For j = 1
To Map.TrapCount
If Sqr((.X - Map.Trap(j).X) ^ 2 + (.Y - Map.Trap(j).Y) ^ 2) <= 30 + 24
Then
t = Rnd * 99 + 1
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - 50
Call CreateFallingText("-50", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(4), DSBPLAY_DEFAULT)
End If
'Ñ÷àñ ìû êàê ÷òî-íèáóäü ðàññ÷èòàåì!
Px = .X - Map.Trap(j).X
'îòíîñèòåëüíîå ðàññòîÿíèå ïî X
Py = .Y - Map.Trap(j).Y
'îòíîñèòåëüíîå ðàññòîÿíèå ïî Y
d2 = Px * Px + Py * Py
'êâàäðàò ðàññòîÿíèÿ
'TRAPS
If d2 > 0
Then
VPx1 = (Px * .FX + Py * .FY) * Px / d2
'\_ïåðïåíäèêóëÿð i
VPy1 = (Px * .FX + Py * .FY) * Py / d2
'/
VNx1 = (Py * .FX - Px * .FY) * Py / d2
'\_íîðìàëü i
VNy1 = (Px * .FY - Py * .FX) * Px / d2
'/
VPx2 = -VPx1
VPy2 = -VPy1
VNx2 = -VNx1
VNy2 = -VNy1
If Px * (VPx2 - VPx1) + Py * (VPy2 - VPy1) > 0
Then '÷òîáû íå ñëèïàëèñü
.FX = ((24 ^ (1 / 3) - 30 ^ (1 / 3)) * .FX + 2 * 30 ^ (1 / 3) * (VPx2 + VNx1)) / (24 ^ (1 / 3) + 30 ^ (1 / 3))
.FY = ((24 ^ (1 / 3) - 30 ^ (1 / 3)) * .FY + 2 * 30 ^ (1 / 3) * (VPy2 + VNy1)) / (24 ^ (1 / 3) + 30 ^ (1 / 3))
.FX = .FX - 2 * Cos(AngleFromTwoPoints(.X, .Y, Map.Trap(j).X, Map.Trap(j).Y) * Pi / 180)
.FY = .FY - 2 * Sin(AngleFromTwoPoints(.X, .Y, Map.Trap(j).X, Map.Trap(j).Y) * Pi / 180)
.X = .X + .FX
.Y = .Y + .FY
End If
If (.PushedBy = 0
And .PushedBy <> i)
Then .PushedBy = i
.PushedByTime = PushedByTime
For t = 1
To 50
RandomAngle = Rnd * 360
Random = Rnd * 5
Call CreateShootStar(i, _
.X + 24 * Cos(AngleFromTwoPoints(.X, .Y, Map.Trap(j).X, Map.Trap(j).Y)), _
.Y + 24 * Sin(AngleFromTwoPoints(.X, .Y, Map.Trap(j).X, Map.Trap(j).Y)), _
 
9 +
Random) * Cos(RandomAngle * Pi / 180), _
 
5 +
Random) * Sin(RandomAngle * Pi / 180))
';/
Next 'stars
End If
End If 'distance
Next 'END TRAP CHECK
If .X < 10 + 22
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FX)
Call CreateFallingText("-" &
CLng(Abs(.FX)), i, .X, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.X = 10 + 22
.FX = Abs(.FX) * 0.6 + 1
.FY = .FY * µ
'0.85
For j = 1
To Abs(.FX) * 4
RandomAngle = Rnd * 180 - 90
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X - 22, .Y, (Abs(.FX) +
Random) * Cos(RandomAngle * Pi / 180), Abs(.FX / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
End If
'BORDERS
If .X > Map.Width - 10 - 22
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X - 32, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FX)
Call CreateFallingText("-" &
CLng(Abs(.FX)), i, .X - 32, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.X = Map.Width - 10 - 22
.FX = -Abs(.FX) * 0.6 - 1
.FY = .FY * µ
'0.85
For j = 1
To Abs(.FX) * 4
RandomAngle = Rnd * 180 + 90
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X + 22, .Y, (Abs(.FX) +
Random) * Cos(RandomAngle * Pi / 180), (Abs(.FX) / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
End If
If .Y < 10 + 13
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, 0.5)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FY)
Call CreateFallingText("-" &
CLng(Abs(.FY)), i, .X, .Y, 0, 0.5)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.Y = 10 + 13
.FY = Abs(.FY) * 0.6 + 1
.FX = .FX * µ
'0.85
For j = 1
To Abs(.FY) * 4
RandomAngle = Rnd * 180
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X, .Y - 13, (Abs(.FY) +
Random) * Cos(RandomAngle * Pi / 180), (Abs(.FY) / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
End If
If .Y > Map.Height - 10 - 15
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FY)
Call CreateFallingText("-" &
CLng(Abs(.FY)), i, .X, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.Y = Map.Height - 10 - 15
.FY = -Abs(.FY) * 0.6 - 1
.FX = .FX * µ
'0.85
For j = 1
To Abs(.FY) * 4
RandomAngle = Rnd * 180 + 180
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X, .Y + 15, (Abs(.FY) +
Random) * Cos(RandomAngle * Pi / 180), (Abs(.FY) / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
End If
End If
'============ *** ÒÓÒ ÏÐÎÂÅÐßÅÌ ÑÒÎËÊÍÎÂÅÍÈÅ Ñ ÎÁÚÅÊÒÀÌÈ *** ============
For j = 1
To Map.WallsCount
If .X > Map.Walls(j).X
And .X < Map.Walls(j).X + Map.Walls(j).Width
Then
If .Y + 15 > Map.Walls(j).Y
And .Y <= Map.Walls(j).Y + Map.Walls(j).Height / 2
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FY)
Call CreateFallingText("-" &
CLng(Abs(.FY)), i, .X, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.Y = Map.Walls(j).Y - 15
.FY = -Abs(.FY) * 0.6 - 1
.FX = .FX * µ
'0.85
For t = 1
To Abs(.FY) * 4
RandomAngle = Rnd * 180 + 180
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X, .Y + 15, (Abs(.FY) +
Random) * Cos(RandomAngle * Pi / 180), (Abs(.FY) / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
ElseIf .Y - 15 < Map.Walls(j).Y + Map.Walls(j).Height
And .Y > Map.Walls(j).Y + Map.Walls(j).Height / 2
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FY)
Call CreateFallingText("-" &
CLng(Abs(.FY)), i, .X, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.Y = Map.Walls(j).Y + Map.Walls(j).Height + 15
.FY = Abs(.FY) * 0.6 + 1
.FX = .FX * µ
'0.85
For t = 1
To Abs(.FY) * 4
RandomAngle = Rnd * 180
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X, .Y - 15, (Abs(.FY) +
Random) * Cos(RandomAngle * Pi / 180), (Abs(.FY) / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
End If
ElseIf .Y > Map.Walls(j).Y
And .Y < Map.Walls(j).Y + Map.Walls(j).Height
Then
If .X + 22 > Map.Walls(j).X
And .X <= Map.Walls(j).X + Map.Walls(j).Width / 2
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FX)
Call CreateFallingText("-" &
CLng(Abs(.FX)), i, .X, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.X = Map.Walls(j).X - 22
.FX = -Abs(.FX) * 0.6 - 1
.FY = .FY * µ
'0.85
For t = 1
To Abs(.FX) * 4
RandomAngle = Rnd * 180 + 90
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X + 22, .Y, (Abs(.FX) +
Random) * Cos(RandomAngle * Pi / 180), (Abs(.FX) / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
ElseIf .X - 22 < Map.Walls(j).X + Map.Walls(j).Width
And .X > Map.Walls(j).X + Map.Walls(j).Width / 2
Then
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Abs(.FX)
Call CreateFallingText("-" &
CLng(Abs(.FX)), i, .X, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
.X = Map.Walls(j).X + Map.Walls(j).Width + 22
.FX = Abs(.FX) * 0.6 + 1
.FY = .FY * µ
'0.85
For t = 1
To Abs(.FX) * 4
RandomAngle = Rnd * 180 - 90
Random = Rnd * 4 + 2
Call CreateShootStar(i, .X - 22, .Y, (Abs(.FX) +
Random) * Cos(RandomAngle * Pi / 180), (Abs(.FX) / 2 +
Random) * Sin(RandomAngle * Pi / 180))
Next
Hitten =
True
End If
End If
'ÓÃËÛ ÎÁÚÅÊÒΠ—— ÎÁßÇÀÒÅËÜÍÎ ÏÐÎÂÅÐÈÒÜ
For u = 1
To 4
Select Case u
Case 1
X = Map.Walls(j).X
Y = Map.Walls(j).Y
Case 2
X = Map.Walls(j).X + Map.Walls(j).Width
Y = Map.Walls(j).Y
Case 3
X = Map.Walls(j).X
Y = Map.Walls(j).Y + Map.Walls(j).Height
Case 4
X = Map.Walls(j).X + Map.Walls(j).Width
Y = Map.Walls(j).Y + Map.Walls(j).Height
End Select
If Sqr((.X - X) ^ 2 + (.Y - Y) ^ 2) <= 20
Then
t = Rnd * 99 + 1
If t <= 5
Then
Call CreateFallingText("JUST", i, .X, .Y, 0, -1)
Call PlaySound(dsHit(5), DSBPLAY_DEFAULT)
Else
.HP = .HP - Sqr(.FX ^ 2 + .FY ^ 2) / 1.4
Call CreateFallingText("-" &
CLng(Sqr(.FX ^ 2 + .FY ^ 2) / 1.4), i, .X, .Y, 0, -1)
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
'Ñ÷àñ ìû êàê ÷òî-íèáóäü ðàññ÷èòàåì!
Px = .X - X
'îòíîñèòåëüíîå ðàññòîÿíèå ïî X
Py = .Y - Y
'îòíîñèòåëüíîå ðàññòîÿíèå ïî Y
d2 = Px * Px + Py * Py
'êâàäðàò ðàññòîÿíèÿ
VPx1 = (Px * .FX + Py * .FY) * Px / d2
'\_ïåðïåíäèêóëÿð i
VPy1 = (Px * .FX + Py * .FY) * Py / d2
'/
VNx1 = (Py * .FX - Px * .FY) * Py / d2
'\_íîðìàëü i
VNy1 = (Px * .FY - Py * .FX) * Px / d2
'/
VPx2 = -VPx1
VPy2 = -VPy1
VNx2 = -VNx1
VNy2 = -VNy1
If Px * (VPx2 - VPx1) + Py * (VPy2 - VPy1) > 0
Then '÷òîáû íå ñëèïàëèñü
.FX = ((24 ^ (1 / 3) - 1 ^ (1 / 3)) * .FX + 2 * 1 ^ (1 / 3) * (VPx2 + VNx1)) / (24 ^ (1 / 3) + 1 ^ (1 / 3))
.FY = ((24 ^ (1 / 3) - 1 ^ (1 / 3)) * .FY + 2 * 1 ^ (1 / 3) * (VPy2 + VNy1)) / (24 ^ (1 / 3) + 1 ^ (1 / 3))
.FX = .FX - 1.5 * Cos(AngleFromTwoPoints(.X, .Y, X, Y) * Pi / 180)
.FY = .FY - 1.5 * Sin(AngleFromTwoPoints(.X, .Y, X, Y) * Pi / 180)
.X = .X + .FX
.Y = .Y + .FY
End If
If (.PushedBy = 0
And .PushedBy <> i)
Then .PushedBy = i
.PushedByTime = PushedByTime
For t = 1
To Sqr(.FX ^ 2 + .FY ^ 2) * 1.4 + 10
RandomAngle = Rnd * 360
Random = Rnd * 5
Call CreateShootStar(i, _
.X + 24 * Cos(AngleFromTwoPoints(.X, .Y, X, Y)), _
.Y + 24 * Sin(AngleFromTwoPoints(.X, .Y, X, Y)), _
 
9 +
Random) * Cos(RandomAngle * Pi / 180), _
 
5 +
Random) * Sin(RandomAngle * Pi / 180))
';/
Next 'stars
Hitten =
True
End If 'distance
Next
Next
If .HP <= 0
Then
'If Hitten Then
Call CreateExplode(.X, .Y, 0, 0)
' .FX, .FY)
'Else
' Call CreateExplode(.X, .Y, .FX / 3, .FY / 3)
'End If
If (.PushedBy > 0
And .PushedBy <> i)
And Hitten
Then
Player(.PushedBy).Frags = Player(.PushedBy).Frags + 1
Call CreateFallingText("FRAG!", .PushedBy, Player(.PushedBy).X, Player(.PushedBy).Y, 0, 0)
Call CreateFallingText("FRAG!", .PushedBy, Player(.PushedBy).X, Player(.PushedBy).Y, 0, 0)
Call CreateFallingText("FRAG!", .PushedBy, Player(.PushedBy).X, Player(.PushedBy).Y, 0, 0)
ElseIf (.PushedBy = 0)
And Hitten
Then
.Frags = .Frags - 1
Call CreateFallingText("SUICIDER!", 5, .X, .Y, 0, 0)
ElseIf (.PushedBy = i)
And Hitten
Then
.Frags = .Frags - 1
Call CreateFallingText("SUICIDER!", 5, .X, .Y, 0, 0)
ElseIf (.PushedBy > 0)
And Not Hitten
Then
If (.PushedBy <> i)
Then
Player(.PushedBy).Frags = Player(.PushedBy).Frags + 1
Call CreateFallingText("FRAG!", .PushedBy, Player(.PushedBy).X, Player(.PushedBy).Y, 0, 0)
Call CreateFallingText("FRAG!", .PushedBy, Player(.PushedBy).X, Player(.PushedBy).Y, 0, 0)
Call CreateFallingText("FRAG!", .PushedBy, Player(.PushedBy).X, Player(.PushedBy).Y, 0, 0)
Else
.Frags = .Frags - 1
Call CreateFallingText("SUICIDER!", 5, Player(.PushedBy).X, Player(.PushedBy).Y, 0, 0)
End If
End If
.FramesToRespawn = 75 * 5
End If
Else
.FramesToRespawn = .FramesToRespawn - 1
If .FramesToRespawn = 0
Then
.X = .SpawnX
.Y = .SpawnY
.FX = 0
.FY = 0
.PushedBy = 0
.PushedByTime = 0
.HP = .MaxHP
End If
End If
End With
Next
For i = 1
To MaxPlayers - 1
For j = i
To MaxPlayers
If i <> j
Then
If Player(i).FramesToRespawn = 0
And Player(i).Exist
And Player(j).Exist
And Player(j).FramesToRespawn = 0
And Player(j).Exist
And Player(i).Exist
Then
Px = Player(i).X - Player(j).X
'îòíîñèòåëüíîå ðàññòîÿíèå ïî X
Py = Player(i).Y - Player(j).Y
'îòíîñèòåëüíîå ðàññòîÿíèå ïî Y
d2 = Px * Px + Py * Py
'êâàäðàò ðàññòîÿíèÿ
If (d2 <= (24 + 24) ^ 2)
And (d2 > 1)
Then
VPx1 = (Px * Player(i).FX + Py * Player(i).FY) * Px / d2
'\_ïåðïåíäèêóëÿð i
VPy1 = (Px * Player(i).FX + Py * Player(i).FY) * Py / d2
'/
VNx1 = (Py * Player(i).FX - Px * Player(i).FY) * Py / d2
'\_íîðìàëü i
VNy1 = (Px * Player(i).FY - Py * Player(i).FX) * Px / d2
'/
VPx2 = (Px * Player(j).FX + Py * Player(j).FY) * Px / d2
'\_ïåðïåíäèêóëÿð j
VPy2 = (Px * Player(j).FX + Py * Player(j).FY) * Py / d2
'/
VNx2 = (Py * Player(j).FX - Px * Player(j).FY) * Py / d2
'\_íîðìàëü j
VNy2 = (Px * Player(j).FY - Py * Player(j).FX) * Px / d2
'/
If Px * (VPx2 - VPx1) + Py * (VPy2 - VPy1) > 0
Then '÷òîáû íå ñëèïàëèñü
Player(i).FX = ((24 ^ (1 / 3) - 24 ^ (1 / 3)) * Player(i).FX + 2 * 24 ^ (1 / 3) * (VPx2 + VNx1)) / (24 ^ (1 / 3) + 24 ^ (1 / 3))
Player(i).FY = ((24 ^ (1 / 3) - 24 ^ (1 / 3)) * Player(i).FY + 2 * 24 ^ (1 / 3) * (VPy2 + VNy1)) / (24 ^ (1 / 3) + 24 ^ (1 / 3))
Player(j).FX = ((24 ^ (1 / 3) - 24 ^ (1 / 3)) * Player(j).FX + 2 * 24 ^ (1 / 3) * (VPx1 + VNx2)) / (24 ^ (1 / 3) + 24 ^ (1 / 3))
Player(j).FY = ((24 ^ (1 / 3) - 24 ^ (1 / 3)) * Player(j).FY + 2 * 24 ^ (1 / 3) * (VPy1 + VNy2)) / (24 ^ (1 / 3) + 24 ^ (1 / 3))
'Ïîñëå ñòîëêíîâåíèÿ êîðàáèêè âñå æå ðàçëåòàþòñÿ
Player(i).FX = Player(i).FX - 2 * Cos(AngleFromTwoPoints(Player(i).X, Player(i).Y, Player(j).X, Player(j).Y) * Pi / 180)
Player(i).FY = Player(i).FY - 2 * Sin(AngleFromTwoPoints(Player(i).X, Player(i).Y, Player(j).X, Player(j).Y) * Pi / 180)
Player(j).FX = Player(j).FX - 2 * Cos(AngleFromTwoPoints(Player(j).X, Player(j).Y, Player(i).X, Player(i).Y) * Pi / 180)
Player(j).FY = Player(j).FY - 2 * Sin(AngleFromTwoPoints(Player(j).X, Player(j).Y, Player(i).X, Player(i).Y) * Pi / 180)
End If
Player(i).PushedBy = j
Player(i).PushedByTime = PushedByTime
Player(j).PushedBy = i
Player(j).PushedByTime = PushedByTime
For t = 1
To 20
RandomAngle = Rnd * 360
Call CreateShootStar(i -
CBool(Rnd <= 0.5) * (j - i), _
Player(i).X + 24 * Cos(AngleFromTwoPoints(Player(i).X, Player(i).Y, Player(j).X, Player(j).Y)), _
Player(i).Y + 24 * Sin(AngleFromTwoPoints(Player(i).X, Player(i).Y, Player(j).X, Player(j).Y)), _
 
7 + Rnd * 5) * Cos(RandomAngle * Pi / 180), _
 
7 + Rnd * 5) * Sin(RandomAngle * Pi / 180))
';/
Next
Call PlaySound(dsHit(1), DSBPLAY_DEFAULT)
End If
End If
End If
Next
Next
End Sub