Skip to main content
gamedev.net
🔒 Locked

debug assertion failed

Started by MinerWilly Aug 14, 2004 at 12:14 PM 2 replies 1.3k views
Original Post
MinerWilly
MinerWilly
I'm writting a little rogue type engine so i can play with more interesting things like random maps. anyway, i've been getting a debug assertion failed error and havent much of a clue how to fix it. I'm pretty sure i know where the problem is occuring though. ___________________________________________________________ h file: #include class tile { private: bool obstruction; bool elevated; public: tile() { obstruction = true; elevated = true; } ~tile() {} void setObstruction(bool); void setElevated(bool); bool returnObstruction(); bool returnElevated(); }; bool tile::returnObstruction() { return obstruction; } bool tile::returnElevated() { return elevated; } void tile::setObstruction(bool newObstruction) { obstruction = newObstruction; return; } void tile::setElevated(bool newElevated) { elevated = newElevated; return; } class dungeon { private: tile *map; public: dungeon(int mapSize) { //commenting this line out makes it run ok, i think the problem is in this part map = new tile[(mapSize*mapSize)]; } ~dungeon() { free(map); } void drawTile(int tileNum) { cout << map[tileNum].returnObstruction(); } }; ___________________________________________________________ cpp file: #include //commenting out tiles.h makes it not crash #include "tiles.h" const mapSize = 20; const screenHeight = 9; const screenWidth = 9; int screenX = 0; int screenY = 0; dungeon currentLevel(mapSize); void drawScreen(); void main() { drawScreen(); } void drawScreen() { int z= 0; //loop y for(int y=screenY; y<=screenHeight; y++) { //loop x for(int x=screenX; x<=screenWidth; x++) { //output the current map tile //Comment this line out till we fix the code //currentLevel.drawTile((y*mapSize)+x); //Just output some data for the moment till we stop crashing :c( cout << "\n" << "x=" << x << " y=" << y << "\t tilenumber=" << (y*mapSize)+x << "\t total outputs " << z; z++; } } } __________________________________________________________ A tile object just holds some properties of that square, dungeon objects being a collection of tiles. and the screen data in the main file is to create a window to look into the dungeon. I'm fairly certain the problem is in the h file when i create the array of tiles as commenting that line out makes it run without any problems (except it doesnt do anything at all).
MinerWilly
MinerWilly
Thanks guys.
Thats fixed it easy :)

*gives u all cocanuts*

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.