I’m building a javascript - html5 canvas side-scroller game. The terrain consists basically on a double-entry table like this one:
-1 2 10
-----------------
0 b a c
-----------------
2 a b a
-----------------
5 a a b
-----------------
(the columns and rows represent the position on the map and a, b and c would state what’s on that space).
I don’t know how to save this table so I can retrieve any range of it quickly later on. I can’t think of any terminology that helps me search for the solution either, so any info and help tagging the question will be of help.
Use JSON for saving such data:
And retrieve your data like that:
map['2']['-1'].You can also change it like that also
map['2']['-1'] = 'c'.Some function for easier manipulation of this object could be written by you if you like.