follow path

BlitzMax Forums/BlitzMax Beginners Area/follow path

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.

Here is a small sample using scotts spritebeviors.

Strict

Import sas.spritebehaviors

Graphics 800,600



Parameters.SeparationWeight= 8
Parameters.AlignmentWeight= 4
Parameters.CohesionWeight= 10
Parameters.ObstacleAvoidanceWeight=10
Parameters.WallAvoidanceWeight= 99
Parameters.WanderWeight = 50
Parameters.SeekWeight=5
Parameters.FleeWeight=1
Parameters.ArriveWeight=1
Parameters.PursuitWeight=1
Parameters.OffsetPursuitWeight=1
Parameters.InterposeWeight=1
Parameters.HideWeight=1
Parameters.EvadeWeight= 0.01
Parameters.FollowPathWeight=0.05
Parameters.ViewDistance = 25

Global colrad:Double = 32

Global world:GameWorld = GameWorld.Create(GraphicsWidth(),GraphicsHeight())
Delta.Start()

Local Leader:Sprite = Sprite.CreateForSteering(Null, world, CreateVector(MouseX(),MouseY()), Rand(0,359), CreateVector(0,0), 1, 4, 4, 180, .5)
		Leader.SetCollisionRadius(colrad)
		Leader.GetSteering().ObstacleAvoidanceOn() ' Turn on the flocking behaviors 
		Leader.SetWorldWrap(True)			' allow the prites to wrap from on side to the other of the screen
		world.AddVehicle(Leader)





Local ld = 40
Local ax, ay

ax = MouseX()- ld
ay = MouseY()- ld

While Not KeyDown(KEY_ESCAPE)
	
		Cls
		SetColor 255,255,255
		Leader.SetPosition(MouseX(),MouseY())
				
		If MouseDown(1) Then
			Local s1:sprite = Sprite.CreateForSteering(Null, world, CreateVector(ax,ay), Rand(0,359), CreateVector(0,0), 1, 4, 4, 180, .5)
			s1.SetCollisionRadius(colrad)
			s1.GetSteering().ObstacleAvoidanceOn() ' Turn on the flocking behaviors 
			s1.GetSteering().FlockingOn() ' Turn on the flocking behaviors  
			s1.GetSteering().SeekOn(Leader)
			s1.SetWorldWrap(True)			' allow the prites to wrap from on side to the other of the screen
			world.AddVehicle(s1)
	
			ax = MouseX()- ld
			ay = MouseY()- ld
			ld = ld + 20
			FlushMouse()
		End If
		
		world.Update(Delta.Time())	' update the agents
		world.Render()				' render the world
		Flip
		Delta.update()

Wend


You need to have the sas.spritebehaviors module installed from his side and build it.