I have been allowed to program at work without fear of my boss taking my projects as they ARE written on "company time";
This was to keep me happy and not force me to quit and it is written in to my contract now! As a bonus if they need something we can negotiate pricing.
OK That said I am looking at me MAP EDITOR and MAP USE examples and I am trying to figure out how to implement LAYERS in my maps.
Layers would be a key component in any game system / map system... Has anyone ever worked on this? Does anyone know any theory?
Layers of confusion
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Yep, done it, and tis fun 
I end up using a link list of structures. This allows the map to be virtually unlimited in size and layers (limited by PB's structures).
Structure stTile
*sprite.i
x.i
y.i
layer.i
EndStructure
I then create a view list of the list of tiles based on the x,y,width,height of the view port (if you do scrolling maps). That view list is ordered by layer only. And rendered on demand.
When user add or remove a tile from the view port, it is added (or removed) from the tile list, and pointer is removed or added to the view list, and you are good to go.
I end up using a link list of structures. This allows the map to be virtually unlimited in size and layers (limited by PB's structures).
Structure stTile
*sprite.i
x.i
y.i
layer.i
EndStructure
I then create a view list of the list of tiles based on the x,y,width,height of the view port (if you do scrolling maps). That view list is ordered by layer only. And rendered on demand.
When user add or remove a tile from the view port, it is added (or removed) from the tile list, and pointer is removed or added to the view list, and you are good to go.
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Nope, one master list of tiles for that map (notice the layer.i in the structure). Then I have another list containing pointers to the master list of only the tiles that are visible to the user. I have scrolling maps so only a small subset of tiles are visible to the user at a time.
I render on that view list rather then the master list as it is much faster to cycle through (max: 1000 * layers) tiles then (max: 4 billion * layers), just to render the tiles that are viewable.
The reason I said 4 bill, because that is roughly the number of (long * long) in pb. And my maps are limited in width and height to the size of a long.
Oh, I noticed I didnt put in the 2nd link list (view list) structure..
structure stViewTile
*tile.stTile
screenX.i
screenY.i
endstructure
Im not at home, but thats the gist of it. I think I had to put in a layer.i member here to, I dont remember off the top of my head. It all depends if the SortList function can sort via pointer's structure's member or not.
I render on that view list rather then the master list as it is much faster to cycle through (max: 1000 * layers) tiles then (max: 4 billion * layers), just to render the tiles that are viewable.
The reason I said 4 bill, because that is roughly the number of (long * long) in pb. And my maps are limited in width and height to the size of a long.
Oh, I noticed I didnt put in the 2nd link list (view list) structure..
structure stViewTile
*tile.stTile
screenX.i
screenY.i
endstructure
Im not at home, but thats the gist of it. I think I had to put in a layer.i member here to, I dont remember off the top of my head. It all depends if the SortList function can sort via pointer's structure's member or not.
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
That is essentially what we do on he mainlayer... but
Reading all the layers...
Let is say I have a 4 layer map:
1. BACKGROUND
2. COLLECTIBLES etc.
3. ENEMY
4. PLAYER
i have to read through all 4 linked lists to create a view linked list?
Wow and managing collisions would require anothe rrun through the linked lists... comparing them...
larger than I thought... maybe a simple 2 layer game as proof of concept???
Reading all the layers...
Let is say I have a 4 layer map:
1. BACKGROUND
2. COLLECTIBLES etc.
3. ENEMY
4. PLAYER
i have to read through all 4 linked lists to create a view linked list?
Wow and managing collisions would require anothe rrun through the linked lists... comparing them...
larger than I thought... maybe a simple 2 layer game as proof of concept???
Hmm, I believe you are talking about two different things?
For instance, I was talking about graphical layers and speeding up their rendering ... nothing to do with the world objects (players, mobs, npcs, items, etc).
I keep those world objects in their own storage, and run collision detection on those, separately from the graphics
If you are not doing a client/server, then you can place those objects in an multi-dimensional array of the view port (so it's a small one), and place pointers to those objects.
Since you are doing a tiled map, I am assuming (?) that you are doing tile by tile movements? If that is the case, then you only need to do collision detection by tile location only
If you could provide a little more detail, hopefully, I can provide more usefull help
For instance, I was talking about graphical layers and speeding up their rendering ... nothing to do with the world objects (players, mobs, npcs, items, etc).
I keep those world objects in their own storage, and run collision detection on those, separately from the graphics
If you are not doing a client/server, then you can place those objects in an multi-dimensional array of the view port (so it's a small one), and place pointers to those objects.
Since you are doing a tiled map, I am assuming (?) that you are doing tile by tile movements? If that is the case, then you only need to do collision detection by tile location only
If you could provide a little more detail, hopefully, I can provide more usefull help
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Actually I am still trying to work out HOW I am going to do it... Let me zip up my scrolling map examples... Jared and I wrote this and I am at the oint where I am making decisions about HOW I will make things work...
You can see it here:
http://www.bluemesapc.com/Downloads/LEVEL1.zip
Doing the map and creating the graphics and scrolling it was the easy part... The much harder part will be figuring out HOW to do all the really fun bits!
You can see it here:
http://www.bluemesapc.com/Downloads/LEVEL1.zip
Doing the map and creating the graphics and scrolling it was the easy part... The much harder part will be figuring out HOW to do all the really fun bits!
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
My main fun bit right now is how to work an array for isometric perspective...
I am taking your idea of multiple layers in a 3D array creating a display list from that as to what is on screen... Collisions etc. Have a sokoban concept going...
Want to do a isometric sokoban... my next idea/project
Cannot work out how to arrange the array... For my hex game "H3x" I simply used a regular array and had cells in the array that could be termed BLANK areas that the computer was instructed to ignore... but as a sokoban has movement (pushing the box) I think I am stumped... I am probably working it too hard!
I am taking your idea of multiple layers in a 3D array creating a display list from that as to what is on screen... Collisions etc. Have a sokoban concept going...
Want to do a isometric sokoban... my next idea/project
Cannot work out how to arrange the array... For my hex game "H3x" I simply used a regular array and had cells in the array that could be termed BLANK areas that the computer was instructed to ignore... but as a sokoban has movement (pushing the box) I think I am stumped... I am probably working it too hard!

