Recommendation for Way to Structure Data

Monkey Forums/Monkey Programming/Recommendation for Way to Structure Data

Kauffy(Posted 2012) [#1]
Hey, all--

I'm fairly new to Monkey and, even worse, have been out of coding for a looooong time.

I am putting together a (not that) simple game similar to the old arcade game Xenophobe.

For the purposes of how the data is structured for a level, this is my first swag at it:

Ship_Map is a 2D array of Ship_Screen (Ship_Map is just a simple layout of "screenfuls" of data)

Ship_Screen is a 2D array of Ship_Panel (Ship_Screen is everything that would be visible at once)

Ship_Panel is a 1D array of Ship_Slice (Ship_Panel is like a tile, but comprises layers of Ship_Slices-- think of BG, MG, FG)

Ship_Slice is the actual piece that gets drawn.

Is this an overly complicated arrangement, or does this make sense, and if it makes sense, how best to implement it? My hunches are to use actual 2D arrays, but they seem to be a little trickier to work with than I was anticipating.

Any help would be appreciated!


AdamRedwoods(Posted 2012) [#2]
you don't need ship_screen.
For Local y:= viewable_top to viewable_bottom
  For Local x:= viewable_left to viewable_right
    DrawImage ship_map[x][y].your_image
  Next
Next


You don't need ship_panel, draw everything in layers/ 3 passes. Are you going for parallax effect?


Kauffy(Posted 2012) [#3]
I wanted to use Ship_Screen as a way to break up the map--to reduce the amount and number of panels to be dealt with at a time.

I wanted to use the layers (panels) to allow more unique combinations of assets-- the background layer of the panel is always drawn, then in some cases, there are also objects in the middle ground (where players are) and sometimes there are objects in front (like columns, front panels for elevators, etc.)

I understand your method-- I may be overthinking the need to reduce the number of assets that have to be dealt with at any one time.

For example, in a Ship_Map that's 5x3 (five screens wide, by three tall), each screen has, say, eight panels across by three panels high, that's 40x9 panels and..... I am overthinking this aren't I?