New Dungeon Delving

Worked some on Dungeon Delving tonight; here’s the new version¬†[update: new version ]. I have walls, working walls, which I must tell you is no mean feat.

When I say walls, one must understand that what I actually have is an underlying data structure that can be used to represent any walls. The meager walls you see in the version here are but a glimmer of the walls to come, or at least that’s what I saw in my tea leaves this morning. And the tea leaves are never wrong.

I like working with grid-based systems; it simplifies so many things. I’m taking the general approach for this that there’s a data map that the player is walking around in, and that the graphics are mere representations of this, the One True Map, which only exists in memory.

Been a while since I goofed around with icky array math. Check this shit out:

var place_x = player_x;
var place_y = player_y;
for (i = 1; i < = map_hall_1[0][MAP_IDX_HEIGHT]; i++) {
    for (j = 1; j <= map_hall_1[0][MAP_IDX_WIDTH]; j++) {
        world_map[
            (place_y + map_hall_1[0][Y_OFFSET] + i - 1)
            ][
            (place_x + map_hall_1[0][X_OFFSET] + j - 1)
            ] = map_hall_1[i][j];
        }
    }

Which is to say, take the data version of the map piece we are placing onto the map, and copy its data into the map. This installs walls where there are now walls, doors where there are doors, etc, from the new map piece to the One True Map.

Hmm. It actually is more impressive knowing that I made 37 iterations to get all the +1s and [0]s and everything working. Anyway. Look, code!

It’s late, and I sleep now. Sleeeeeeeeeeeeeep.

Published by

the_darklorde

I design.

Leave a Reply

Your email address will not be published. Required fields are marked *