Saturday, December 19, 2009

More split-level madness

Okay, so I didn't get maps working across levels, I realized I needed to improve the code that handles rooms before I could do that - last time I touched that items kept appearing outside of the rooms, and more importantly, inside of walls, replacing them.

So, I was looking at the code, and it got boring, so I added a spawn point to my map. And then I added code so I didn't have to hard-code in every spawn point, after all, this game is supposed to be about procedurally generated content, right?

Now the spawn points work, and as I work my way through five maps to get to my spawn point, I notice that there are a lot of monsters appearing on screen - they don't notice me because they're on a different map, but they're appearing on screen. I arrive on the new floor and get clobbered - I have to remember to spawn some items before I spawn those monsters next time, ouch.

I go in, and write two new pieces of code. The first makes monsters that are not on a map that is being drawn, do not draw (this saves on processor power, too). Then, I make it so spawn points that are not on a map the player is currently on, are not pumping out monsters, and even when the player is there, monsters no longer appear so quickly the player gets swamped. I know this is a bit of balancing, but if I'm going to be testing this a bajillion times, I might as well not have it so hard to kill a group of monsters as to be impossible.

Then I found the monsters, ran away and while on the other map I died. I was like 'whaaaat?'. So, I looked and I found that while I was marking the player as being on the new map, he was still being treated as if he were on the staircase of every level he passed through. Which means if a monster on another map walked by a staircase I had passed through, it would 'see' me, approach, and attack (and eventually kill) me. Glad I figured that out, that would have been an annoying issue to have resurface every now and then.

No comments:

Post a Comment