Hmm..
1>------ Build started: Project: Kings of Doom, Configuration: Debug Win32 ------
1>Linking...
1> Creating library DebugKings of Doom.lib and object DebugKings of Doom.exp
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>KoD.obj : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: struct _creature & __thiscall std::vector<struct _creature,class std::allocator<struct _creature> >::operator[](unsigned int)" (??A?$vector@U_creature@@V?$allocator@U_creature@@@std@@@std@@QAEAAU_creature@@I@Z)
1>libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
1>DebugKings of Doom.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:Kings of DoomKings of DoomDebugBuildLog.htm"
1>Kings of Doom - 5 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
my whole project code:
//====================================================================================================================================//
//======================================================KINGS OF DOOM=================================================================//
//====================================================================================================================================//
//--------------------------------------------------------INCLUDES--------------------------------------------------------------------//
#include "DarkGDK.h"
#include "direct.h"
#include "stdio.h"
#include "ReadCache.h"
#include <vector>
using std::vector;
//--------------------------------------------------------DEFINES--------------------------------------------------------------------//
//------------------------------------------------------STRUCTURES-------------------------------------------------------------------//
enum _gamemodes { eMainMenu, eLoad, ePlay, eLose, eWin };
_gamemodes eGameMode = eMainMenu;
struct _player
{
int bullets;
int maxbullets;
int curhealth;
int maxhealth;
int Xloc;
int Zloc;
} player;
typedef struct _creature
{
int ID;
char path[80];
int health;
struct
{
int X;
int Y;
int Z;
} position;
int scale;
} creature;
//------------------------------------------------------FUNCTIONS--------------------------------------------------------------------//
void game (void);
void MainMenu (void);
void LoadGame (void);
void Play (void);
void GameLose (void);
void GameWin (void);
void DisplayPlayerHealth (void);
void UpdatePlayerHealth (void);
void DisplayAmmo (void);
void UpdateAmmo (void);
void UpdatePlayerCamera (void);
void CheckMainMenu (void);
void LoadData (void);
void SaveData (void);
void CreateCreature (int ID, int health, int scale, int X, int Z, char path[80], int loopit);
void ReduceObjectHealth (int objID);
void DrawObjects (void);
//---------------------------------------------------GLOBAL VARIABLES----------------------------------------------------------------//
int iTime = 0;
int firetimer = 0;
float OldCamAngleY;
float OldCamAngleX;
float CameraAngleY;
float CameraAngleX;
int loadX = 200;
int loadZ = 200;
int continued = 0;
vector<creature> creatV(0);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void DarkGDK (void)
{
dbSyncOn();
dbSyncRate(60);
dbSetWindowLayout(0,0,2);
dbSetDisplayMode ( 1366 , 768 , 32 );
dbMaximiseWindow();
dbDisableEscapeKey();
while(1)
{
game();
dbUpdateTerrain();
dbSync();
}
}
void game (void)
{
switch (eGameMode)
{
case eMainMenu:
MainMenu();
break;
case eLoad:
LoadGame();
break;
case ePlay:
Play();
break;
case eLose:
GameLose();
break;
case eWin:
GameWin();
break;
}
}
void MainMenu (void)
{
dbHideMouse();
dbLoadImage("data\images\start screen.jpg" , 1);
dbLoadImage("data\images\start screen-continue.jpg" , 2);
dbLoadImage("data\images\start screen-new game.jpg" , 3);
dbLoadImage("data\images\start screen-exit game.jpg" , 4);
dbLoadImage("data\images\cursor2.tga" , 5);
dbLoadImage("data\images\hidden cursor.tga" , 6);
dbLoadImage("data\images\glow2.tga" , 7);
dbSprite(1,0,0 , 1);
dbSprite(2,50,(dbScreenHeight()/2)+100 , 2);
dbSprite(3,50,(dbScreenHeight()/2)+160, 3);
dbSprite(4,50,(dbScreenHeight()/2)+220, 4);
while(1)
{
failedclick:
dbSprite(5,dbMouseX(),dbMouseY() , 5);
dbSprite(6,dbMouseX(),dbMouseY() , 6);
dbSync();
if(dbEscapeKey() == 1)
{
while(dbEscapeKey() == 1)
{}
exit(0);
}
while(dbSpriteCollision(6,2)) //continue
{
dbSprite(5,dbMouseX(),dbMouseY() , 5);
dbSetSpritePriority(5,2);
dbSprite(6,dbMouseX(),dbMouseY() , 6);
dbSprite(7,40,(dbScreenHeight()/2)+90,7);
dbSync();
if(dbMouseClick() == 1)
{
while(dbMouseClick() == 1)
{
dbSprite(5,dbMouseX(),dbMouseY() , 5);
dbSetSpritePriority(5,2);
dbSprite(6,dbMouseX(),dbMouseY() , 6);
if(!dbSpriteCollision(6,2))
goto failedclick;
dbSync();
}
LoadData();
continued = 1;
goto choosen;
}
}
dbDeleteSprite(7);
while(dbSpriteCollision(6,3))
{
dbSprite(5,dbMouseX(),dbMouseY() , 5);
dbSetSpritePriority(5,2);
dbSprite(6,dbMouseX(),dbMouseY() , 6);
dbSprite(7,40,(dbScreenHeight()/2)+150,7);
dbSync();
if(dbMouseClick() == 1)
{
while(dbMouseClick() == 1)
{
dbSprite(5,dbMouseX(),dbMouseY() , 5);
dbSetSpritePriority(5,2);
dbSprite(6,dbMouseX(),dbMouseY() , 6);
if(!dbSpriteCollision(6,3))
goto failedclick;
dbSync();
}
goto choosen;
}
}
dbDeleteSprite(7);
while(dbSpriteCollision(6,4))
{
dbSprite(5,dbMouseX(),dbMouseY() , 5);
dbSetSpritePriority(5,2);
dbSprite(6,dbMouseX(),dbMouseY() , 6);
dbSprite(7,40,(dbScreenHeight()/2)+210,7);
dbSync();
if(dbMouseClick() == 1)
{
while(dbMouseClick() == 1)
{
dbSprite(5,dbMouseX(),dbMouseY() , 5);
dbSetSpritePriority(5,2);
dbSprite(6,dbMouseX(),dbMouseY() , 6);
if(!dbSpriteCollision(6,4))
goto failedclick;
dbSync();
}
exit(0);
}
}
dbDeleteSprite(7);
}
choosen:
dbDeleteSprite(2);
dbDeleteSprite(3);
dbDeleteSprite(4);
dbDeleteSprite(5);
dbDeleteSprite(6);
dbDeleteSprite(7);
eGameMode=eLoad;
}
void LoadGame (void)
{
dbLoadSound("data\sounds\shoot.wav", 1);
dbLoadImage("data\images\Detail Image.jpg",101);
dbLoadImage("data\images\level 1 texture.jpg",102);
dbLoadImage("data\images\healthx1.tga",1001);
dbLoadImage("data\images\healthx2.tga",1000);
dbSetCameraRange (0, 1.0f, 5000.0f );
dbSetupTerrain ( );
dbMakeObjectTerrain ( 1 );
dbSetTerrainHeightMap ( 1, "data\images\level 1 heights.jpg" );
dbSetTerrainScale ( 1, 5.0f, 1.0f, 5.0f );
dbSetTerrainLight ( 1, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f );
dbSetTerrainTexture ( 1, 102,101);
dbBuildTerrain ( 1 );
dbPositionCamera(0, loadX,dbGetTerrainGroundHeight(1,loadX,loadZ)+10,loadZ);
player.maxhealth = 10;
if(continued == 0)
{
player.bullets = 99;
player.maxbullets = 99;
player.curhealth = 10;
}
//==================================================Create Creatures=========================================================
CreateCreature(1100,0,100,200,200,"Data\Objects\Flames.X",1);
//===========================================================================================================================
dbLoadImage("data\images\main menu.jpg" , 201);
dbLoadImage("data\images\main menu-options.jpg" , 202);
dbLoadImage("data\images\main menu-resume.jpg" , 203);
dbLoadImage("data\images\main menu-exit game.jpg" , 204);
dbSprite(201,(dbScreenWidth()/2)-100,(dbScreenHeight()/2)-150,201);
dbHideSprite(201);
dbSprite(202,(dbScreenWidth()/2)-56,(dbScreenHeight()/2)-110,202);
dbHideSprite(202);
dbSprite(203,(dbScreenWidth()/2)-56,(dbScreenHeight()/2)-22,203);
dbHideSprite(203);
dbSprite(204,(dbScreenWidth()/2)-56,(dbScreenHeight()/2)+66,204);
dbHideSprite(204);
dbDeleteSprite(1);
DisplayPlayerHealth();
DisplayAmmo();
dbLoadImage("data\images\cursor.tga",103);
dbSprite(103,(dbScreenWidth()/2)-50,(dbScreenHeight()/2)-50,103);
eGameMode=ePlay;
}
void Play (void)
{
iTime=dbTimer();
dbPositionMouse(dbScreenWidth()/2,dbScreenHeight()/2);
UpdatePlayerCamera();
UpdateAmmo();
UpdatePlayerHealth();
CheckMainMenu();
dbSync();
}
void GameLose (void)
{
}
void GameWin (void)
{
}
void DisplayPlayerHealth (void)
{
int PMH;
int PCH;
int countX=0;
int countX2=0;
int multiply=10;
PMH=10;
PCH=player.curhealth;
for(int count=1000;count<(PMH*multiply)+1000;count++) //print max health
{
dbSprite(count,countX,0,1000);
dbSetSpritePriority(count,2);
countX++;
}
for(int count2=1200;count2<(PCH*multiply)+1200;count2++) //current health
{
dbSprite(count2,countX2,0,1001);
dbSetSpritePriority(count2,3);
countX2++;
}
dbSync();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void UpdatePlayerHealth (void)
{
int PCH;
int countX=0;
int multiply=10;
PCH=player.curhealth;
for(int count3=1200;count3< 1300;count3++) //current health
{
dbDeleteSprite(count3);
}
for(int count2=1200;count2<(PCH*multiply)+1200;count2++) //current health
{
dbSprite(count2,countX,0,1001);
dbSetSpritePriority(count2,3);
countX++;
}
dbSync();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void DisplayAmmo (void)
{
int countX=0;
for(int count = 1500;count < 1600;count++)
dbDeleteSprite(count);
for(int count = 1500; count < 1500+player.maxbullets; count++) //max bullets
{
dbSprite(count,countX,30,1000);
countX++;
}
countX=0;
for(int count = 1500; count < 1500+player.bullets; count++) //cur bullets
{
dbSprite(count,countX,30,1001);
dbSetSpritePriority(count,5);
countX++;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void UpdateAmmo (void)
{
if(dbMouseClick() == 1 && player.bullets > 0 && iTime > firetimer+0.3)
{
dbPlaySound(1);
player.bullets--;
firetimer=dbTimer();
}
if(dbMouseClick() == 2 && player.bullets < 98 && player.maxbullets > 32)
{
player.bullets = 99;
player.maxbullets -= 33;
}
DisplayAmmo();
}
float GetCurrentY (void)
{
return dbCameraPositionY();
}
float GetCurrentX (void)
{
return dbCameraPositionX();
}
float GetCurrentZ (void)
{
return dbCameraPositionZ();
}
void UpdatePlayerCamera (void)
{
float CurY = GetCurrentY();
float CurX = GetCurrentX();
float CurZ = GetCurrentZ();
if ( dbUpKey() || dbKeyState( 17 ) == 1 ) //forward
{
dbMoveCamera ( 0 , 1 );
}
if ( dbDownKey() || dbKeyState( 31 ) == 1 ) //backward
{
dbMoveCamera ( 0 , -1 );
}
if (dbKeyState( 16 ) == 1 ) //Q
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -90 );
dbMoveCamera ( 0 , 1 );
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) +90 );
}
if ( dbKeyState( 18 ) == 1 )//E
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) + 90 );
dbMoveCamera ( 0 , 1 );
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -90 );
}
if ( dbKeyState( 32 ) == 1 || dbKeyState(89) == 1)//Right
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) +3 );
}
if ( dbKeyState( 30 ) == 1 || dbKeyState(79) == 1)//left
{
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -3 );
}
//mouse camera control
float cx = dbCameraPositionX ( 0 );
float cy = dbCameraPositionY ( 0 ) -40;
float cz = dbCameraPositionZ ( 0 );
float OldCamAngleY = dbCameraAngleY ( 0 );
float OldCamAngleX = dbCameraAngleX ( 0 );
CameraAngleY = dbWrapValue ( ( dbCameraAngleY ( 0 ) + dbMouseMoveX ( ) * 0.4f ) );
CameraAngleX = dbWrapValue ( ( dbCameraAngleX ( 0 ) + dbMouseMoveY ( ) * 0.4f ) );
if ( CameraAngleX > 80 && CameraAngleX <180 ) CameraAngleX = 80;
if ( CameraAngleX < 270 && CameraAngleX > 180 ) CameraAngleX = 270;
dbYRotateCamera ( 0 , dbCurveAngle ( CameraAngleY , OldCamAngleY , 6 ) );
dbXRotateCamera ( 0 , dbCurveAngle ( CameraAngleX , OldCamAngleX , 6 ) );
if (dbMouseX() > (dbScreenWidth()-40)) //right
{
dbPositionMouse(dbScreenWidth()-40,dbMouseY());
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) +3 );
}
if (dbMouseX() < 40) //left
{
dbPositionMouse(40,dbMouseY());
dbYRotateCamera ( 0 , dbCameraAngleY( 0 ) -3 );
}
if (dbMouseY() > (dbScreenHeight()-40)) //down
{
dbPositionMouse(dbMouseX(),dbScreenHeight()-40);
dbXRotateCamera ( 0 , dbCameraAngleX( 0 ) +3 );
if (dbCameraAngleX(0) > 80)
dbXRotateCamera ( 0 , dbCameraAngleX( 0 ) -3 );
}
if (dbMouseY() < 40) //up
{
dbPositionMouse(dbMouseX(),40);
dbXRotateCamera ( 0 , dbCameraAngleX( 0 ) -3 );
if (dbCameraAngleX(0) < -80)
dbXRotateCamera ( 0 , dbCameraAngleX( 0 ) +3 );
}
dbPositionCamera ( 0 , dbCameraPositionX ( 0 ) , dbGetTerrainGroundHeight(1,dbCameraPositionX(0),dbCameraPositionZ(0))+10 , dbCameraPositionZ ( 0 ) );
dbSetPointLight ( 0 , dbCameraPositionX ( 0 ) , 80 , dbCameraPositionZ ( 0 ) );
if(GetCurrentY() > CurY+1)
dbPositionCamera(CurX,CurY,CurZ);
player.Xloc = dbCameraPositionX(0);
player.Zloc = dbCameraPositionZ(0);
}
void CheckMainMenu (void)
{
if(dbEscapeKey())
{
while(dbEscapeKey()) {}
dbHideSprite(103);
dbShowSprite(201);
dbShowSprite(202);
dbShowSprite(203);
dbShowSprite(204);
dbSync();
while(1)
{
failedtoclick:
dbSprite(5,dbMouseX()-50,dbMouseY()-50,5);
dbSprite(6,dbMouseX()-50,dbMouseY()-50,6);
dbSync();
if(dbEscapeKey())
{
while(dbEscapeKey()) {}
goto choosen2;
}
while(dbSpriteCollision(6,202)) // options
{
dbSprite(5,dbMouseX()-50,dbMouseY()-50,5);
dbSprite(6,dbMouseX()-50,dbMouseY()-50,6);
dbSetSpritePriority(5,2);
dbSprite(7,(dbScreenWidth()/2)-66,(dbScreenHeight()/2)-120,7);
dbSync();
if(dbMouseClick() == 1)
{
while(dbMouseClick() == 1 && dbSpriteCollision (6,202))
{
dbSprite(5,dbMouseX()-50,dbMouseY()-50,5);
dbSprite(6,dbMouseX()-50,dbMouseY()-50,6);
dbSetSpritePriority(5,2);
dbSync();
}
if(!dbSpriteCollision(6,202))
goto failedtoclick;
//###########################################OPTIONS######################################################
}
}
dbDeleteSprite(7);
while(dbSpriteCollision(6,203)) // resume
{
dbSprite(5,dbMouseX()-50,dbMouseY()-50,5);
dbSprite(6,dbMouseX()-50,dbMouseY()-50,6);
dbSetSpritePriority(5,2);
dbSprite(7,(dbScreenWidth()/2)-66,(dbScreenHeight()/2)-32,7);
dbSync();
if(dbMouseClick() == 1)
{
while(dbMouseClick() == 1 && dbSpriteCollision (6,203))
{
dbSprite(5,dbMouseX()-50,dbMouseY()-50,5);
dbSprite(6,dbMouseX()-50,dbMouseY()-50,6);
dbSetSpritePriority(5,2);
dbSync();
}
if(!dbSpriteCollision(6,203))
goto failedtoclick;
goto choosen2;
}
}
dbDeleteSprite(7);
while(dbSpriteCollision(6,204)) // exit game
{
dbSprite(5,dbMouseX()-50,dbMouseY()-50,5);
dbSprite(6,dbMouseX()-50,dbMouseY()-50,6);
dbSetSpritePriority(5,2);
dbSprite(7,(dbScreenWidth()/2)-66,(dbScreenHeight()/2)+56,7);
dbSync();
if(dbMouseClick() == 1)
{
while(dbMouseClick() == 1 && dbSpriteCollision (6,204))
{
dbSprite(5,dbMouseX()-50,dbMouseY()-50,5);
dbSprite(6,dbMouseX()-50,dbMouseY()-50,6);
dbSetSpritePriority(5,2);
dbSync();
}
if(!dbSpriteCollision(6,204))
goto failedtoclick;
SaveData();
exit(0);
}
}
dbDeleteSprite(7);
}
choosen2:
dbHideSprite(201);
dbHideSprite(202);
dbHideSprite(203);
dbHideSprite(204);
dbDeleteSprite(5);
dbDeleteSprite(6);
dbDeleteSprite(7);
dbShowSprite(103);
}
}
void SaveData (void)
{
FILE *X;
FILE *Z;
FILE *ammo;
FILE *maxammo;
FILE *health;
X = fopen("Data\cache\X.txt","w");
fprintf(X,"%d",player.Xloc);
fclose (X);
Z = fopen("Data\cache\Z.txt","w");
fprintf(Z,"%d",player.Zloc);
fclose (Z);
ammo = fopen("data\cache\ammo.txt","w");
fprintf(ammo,"%d",player.bullets);
fclose (ammo);
maxammo = fopen("data\cache\maxammo.txt","w");
fprintf(maxammo,"%d",player.maxbullets);
fclose(maxammo);
health = fopen("data\cache\health.txt","w");
fprintf(health,"%d",player.curhealth);
fclose(health);
}
void LoadData (void)
{
FILE *X;
char Xbuff[30];
FILE *Z;
char Zbuff[30];
FILE *ammo;
char ammobuff[30];
FILE *maxammo;
char maxammobuff[30];
FILE *health;
char healthbuff[30];
int result;
X = fopen("Data\cache\X.txt","r");
while(1)
{
fgets(Xbuff,30,X);
result=feof(X);
if(result != 0 )
break;
}
loadX = ReadCache(Xbuff);
fclose (X);
result=0;
Z = fopen("Data\cache\Z.txt","r");
while(1)
{
fgets(Zbuff,30,Z);
if(Zbuff != 0)
break;
}
loadZ = ReadCache(Zbuff);
fclose (Z);
result=0;
ammo = fopen("data\cache\ammo.txt","r");
while(1)
{
fgets(ammobuff,30,ammo);
result = feof(ammo);
if(result != 0)
break;
}
player.bullets = ReadCache(ammobuff);
fclose (ammo);
result=0;
maxammo = fopen("data\cache\maxammo.txt","r");
while(1)
{
fgets(maxammobuff,30,maxammo);
result = feof(maxammo);
if(result != 0 )
break;
}
player.maxbullets = ReadCache(maxammobuff);
fclose(maxammo);
result=0;
health = fopen("data\cache\health.txt","r");
while(1)
{
fgets(healthbuff,30,health);
result = feof(health);
if(result != 0 )
break;
}
player.curhealth = ReadCache(healthbuff);
fclose(health);
result = 0;
}
void CreateCreature (int ID, int health, int scale, int X, int Z, char path[80], int loopit)
{
creature creat;
creat.ID = ID;
creat.health = health;
creat.scale = scale;
creat.position.X = X;
creat.position.Z = Z;
creat.position.Y = dbGetTerrainGroundHeight(1,X,Z);
strcpy(creat.path, path);
/*dbLoadObject(creat.path,creat.ID);
dbPositionObject(creat.ID,creat.position.X,creat.position.Y,creat.position.Z);
dbLoopObject(creat.ID);
dbSetObjectSpeed(creat.ID, 5000);*/
creatV.push_back(creat); // add the new creature into the vector
}
void ReduceObjectHealth(int ID)
{
for(int i = 0; i < creatV.size(); i++) // iterate through all creatures in vector
if(creatV[i].ID == ID) // If the creature's ID equals the ID of the one sent to the function
creatV[i].health -= 2; //Accessing a creature and decreasing its health
}
void DrawObjects (void)
{
for(int i = 0; i < creatV.size();i++)
{
dbLoadObject(creatV[i].path,creatV[i].ID);
dbPositionObject( creatV[i].ID , creatV[i].position.X , creatV[i].position.Y , creatV[i].position.Z );
dbLoopObject(creatV[i].ID);
dbSetObjectSpeed(creatV[i].ID, 5000);
}
}
Well im running debug mode, since release mode is totally screwed up somehow, it breaks once my gam runs, anyway before testing your example my game was running just fine, but now my debug\KoD.exe is gone