Test my laser cannon please

Blitz3D Forums/Blitz3D Programming/Test my laser cannon please

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This quick bit of code should get you a boat moving around.


Global boat_nextpoint = 1

Type boatwaypoint
	Field entity
	Field number
End Type

Function MoveBoat()

For this.boatwaypoint = Each boatwaypoint
	If this\number = boat_nextpoint Then
		xvector# = EntityX(this\entity) - EntityX(boatmesh)
		zvector# = EntityZ(this\entity) - EntityZ(boatmesh)
		AlignToVector boatmesh, xvector, 0, zvector, 3, 0.01
		MoveEntity boatmesh,0,0,2
			If EntityDistance(boatmesh,this\entity)<300 Then
			    ; this determines how close we let the boat get to the waypoint
			    ; time for the next waypoint
			    boat_nextpoint = boat_nextpoint+1
			    ; back to the first waypoint
			    If boat_nextpoint = 7 then  boat_nextpoint = 1
		        End If
	EndIf
Next

End Function

Function CreateBoatWaypoints()

	this.boatwaypoint = New boatwaypoint
	this\entity = CreateCube()
	this\number = 1
	PositionEntity this\entity,-6237,500,246
	
	this.boatwaypoint = New boatwaypoint
	this\entity = CreateCube()
	this\number = 2
	PositionEntity this\entity,-2048,500,5319
	
	this.boatwaypoint = New boatwaypoint
	this\entity = CreateCube()
	this\number = 3
	PositionEntity this\entity,7500,500,5000
	
	this.boatwaypoint = New boatwaypoint
	this\entity = CreateCube()
	this\number = 4
	PositionEntity this\entity,9024,500,-6659
	
	this.boatwaypoint = New boatwaypoint
	this\entity = CreateCube()
	this\number = 5
	PositionEntity this\entity,-1100,500,-12500
	
	this.boatwaypoint = New boatwaypoint
	this\entity = CreateCube()
	this\number = 6
	PositionEntity this\entity,-3300,500,-10500
	
End Function