Game Development Reference
In-Depth Information
& BlindSpot.ID & " in lane " & somelane.ToString & ".")
End If
End If
End If
'Is there anyone in front to worry about?
Dim OtherGuy As Vehicle = CarAhead(somelane, myIndex, theRoad)
If OtherGuy Is Nothing Then
'Debug.WriteLine(Me.ID & " finds lane " & somelane.ToString & _
'" is open for an available speed of " & BestNextSpeed().ToString)
Return BestNextSpeed()
'Will we hit his tail end? (Should never happen in our own lane.)
If myLane <> OtherGuy.Lane Then
Dim tail As Integer = OtherGuy.X - OtherGuy.Length - _
If tail < Me.X Then
'Debug.WriteLine(Me.ID & " sees that lane " & _
' somelane.ToString & " is blocked by " & OtherGuy.ID)
Return -1
End If
End If
End If
'The lane is usable. How fast is it?
'We like a distance that is numerically equal to twice our speed.
Dim deltaX As Integer = OtherGuy.X - Me.X - OtherGuy.Length
Dim matchSpeed As Integer = deltaX \ 2
'Is the other guy faster than we are?
'This is not worth changing lanes over - only applies in our
'lane. Not checking this in other lane dampens maniacal lane
'switching so we only switch into a lane with non-compromised
'clear distance ahead. In our lane, we'll take a compromise if
'it is safe.
If OtherGuy.Lane = Me.Lane Then
'If he's pulling away we don't slow down
If OtherGuy.Speed > Me.Speed Then
If Me.Speed > matchSpeed Then
Search Nedrilad ::

Custom Search