Quote: "Those errors mean that one of the libraries were built in debug mode while another is built in release mode. Not sure if the problem is with Dark GDK or with stringstream. Are you in Release mode or Debug mode?"
I'm in debug mode. It works in release mode, I have to be able to set breakpoints or else there's no way to manage some of the bugs I get.
Quote: "Maybe we can find out more if you post actual code and not only the errors. my guess is that you are using namespace std. instead of using a namespace, put std:: on the left of the std type variables. for example, for a string, use std::string and remove using namespace std;."
As far as I can see, I don't nave "using namespace std;" anywhere. As for posting code, my project's pretty large, with many classes; I suppose I could post the level.cpp, which is being referenced in the error. It's pretty massive itself though:
#include "CLevel.h"
//Default Constructor
Level::Level()
{
numRooms = 0;
xDim = 0;
yDim = 0;
RoomNodeX = NULL;
RoomNodeY = NULL;
RoomNodeXD = NULL;
RoomNodeYD = NULL;
}
//Init Constructor
Level::Level(int rooms, int x, int y, int numplayers)
{
numRooms = rooms;
xDim = x;
yDim = y;
//Note: we initialize the array to numRooms + 1 because we want to include a center room
//that connects all quadrants together
RoomNodeX = new int[numRooms + 1];
RoomNodeY = new int[numRooms + 1];
RoomNodeXD = new int[numRooms + 1];
RoomNodeYD = new int[numRooms + 1];
numPlayers = numplayers;
Players = new Player*[numplayers];
for(int i = 0; i < numPlayers; i++)
Players[i] = NULL;
}
//Copy Constructor
Level::Level(const Level& l)
{
numRooms = l.numRooms;
xDim = l.xDim;
yDim = l.yDim;
for(int i = 0; i < numRooms + 1; i++)
{
RoomNodeX[i] = l.RoomNodeX[i];
RoomNodeY[i] = l.RoomNodeX[i];
RoomNodeXD[i] = l.RoomNodeX[i];
RoomNodeYD[i] = l.RoomNodeX[i];
}
for(int i = 0; i < numPlayers; i++)
Players[i] = l.Players[i];
}
Level::~Level()
{
delete [] RoomNodeX;
delete [] RoomNodeY;
delete [] RoomNodeXD;
delete [] RoomNodeYD;
}
//Gets a random number from the "from" variable to the "to" variable
int Level::GetRand(int from, int to)
{
return std::rand() % (to - from + 1) + from;
}
//Draws a box using DarkGDK's dbBox function, which takes parameters of top left and bottom right
//coords of the box.
void Level::DrawBox(int xCenter, int yCenter, int length, int width)
{
dbBox(xCenter - width/2, yCenter - length/2, xCenter + width/2, yCenter + length/2);
}
//Generates a level drawn of boxes. Note that x and y should be taken as the number of pixels divided
//by GRID_SIZE, so that all numRooms can be made as a grid.
void Level::Draw()
{
//Create a bitmap to store the image data in
dbCreateBitmap(LEVEL_Q1_BITMAP, xDim*GRID_SIZE, yDim*GRID_SIZE);
dbSetCurrentBitmap(LEVEL_Q1_BITMAP);
//Set the background to black and the draw color to white
dbInk(dbRGB(255, 255, 255), dbRGB(0, 0, 0));
//Draw each room to the bitmap using the room coordinates and dimensions
for(int i = 0; i < numRooms + 1; i++)
DrawBox(RoomNodeX[i] * GRID_SIZE, RoomNodeY[i] * GRID_SIZE, RoomNodeXD[i] * GRID_SIZE, RoomNodeYD[i] * GRID_SIZE);
//Connect all the numRooms with straight hallways
for(int i = 0; i < numRooms; i++)
{
for(int j = i + 1; j < numRooms + 1; j++) //numRooms + 1 so the center room gets connected
{
//In this case it is easier to use the DarkGDK draw box function instead of ours
//Check if the room j is above or below the room i (need to specify top and bottom of box)
if(RoomNodeY[i] > RoomNodeY[j])
//Draw a box up from the i's Y to j's Y, make it width 64
dbBox(RoomNodeX[i] * GRID_SIZE - GRID_SIZE, RoomNodeY[j] * GRID_SIZE, RoomNodeX[i] * GRID_SIZE + GRID_SIZE, RoomNodeY[i] * GRID_SIZE);
else
//Draw a box down from i's Y to j's Y, make it width 64
dbBox(RoomNodeX[i] * GRID_SIZE - GRID_SIZE, RoomNodeY[i] * GRID_SIZE, RoomNodeX[i] * GRID_SIZE + GRID_SIZE, RoomNodeY[j] * GRID_SIZE);
//Check if j is to the right or left of i
if(RoomNodeX[i] < RoomNodeX[j])
//Draw a box from the top or bottom (depending on which direction the want-to-connect room node is)
//of i to j in the right direction
dbBox(RoomNodeX[i] * GRID_SIZE - GRID_SIZE, RoomNodeY[j] * GRID_SIZE - GRID_SIZE, RoomNodeX[j] * GRID_SIZE, RoomNodeY[j] * GRID_SIZE + GRID_SIZE);
else
//Draw a box from the top or bottom (depending on which direction the want-to-connect room node is)
//of i to j in the left direction
dbBox(RoomNodeX[j] * GRID_SIZE, RoomNodeY[j] * GRID_SIZE - GRID_SIZE, RoomNodeX[i] * GRID_SIZE - GRID_SIZE, RoomNodeY[j] * GRID_SIZE + GRID_SIZE);
}
}
//Create the bitmap to house the entire level
dbCreateBitmap(LEVEL_BITMAP, xDim*64, yDim*64);
//Copy the first quadrant in
dbCopyBitmap(LEVEL_Q1_BITMAP, 0, 0, xDim*GRID_SIZE, yDim*GRID_SIZE, LEVEL_BITMAP, xDim*GRID_SIZE, 0, xDim*GRID_SIZE*2, yDim*GRID_SIZE);
//Mirror and flip the first quadrant to create the other quadrants and copy them to the level bitmap
dbMirrorBitmap(LEVEL_Q1_BITMAP); //Now mirrored (2nd quadrant)
dbCopyBitmap(LEVEL_Q1_BITMAP, 0, 0, xDim*GRID_SIZE, yDim*GRID_SIZE, LEVEL_BITMAP, 0, 0, xDim*GRID_SIZE, yDim*GRID_SIZE);
dbFlipBitmap(LEVEL_Q1_BITMAP); //Now mirrored and flipped (3rd quadrant)
dbCopyBitmap(LEVEL_Q1_BITMAP, 0, 0, xDim*GRID_SIZE, yDim*GRID_SIZE, LEVEL_BITMAP, 0, yDim*GRID_SIZE, xDim*GRID_SIZE, yDim*GRID_SIZE*2);
dbMirrorBitmap(LEVEL_Q1_BITMAP); //Now only flipped (4th quadrant)
dbCopyBitmap(LEVEL_Q1_BITMAP, 0, 0, xDim*GRID_SIZE, yDim*GRID_SIZE, LEVEL_BITMAP, xDim*GRID_SIZE, yDim*GRID_SIZE, xDim*GRID_SIZE*2, yDim*GRID_SIZE*2);
//Make the bitmap into an image so it can be translated into a sprite
//(for collision detection purposes
dbSetCurrentBitmap(LEVEL_BITMAP);
dbGetImage(LEVEL_IMAGE, 0, 0, xDim*GRID_SIZE*2, yDim*GRID_SIZE*2);
dbSaveImage("LevelImg.bmp", LEVEL_IMAGE);
//Set the current bitmap back to 0 just in case there are screen drawing operations after this
dbSetCurrentBitmap(0);
}
//Draw all the entities that the level has stored; this includes players, projectiles etc.
//Needs the x and y coordinates of the center of the screen, as well as the screen's width and height.
void Level::DrawEntities(int xCenter, int yCenter, int screenWidth, int screenHeight)
{
for(int i = 0; i < numPlayers; i++)
if(Players[numPlayers] != NULL)
// ============ TODO - I fudged the origins here since I'm not using DrawEntities yet, make them ORIGIN_X and ORIGIN_Y!
Players[numPlayers]->Draw(xCenter, yCenter, screenWidth, screenHeight);
}
//Gets the max number of players
int Level::GetNumPlayers() const
{
return numPlayers;
}
//Gets the pointer to a specific player
Player* Level::GetPlayer(int pID)
{
return Players[pID];
}
// ----- Setters -----
void Level::SetXDim(int x)
{
xDim = x;
}
void Level::SetYDim(int y)
{
yDim = y;
}
void Level::SetNumRooms(int rooms)
{
numRooms = rooms;
}
void Level::SetRNX(int index, int RNX)
{
RoomNodeX[index] = RNX;
}
void Level::SetRNY(int index, int RNY)
{
RoomNodeY[index] = RNY;
}
void Level::SetRNXD(int index, int RNXD)
{
RoomNodeXD[index] = RNXD;
}
void Level::SetRNYD(int index, int RNYD)
{
RoomNodeYD[index] = RNYD;
}
void Level::AddPlayer(char* n, int pID, int posX, int posY)
{
Players[pID] = new Player(pID, n, posX, posY, NULL);
}
void Level::SetPlayer(int pID, Player* player)
{
Players[pID] = player;
}