[C++/SFML] Trouble with BSP Dungeon Generation Algorithm

Started by
-1 comments, last by packetpirate 10 years, 4 months ago

I'm having some trouble with a BSP Dungeon Generation algorithm I'm working on, and I'm not really sure how to fix it. I got a general idea of how it's supposed to work based on this tutorial:

http://roguebasin.roguelikedevelopment.org/index.php?title=Basic_BSP_Dungeon_generation

However, the tutorial doesn't show any examples, and I had to just guess how everything worked and make my own. I'm running into several problems with my algorithm, mainly, an integer division by zero exception sometimes created by the CreateRooms() method of my MapGenerator class, and access violations for specific tiles (which I assume have something to do with the way I'm creating and initializing my 2D vector of tiles in the Map class). Can someone take a look at my classes and see if there's anything inherently wrong with my algorithm? I know there's a problem with the way I'm creating and initializing the tiles in the Map class' 2D vector, so maybe check that out first?

The things of note to look at would be the constructor in the Map class, and all the generation methods in the MapGenerator class. I'm not sure if anything else might be affecting it, but I'll attach all my classes to be sure.

SFMLApp.h: http://pastebin.com/jigFbPH5

SFMLApp.cpp: http://pastebin.com/tBdhgW7f

Map.h: http://pastebin.com/tmEY0tih

Map.cpp: http://pastebin.com/bV9NgkR8

Tile.h: http://pastebin.com/RCXhTK7i

Tile.cpp: http://pastebin.com/7uLGSuPb

MapGenerator.h: http://pastebin.com/F08ERcu2

MapGenerator.cpp: http://pastebin.com/npWxfmLK

There are some rudimentary comments that explain the gist of what each method is supposed to do, but if you have any questions, just ask.

EDIT: I figured it out. There were some fatal flaws with the way I was splitting the nodes that were causing invalid row/column/width/height values. I've corrected it now, and it partitions the spaces just fine.

This topic is closed to new replies.

Advertisement