"Grim Reaper" said: I gots me some questions: 1. How can I make a 2d array? -------------------------------- you make array of arrays.
Speudo: map = [ [1,1,1,1,1,1], [1,0,0,0,0,1], [1,0,0,0,0,1], [1,0,0,0,0,1], [1,0,0,0,0,1], [1,1,1,1,1,1], ] -------------------------------- 2. How can I store characters, symbols and other markings in a 2d array? -------------------------------- Depends about a language. You don't have to use that array, you can use also separate object array.
In some case you can structure your cell.
Speudo: class Cell: objects = [] type = 'wall' __init__(self, type = 'wall'): self.type = type
# Turn your original array into a celled map. map = -------------------------------- 3. How can I make an object (or something else) that can be controlled to move about using a 2d array containing characters, symbols etc. as a background? -------------------------------- You have a reference into that character on your map. then you just find out where he is, and move him from cell into another. -------------------------------- 4. How could I store the X and Y positions of the player inside the array? (this one I think I have pretty much figured out, asked anyway) -------------------------------- Descbrided above. -------------------------------- 5. How could I do so that the player can't go through some "tiles" while he can go through some other ones (best thing I've figured out is a 2d array storing different types of numbers depending on what type of tile there is)? -------------------------------- you put the behauvior into tile type. -------------------------------- 6.How could I create objects (or something like that) that change their appearance once the player hits them (=switches)? -------------------------------- you can make a callback or event system('switch') which allows you to attack a extra behauvior into the cell. In event system, it must have some fallbacking ( ie. can character step on it? ) because information is not immediately processed in that case. -------------------------------- 7. How could I make it so that once a switch is hit, something happens in that (or in some other) room? -------------------------------- you set behauvior into a 'switch'.
|