axes

BlitzMax Forums/BlitzMax Beginners Area/axes

ssdw(Posted 2011) [#1]
how can i make an x and y axes with more then one variable and strings on one position?

thank you!


Jesse(Posted 2011) [#2]
what ??????
you need to be more specific.


Czar Flavius(Posted 2011) [#3]
Local x:Int, y:Int
Local position:String

:D

Last edited 2011


Who was John Galt?(Posted 2011) [#4]
Something to do with graphs maybe?


ssdw(Posted 2011) [#5]
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.


Kryzon(Posted 2011) [#6]
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?


Czar Flavius(Posted 2011) [#7]
If you want random access, then an array is a must.


ssdw(Posted 2011) [#8]
that is it, I use the arrays.

thank you all!


AdamRedwoods(Posted 2011) [#9]
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?


Czar Flavius(Posted 2011) [#10]
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


Kryzon(Posted 2011) [#11]
Thanks for the clarification.


ssdw(Posted 2011) [#12]
thanks you all!
I can continue now with my program!