C# Arrays - Using them to store game level -
i'm making 2d tile based game. use 2d jagged array store integer, , renderer draws image depending on integer is. have part of code working, i've come point i'm not sure how proceed next.
as player goes on through game, need able store information every cell in 2d array, such light level, or number of times user has clicked cell, or rotation value of image in cell, or alpha level image, etc etc.
the way can think of doing create 2d array have done previously, each piece of information i'm using. example:
alphalevel[][] numberoftimesclicked[][]
and if needed (for example) check number of times user has clicked cell 5,5 can numberoftimesclicked[5][5] or if needed set rotation setrotation[5][5] = 90.
the thing i'm not sure how efficient is, having array each piece of information doesn't seem memory efficient.
is idea have solution, or there better way haven't thought about?
any advice great! thanks
make tile
object has information, alphalevel
, numberoftimesclicked
, , make jagged array of those. then, need 1 jagged array hold of information, , it's organized more nicely, since can find properties tile
has.
if you're interested in memory optimization, npsf3000 correct in saying structs marginally better. make sure you're familiar how value , reference types differ before using them.
storing data in smaller format going bigger not storing data @ all. in addition working compress current data as possible, @ ways of storing old data won't need disk, or discarding data can generate procedurally later.
one last note: sure need compress it? when worked on 2d tile systems in past, found storing data improve speed, because wasn't using memory. run numbers make sure you're using enough memory optimizations worth it.
Comments
Post a Comment