2d array as a type object
BlitzMax Forums/BlitzMax Beginners Area/2d array as a type object
| ||
does this make sense to have a type, with a 2d array for say level map data, or is this going about it the wrong way programmatically. basically i have a number a levels for a game, all different sizes, thats easy, so i was wanting to make an object that has an array as it main focus, with methods that can be used on it to erase, randomise, draw line, squares , spray brushes with different tiles. does that seem the way to do it or should i have a global array and have a type with funtions in it to effect that array... still trying to get my head around how far to go with the oob concept... cheers |
| ||
It depends on your favorite coding style, but a TMap sounds like a good idea. I would it do the same way. |
| ||
DREAM, yeah thats a pretty good way to handle tilemaps/level data ect. Jake, TMap sounds like a good idea for what? |
| ||
what am i doing wrong here now???Graphics 1024,768,0,75',32 Type Tmap Local levelmap:Int [][] levelmap=levelmap[100] For i=0 To 100 levelmap=levelmap[i][100] Next Method init() For x=0 To 100 For y=0 To 100 levelmap [x][y]=Rand(0,1) Next Next End Method Method drawmap() For x=0 To 100 For y=0 To 100 If levelmap [x][y]=1 SetColor 255,0,0 Else SetColor 0,255,0 EndIf DrawRect x*16,y*16,16,16,1 Next Next End Method End Type tmap.init() Repeat Cls tmap.drawmap() Flip Until Keydown(key_escape) |
| ||
Sorry, dont have time to explain the changes right now, but it'll give you something to study. (maybe somebody else can give you some pointers on what you did wrong in your original code) |
| ||
TMap sounds like a good idea A TMap is a hash table-like data structure and has nothing inherently to do with tilemaps (which is crushing news, I know, but it turns out that TMaps are cool in their own way). Personally I wouldn't use 'TMap' as the name of a custom type, if only to spare those who who follow in search of information on actual TMaps (hi!). They're cursing you right now. |
| ||
tmap is no hash table like data structure. its a balanced binary tree based dictionary data structure |
| ||
Well it associates a key with an entry, like a hash table does (apparently). You can go ahead and educate me on the finer details, though, because it was a new data structure on me with Max and I find it quite quirky (in a good way). EDIT: For clarity. And to add: DREAM! Wasn't it you guys who gave away some old pixel gfx back in the BlitzCoder days? Really enjoyed playing around with it if it was, so cheers! |
| ||
Sorry for confusing everyone, with TMap I did not refer to BRL.TMap but to a TTypeThatHandlesMyMapNeeds type. |
| ||
yeah sledge that would be us......inventivedreams......it would of been my brothers artwork, he does the art i do the code......we still work together... just both now have full time jobs.....and that takes most of our game making away but we are still making stuff, we are trying to future proof what we do now so we can do a mass release, well by mass 4-6 games at once hopefully all with editors, two with addon capabilities and a few special editions.......anyway gotta get my head into this oob idea i get it its just changing from Blitz3d syntax to max.......feels like its twisting my head...lol with The Tmap maybe i should of used Tlevmap or something sorry about that....anyway thanks for the advice much appreciated... |