`type question

Blitz3D Forums/Blitz3D Beginners Area/`type question

Santiworld(Posted 2009) [#1]
hi, i want to know if can i have problems if i use for a racecar game a type for each car, with more than 100 variables for car..

now i using car_speed(i), posx(i)

i wan't to know if i can use types with too many variables for car..
is faster?


Wayne(Posted 2009) [#2]
Myself I'd go with types because it looks cleaner, and wouldn't expect much performance impact between indexes and types.

Type car
Field IP$
Field Name$
Field r,g,b
Field NextWaypoint
Field x,y,z
..


Santiworld(Posted 2009) [#3]
thanks wayne..

if i use types...

you use,

for car.car = each car
moveentity car\entity,x,y,z
next

but how you pointentity the camera to x car? the player car for example, or other car you want, how you make that?

for car.car = each car
if car\id = X then pointentity camera,car\entity ???
next

so, each time i want choose a specific car for something, i nned mame that loop?

(soory my english)


Mortiis(Posted 2009) [#4]
Create different instances of the same type like;

car1.tCar = new tCar
car2.tCar = new tCar

then just

pointentity camera, car1\entity


Stevie G(Posted 2009) [#5]
As well as the ID per car, you could also create an array of types ...

Type CarT
  field Entity
  field Blah
End type

dim CAR.CarT( 99 )

for l = 0 to 99
  CAR(l) = new CartT
  CAR(l)\Entity = Copyentity( CAR_MESH )
  CAR(l)\Blah = ???
next


Then to point to car 4 do this:

pointentity CAMERA, CAR(4)\Entity



Ross C(Posted 2009) [#6]
I've still not gotten round to using an array of types, but the potential of them looks pretty sweet.


Santiworld(Posted 2009) [#7]
is that an excelent example !..

i go to try now that... :)