Type Question
Blitz3D Forums/Blitz3D Beginners Area/Type Question
| ||
hi, i was reading the forums and came accross someone who said the easiest way to think of types is like a database of items with fields etc. This got me thinking. If i wanted to create a tiling grid and i create the following type to hold the tile details: type gridpoint field Xloc field Yloc field Tiletype end type then populate it like so: .restore Levelmap1 for x = 0 to 15 for y = 0 to 11 grid1.gridpoint = new gridpoint grid1\xloc = x * 50 grid1\yloc = y * 50 read grid1/tiletype next next this should create a, 800 x 600 grid split into 50 X 50 tiles and stores the tile types from an imaginary data set :levelmap1. And all the data should, essentially, be stored in big 3d array somewhere in the comps memory (ie: gridpoint(xloc,yloc,tiletype) Now, i was wondering if it is possible to create seperate record sets from gridpoint using something along the lines of and SQL style 'select' statement. for example: select * from [gridpoint] where x= 400 and y = 300 then you could use and 'each type' loop to run through a specific selection of the gridpoint list? I'm not sure if i have explained this very well, but if anyone need clarification, i'll try again :D thanks ~V~ |
| ||
Sorry, but I'm not familiar with SQL. Try rephrasing your question while sticking to Blitz. What is it that you are trying to accomplish? Do you want to 'select' a specific item from the typelist? FOR EACH can do this by itself. |
| ||
ah, actually.... essentially, i was wanting to perform a function on a type list, but i wanted to see if i could reduce the list size before the function so i could speed up the framerate. But as i was typing this reply, i just thought, running a function on the whole list to reduce its size then run a function on the reduced list would probally take longer than just using 'For Each'on the full list. Ah well, nm. thanks neway wolron ~V~ |
| ||
Doesn't work that way. You can loop through the type and find each record where x = 400 and y = 300 though. (syntax probably wrong below) for t.gridpoint = each.gridpoint if t\x = 400 and t\y = 300 then Do something here. end if next |
| ||
For what you are trying to do I would use an arraydim tiles(15,15) for x=0 to 15 for y=0 to 15 read tiles(x,y) next next Although if you want to store more than one piece of data you could use an array of types type gridpoint field tiletype filed colour end type dim tiles.gridpoint(15,15) for x=0 to 15 for y=0 to 15 read tiles(x,y)\tiletype read tiles(x,y)\colour next next To get at a piece of data yopu can use something like this tilesize=50 x=400 : y=300 tiletype=tiles(x/tilesize,y/tilesize)\tiletype |
| ||
ah thanks,b-Moon. i had kind of worked around it by just creating a select statement nested in an if statement to perform what dynaman suggested, but i didn't know that you could combine arrays and types. I think if u use them i could clean up my code quite a bit. I'll have a play with them when i get in from work tonight :D thanks for all the help folks ~V~ |