Yeah, sorry about that. I've started working on dungeon generation, to take a break from trying to figure out field of view and a simpler way to handle path finding (I could use A-star, but when I already know there's an unobstructed straight-line path between the monster and the player, why bother?)...
Anyways, I think dungeon generation is mostly working, but I can't get it to actually cut out the rooms, so I can't be sure. I'm going to take a break and see if, like usual, I can figure it out by not trying so hard for a little while. Worst possible outcome, I don't and I can come back to it with a clear head
What I've got so far, should anyone care to look...
Code SnippitHow it's called:
Game.current_map = make_dungeon(64, 23, 3);
"map" is the same data structure I've been using, where an array of integers (tile[][]) represents what tile is in that position. (1 is a floor, 2 is a wall) "room" is a very simple data structure that simply holds the coordinates of the top-left and bottom-right corners of a room.
If someone figures it out, great! If not, I should get back to it later (probably after dinner, it's 5PM here), and we'll see when I can get it.
[EDIT]: Still working on it. I'll be updating the code snippet as I go (I love that website now...). I've changed it to make sure the coordinates are correct (x1,y1 is the top-left, x2,y2 is the bottom-right) and figured out that the problem is somehow related to the width and height never being above 10 for some reason... (I stuck "if(true)" in place of the width check, and it locked up on me. So while there may be further issues with it, my first problem is going to be figuring out why width and height aren't being set as I expected...)
[EDIT 2]: Well, I feel stupid... I had the structure set up wrong, so while I thought I was passing it (x1,y1, x2,y2) I was in fact passing it (x1,x2, y1,y2), notice the order difference? Yeah, zero minus zero is not more than ten... doesn't work well... at least is wasn't division this time. Unfortunately, as expected, there are new problems:
This is obviously not quite what I'm going for...
[EDIT 3]: Well, this is a bit better I guess:
I'm not too worried about connecting the rooms yet, I'd rather try to get them all cut out correctly first... anyways, the issue was, yet again, partially my passing things in the wrong order. I've also made a few more changes that should be making it work a bit better...
[EDIT 4]: Better still!
Something is still wrong with the width/height checking though, I'll look into it some more later... it's 9PM here, so I'm going to start winding down now, I think the family is down-stairs watching a movie anyways. I'll see if I can figure it out tomorrow...