Ship going through dock

Blitz3D Forums/Blitz3D Programming/Ship going through dock

The ship goes throught the dock. What is wrong?
AppTitle "Great Lakes Shipping"

SetBuffer BackBuffer()

Graphics3D 1280,1024,32,0

light = CreateLight()

Dim Cam(5)

Cam(0) = 0.0
Cam(1) = 30.0
Cam(2) = -50.0
Cam(3) = 1
Cam(5) = CreatePivot()

PositionEntity Cam(5),Cam(0),Cam(1),Cam(2)

Global BoatX = 0
Global BoatY = 10
Global BoatZ = 0
Global BoatYaw = 180

Global Water = CreatePlane()

EntityType Water,1

EntityColor Water,0,0,255

Global Oreboat = LoadMesh("Data\Boats\Ore Carrier\Oreboat.3ds")

;Collisions
;1 = Water
;2 = Oreboat
;3 = Oredock

Collisions 2,1,3,3

EntityType Oreboat,2

Global camera = CreateCamera(Cam(5))

PositionEntity Camera,Cam(0),Cam(1),Cam(2)

RotateEntity Oreboat,270,180,90

Oredock = LoadMesh("Data\Graphics\Oredock.3ds")

EntityType Oredock,3

RotateEntity Oredock,270,90,0

PositionEntity Oredock,0,40,100

Collisions 2,3,1,1

While Not KeyHit(1)

TestKeys()

RenderWorld
UpdateWorld
Flip
Wend

FreeEntity Oredock
ClearMem()

Function ClearMem()

FreeEntity Oreboat
FreeEntity Water
FreeEntity Camera
FreeEntity Light

End

End Function

Function TestKeys()

If KeyHit(2) Then
	Cam(3) = 1
ElseIf KeyHit(3) Then
	Cam(3) = 2
EndIf

If KeyDown( 203 ) And Cam(4) = 2 Then
	RotateEntity Cam(5),0,0.1,0
EndIf

If KeyDown( 203 ) And Cam(3) = 1
	BoatX = BoatX + -1.0
	Cam(0) = Cam(0) + -1.0
	Update = True
EndIf

If KeyDown( 205 ) And Cam(3) = 1
	BoatX = BoatX + 1.0
	Cam(0) = Cam(0) + 1.0
	Update = True
EndIf

If KeyDown( 208 ) And Cam(3) = 1
	BoatZ = BoatZ + -1.0
	Cam(2) = Cam(2) + -1.0
	Update = True
EndIf

If KeyDown( 200 ) And Cam(3) = 1
	BoatZ = BoatZ + 1.0
	Cam(2) = Cam(2) + 1.0
	Update = True
EndIf

If KeyDown( 75 )
	BoatYaw = BoatYaw + 1.0
	Update = True
EndIf

If KeyDown( 77 )
	BoatYaw = BoatYaw + -1.0
	Update = True
EndIf

If Update = True Then
	PositionEntity Oreboat,BoatX,BoatY,BoatZ
	RotateEntity Oreboat,270,BoatYaw,90
	Update = False
	PositionEntity Cam(5),Cam(0),Cam(1),Cam(2)
EndIf

End Function