stefanweck / dungeongeneration

A roguelike game with a random dungeon generator. Written in Javascript.
www.stefanweck.nl
MIT License
198 stars 29 forks source link

Fixed browser crash on player death. Game now restarts with fresh map. #4

Closed ruscoe closed 10 years ago

ruscoe commented 10 years ago

The issue where a JS process would lock up the browser seemed to be a result of the scheduler no longer being locked between enemy pathfinding events, which was a result of the player entity being removed. You'd end up with an enemy stuck in a loop of finding a path to the player, somewhere in here.

I modified the combat code to lock the scheduler and set the game to an inactive state when the player is removed here.

I set up the game so it will automatically restart with a fresh map when it finds itself in an inactive state.

Seems to all be working from the testing I did. Let me know what you think.

stefanweck commented 10 years ago

Nice! That's awesome. I'm not home at the moment but whenever I am I'll merge the code and check it out!

Did it take you a long time to figure out how the code works? As in, can I make some improvements on making it more clear what's going on and how things operate.

ruscoe commented 10 years ago

It was easy enough to understand once I read through the component and scheduler systems. You have everything really well commented and that helps a lot.

I didn't have time to work on it until this weekend, but I only had to spend a few hours on this fix to get it all working.

stefanweck commented 10 years ago

Allright, that's good to hear. I've found a small bug though whenever the game creates a new map. The last visible tiles on the old map show up as explored tiles on the new map: bug_explored_tiles

I'll open up an issue for this problem and see if I can find the a solution today.

Issue: https://github.com/stefanweck/dungeongeneration/issues/5

ruscoe commented 10 years ago

Good catch. I'm happy to check that out if you don't have time. It's probably just something I didn't reset when the game restarts.

stefanweck commented 10 years ago

That would be great. I've taken a quick look at the problem but I'm supposed to start implementing the UI today. Thanks for your contributions, I appreciate it!

It helps when you lower the tilesize so you can see the entire map at once. In map.js there is a settings objects which holds the tileSize value. 16 should do fine!

https://github.com/stefanweck/dungeongeneration/blob/master/lib/tilemap/map.js#L89