
-----------------------------------
yusong
Thu May 08, 2008 9:13 am

Creating 2-D Arrays
-----------------------------------
It there a way to massively create variables?
As in I am creating a tiling system for a RPG game, but there are some tiles that you cannot walk over, so I want a 2-D array to say what you can and cannot walk over.
I need to massively creat because there are multiple screens.
Please give suggestions.
THX!

-----------------------------------
Asherel
Thu May 08, 2008 1:15 pm

Re: Creating 2-D Arrays
-----------------------------------
You'll need to look into multi-dimentional arrays.Therefore, the one array would play as an (x,y) location on the screen for you to check.

There is a [url=http://compsci.ca/v3/viewtopic.php?t=14333]walkthrough for what you need there. Take a look into the Arrays. 

If you still have questions, then look us up again.

-----------------------------------
CodeMonkey2000
Thu May 08, 2008 7:54 pm

RE:Creating 2-D Arrays
-----------------------------------
Here is the basic syntax for 2D arrays.
const x := 5
const y := 6
var foo : array 1 .. x, 1 .. y of int
foo (1, 1) := 5
put foo (1, 1)


Now if you want dynamic maps (maps that vary in size) you will need to use a single dimensional flexible array. You just create how many ever elements you need, and just make up a convention you can use that takes the x and y values and finds the proper location in the single dimensional array. Remember a 3 by 3 array still has 9 elements.

-----------------------------------
Nick
Thu May 08, 2008 8:01 pm

RE:Creating 2-D Arrays
-----------------------------------
Yusong knows how to do this based on her post
 so I want a 2-D array to say what you can and cannot walk over

so back to the question, the best way to "massively create" variables is to do so by a file, have each file be a single room, then when the player changes rooms, change the 2D array

-----------------------------------
Saad
Thu May 08, 2008 8:04 pm

Re: Creating 2-D Arrays
-----------------------------------
Seeing how you said "massively create" brings me to think of how big. If a map is relatively big then you might want to consider splitting the bigger map into a group of smaller maps. That way if you need to you can load smaller sections of maps each time and avoid "massively creating" variables.

-----------------------------------
yusong
Mon May 12, 2008 8:41 am

RE:Creating 2-D Arrays
-----------------------------------
Ok, I have already created the arrays and stored it in a pic. But there are tiles, like number 15 and aboves that you cannot walk over, so I either have to not use the pictures and create the tiles in the game or create more arrays and store where you can walk and cannot walk.

-----------------------------------
CodeMonkey2000
Mon May 12, 2008 10:43 am

RE:Creating 2-D Arrays
-----------------------------------
Use a record that memorizes the picutre and the property.
