Creating Typs that have local arrays

BlitzMax Forums/BlitzMax Beginners Area/Creating Typs that have local arrays

Ryan Burnside(Posted 2006) [#1]
Ok I'm making a new type and each instance of that type needs to have it's own array. I ttried using field while declaring the array but it appears to be messing soething up. How do I declare an array in my create event for each object?

Type cube
Global cube_list:TList=New TList
Field x#,y#,z#,width#,length#,elevation#,x_rot#,y_rot#,z_rot#
Field xpoints:Float[8],ypoints:Float[8],zpoints:Float[8]

	Function Create(x#,y#,z#,width#,length#,elevation#)
		Local temp:cube=New cube
		temp.x=x
		temp.y=y
		temp.z=z
		temp.elevation=elevation
		temp.width=width
		temp.length=length
		' make the value holders
		temp.xpoints= New Float[..
		x-width/2, ..
		x+width/2, ..
		x+width/2, ..
		x-width/2, ..
		x-width/2, ..
		x+width/2, ..
		x+width/2, ..
		x-width/2 ..
		]
		
		temp.ypoints=New Float[..
		y-length/2, ..
		y-length/2, ..
		y+length/2, ..
		y+length/2, ..
		y-length/2, ..
		y-length/2, ..
		y+length/2, ..
		y+length/2 ..
		]		
	End Function 
	Method Draw()
	SetColor 255,255,255
		For Local i=0 To 7
			Plot xpoints[i],ypoints[i]
			DrawText xpoints[i],x,y*12 
		Next
		
	End Method
	
End Type



FlameDuck(Posted 2006) [#2]
You are inadvertently creating 8 dimensional arrays.

Try
	temp.xpoints=[..
		y-length/2, ..
		y-length/2, ..
		y+length/2, ..
		y+length/2, ..
		y-length/2, ..
		y-length/2, ..
		y+length/2, ..
		y+length/2 ..
		]
etc...


Ryan Burnside(Posted 2006) [#3]
Thank you so much!