Arrays, types, confusion...
Blitz3D Forums/Blitz3D Beginners Area/Arrays, types, confusion...
| ||
Hi I am trying to write something with blocks sliding. I have a grid full of cubes created with an array; example: for x = 1 to 10 for y = 1 to 10 array(x,y) = createcube position, set colour, set alpha, scale etc. next next However, I am not entirely sure what the array actually contains... for instance, if I click on a cube, how do I get that cube's properties? For instance, colour, and column or row information? Is this something I should be using types for? Sorry about the vague and confusing post, I am newish to Blitz3D and am very confused with types and arrays. Thanks! |
| ||
the array contains nothing. A function that returns something must have () or it will not return anything. And properties of entities are retrieved through the entity commands. |
| ||
You can't retreive the color of the entity or it's alpha ( you can get the scale using tform ) so you need to store this yourself. You could use and array of types and some custom functions to set and store the entity properties .. Type CubeT field entity field r, g, b field alpha# field sx#, sy#, sz# end type dim Cubes.CubeT( 9 , 9 ) for y = 0 to 9 for x = 0 to 9 c.CubeT = new CubeT c\Entity = createcube() CUBEcolor( c , 255,128,64 ) CUBEalpha( c , .75 ) CUBEscale( c, 1, 2, 3 ) positionentity c\Entity , x * 5 , y* 5, 0 Cubes( x, y ) = c next next ;===================================== ;===================================== ;===================================== function CUBEcolor( c.cubeT, r, g, b ) entitycolor c\Entity, r, g, b c\r = r c\g = g c\b = b end function ;===================================== ;===================================== ;===================================== function CUBEalpha( c.cubeT , alpha# ) entityalpha c\Entity, alpha c\Alpha = Alpha end function ;===================================== ;===================================== ;===================================== function CUBEscale( c.cubeT , Sx#, Sy#, Sz# ) scaleentity c\Entity, Sx, Sy , Sz c\Sx = Sx c\Sy = Sy c\Sz = Sz end function ;===================================== ;===================================== ;===================================== |
| ||
Brilliant, thanks, I'll play around with this and see if I can get to grips with it. Thanks! |
| ||
how can i do this? type car field entity field wheels(4) end type dim wheels(4)? how can i put arrays into a type? |
| ||
You can if you user BlitzArrays .. field Wheels[4] |
| ||
thank! |