axes
BlitzMax Forums/BlitzMax Beginners Area/axes
| ||
how can i make an x and y axes with more then one variable and strings on one position? thank you! |
| ||
what ?????? you need to be more specific. |
| ||
Local x:Int, y:Int Local position:String :D Last edited 2011 |
| ||
Something to do with graphs maybe? |
| ||
for explane: on point 5,6 (x,y) is number = 4 cat = 30 scalex = 32 scaley = 32... on point 0,3 (x,y) is number = 2 cat = 78 scalex = 64 scaley = 64... there is more variable in a x and y axes. I want to make a level editor, I will use this. |
| ||
You can use Types or multidimensional Arrays to store this kind of complex value. They are documented at this location in your BMax IDE: Home -> Language Reference -> Arrays (but you can also find documentation online like in here or searching the forums). In a situation like this (say he has to store different values for each pixel in the screen like 'cat'egory, scaleX, scaleY etc.), is an Array more memory-friendly than a collection of Type objects? |
| ||
If you want random access, then an array is a must. |
| ||
that is it, I use the arrays. thank you all! |
| ||
type TPoint field x:int field y:int field num:int field cat:int field scalex:int field scaley:int endtype local mypoints:TPoint[] = New TPoint[50] mypoint[0].x = 5 mypoint[0].y = 6 ..etc... Arrays would be faster and less memory intensive, but depends how many points we're talking. Over 10,000 then use arrays. I think types have a small amount of padding, not terrible, but enough...... actually how does BMax define arrays? Are they just types? |
| ||
Arrays are objects with some meta information such as their length, but the meat of the data is a contigious sequence in memory. Types will have any padding no matter how you store them, so I wouldn't worry about that. It's a few bytes per type. Edit: To be more precise, a type could include padding but not necessarily. A type which consists of purely ints and references to other types shouldn't contain any padding. Alls types may contain metadata of a few bytes, but I'm not sure: http://blitzbasic.com/Community/posts.php?topic=94575 Last edited 2011 |
| ||
Thanks for the clarification. |
| ||
thanks you all! I can continue now with my program! |