types ???

Blitz3D Forums/Blitz3D Programming/types ???

Hi again...

Im making a dynamic system, 3D project. where i need to use a lot of vectors and boids. i made my program run quite nice and even made a little screensaver out of,,,, my first app… I’ll post it later on in this thread…

My problems is to understand types… I thought I figured them out but now when printing variables to the screen I see that my temp type is way bigger and for each iteration it magically grow. ?????..

I found something quite disturbing with this little example I made…

Type m
	Field x#, y#, z#
End Type

For i = 1 To 100
	v.m = New m
Next

ma.m = New m

Temp = 0
temp2 = 0
Repeat 
	temp = 0	
	temp2 = 0
	
	For v.m = Each m
		temp = temp + 1
	Next
	For v.m = Each m
		;Delete v
	Next
	
	For ma.m = Each m
		temp2 = temp2  + 1
	Next
	
	
	Text 10, 10, "1: " + temp
	Text 10,20, "2: " + temp2
Until KeyHit(1)
End


1. look at the two different variables temp and temp2, they are both 101 in my case, where temp2 should ONLY be 1 since my MA.vector only consist of one type..?

it seem like when you create a new instance of the vector you don’t create a totally new one

2. when I delete all in my V.type holder I delete them all, included the one from MA.m

this is rather irritating problem since im not only deleting my temp vectors that I need to calculate on but also all the vectors that I need inside other types for positing my entity’s….


HELP.. how do I create a new copy of my vector type (here it is M).. and how do I make sure it a totally independent copy. So something like this will work properly…?

Type vector
	Field x#
	Field y#
	Field z#
End Type

Type objData
	Field obj
	Field SpaceObj
	Field id
	
	Field velocity.vector            ; = New vector
	Field pos.vector                 ; = New vector
	Field oldpos.vector				 ; = New Vector
	
	Field seekVar#
	Field fleeVar#
	Field speed#
	Field max_speed#
	Field min_speed#
	Field personalSpace#
End Type