Best way to "move my character"

Blitz3D Forums/Blitz3D Beginners Area/Best way to "move my character"

Type variable
Parameters
variable = any legal variable name

Description
If you know C prgramming, a TYPE is basically a STRUCT in Blitz Basic
.
.
.

See also: Field, End Type, New, Before, After, First, Last, Each, Insert, Delete.

Example code usage:
; Define a crafts Type 

Type crafts 
Field x 
Field y 
Field dead 
Field graphic 
End Type 

; Create 100 crafts, with the unique name of alien 
For t = 1 To 100 
alien.crafts = New crafts 
alien\x = Rnd(0,640) 
alien\y = Rnd(0,480) 
alien\dead = 0 
alien\graphic = 1 
Next 

; Move to the first object 
alien.crafts = First crafts 

Print alien\x 
Print alien\y 
Print alien\dead 
Print alien\graphic 

; move to the next alien object 
alien = After alien 

Print alien\x 
Print alien\y 
Print alien\dead 
Print alien\graphic 

; move to the last alien object 
alien.crafts = Last crafts 

Print alien\x 
Print alien\y 
Print alien\dead 
Print alien\graphic 

; move to the second to the last alien object 
alien = Before alien 

Print alien\x 
Print alien\y 
Print alien\dead 
Print alien\graphic  


So, in your case:
Graphics3D 800, 600

Type Node
	Field entity
	Field x#, y#, z#
End Type

For iter = 1 To 10
	thisNode.Node = New Node
	thisNode\entity = CreateCube() ;CreatePivot() ;normally just an invisible pivot
	thisNode\x# = Rnd(-100, 100)
	thisNode\y# = 0
	thisNode\z# = Rnd(-100, 100)
	PositionEntity thisNode\entity, thisNode\x#, thisNode\y#, thisNode\z#
	EntityColor thisNode\entity, iter * 20, 150, 150 ;note:  can't be used with pivots
Next

myGuy = CreateCamera()

grid_tex=CreateTexture( 32,32,8 )
ScaleTexture grid_tex,10,10
SetBuffer TextureBuffer( grid_tex )
Color 0,0,64:Rect 0,0,32,32
Color 0,0,255:Rect 0,0,32,32,False
SetBuffer BackBuffer()
grid_plane=CreatePlane()
EntityTexture grid_plane,grid_tex
MoveEntity grid_plane, 0, -1, 0

thisNode = First Node

While Not KeyHit(1)
	If EntityDistance(myGuy, thisNode\entity) < 10
		turnrate = 5
	Else
		turnrate = 20
	EndIf
	TurnEntity myGuy, 0, DeltaYaw(myGuy, thisNode\entity)/turnrate, 0
	MoveEntity myGuy, 0, 0, .5
	
	If EntityDistance(myGuy, thisNode\entity) < 2
		If thisNode = Last Node Then thisNode = First Node
		thisNode = After thisNode
	EndIf
	
	RenderWorld()
	Flip
Wend

End