I begin the adventure from The dark GDK
How I can do option save game if I can't load library <fstream>
1>------ Build started: Project: pong test, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>Linking...
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
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>Debug\pong test.exe : fatal error LNK1120: 2 unresolved externals
this is my game:
#include "DarkGDK.h"
#include "player1.h"
#include "player2.h"
#include <fstream>
int ballxvelocity=5,ballyvelocity=5;
int ballxcoord,ballycoord;
struct point
{
int x, y;
};
point ballV, ballCord;
int playerPoints1 = 0, playerPoints2 = 0;
float acceleration = 0;
bool state = 1;
player1 player1;
player2 player2;
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetImageColorKey ( 255, 0, 255 );
dbSetWindowTitle("Pong by Rudy Company ");
dbSetWindowSize(640,480);
dbLoadImage("menu.bmp",37);
dbLoadImage("play.bmp",38);
dbLoadImage("control.bmp",39);
dbLoadImage("author.bmp",40);
dbLoadImage("exitbutton.bmp",4);
dbLoadImage("play2.bmp",41);
dbLoadImage("controlm.bmp",44);
dbLoadImage("authorm.bmp",45);
dbLoadImage("control2.bmp",46);
dbLoadImage("author2.bmp",47);
dbLoadImage("exit2.bmp",48);
dbLoadImage("win1.bmp",42);
dbLoadImage("win2.bmp",49);
dbLoadImage("Pause_Game.bmp",60);
dbLoadImage("ball.bmp",1);
dbLoadImage("bat1.bmp",2);
dbLoadSound ("ball.wav",1);
dbLoadSound ("click.wav",2);
dbLoadSound ("blip.wav",3);
dbLoadSound ("beep.wav",4);
dbLoadSound ("goodbye.wav",5);
//dbLoadMusic ("01_david_guetta_ft._kid_cudi_-_memories.mp3",1);
//loads our images
dbLoadImage("scoreboard.bmp",43);
dbLoadImage("customizedpointer.bmp",6);
dbLoadImage("bordertop.bmp",10);
dbLoadImage("bordertop.bmp",13);
dbLoadImage("borderleft.bmp",14);
dbLoadImage("borderleft.bmp",15);
dbLoadImage ("pitch.bmp",7);//pitch
//////////////////////////////////////
dbLoadImage ("1.bmp",17);//1point
dbLoadImage ("2.bmp",18);//2point
dbLoadImage ("3.bmp",19);//3point
dbLoadImage ("4.bmp",20);//4point
dbLoadImage ("5.bmp",21);//5point
dbLoadImage ("6.bmp",22);//6point
dbLoadImage ("7.bmp",23);//7point
dbLoadImage ("8.bmp",24);//8point
dbLoadImage ("9.bmp",25);//9point
dbLoadImage ("10.bmp",26);//10point
//////////////////////////////////////
dbLoadImage ("1.bmp",27);//1point
dbLoadImage ("2.bmp",28);//2point
dbLoadImage ("3.bmp",29);//3point
dbLoadImage ("4.bmp",30);//4point
dbLoadImage ("5.bmp",31);//5point
dbLoadImage ("6.bmp",32);//6point
dbLoadImage ("7.bmp",33);//7point
dbLoadImage ("8.bmp",34);//8point
dbLoadImage ("9.bmp",35);//9point
dbLoadImage ("10.bmp",36);//10point
dbSprite(7,0,0,7);//pitch
dbSprite(2,15,220,2);
dbSprite(3,618,220,2);
dbSprite(14,0,0,14);//borderleft
dbSprite(15,640,0,15);//borderright
dbSprite(10,0,0,10);//bordertopup
dbSprite(13,0,480,13);//bordertopdown
dbSprite (43,255,5,43);//scoreboard
dbSprite(1,300,200,1);
//displays our images
dbSprite(4,0,420,3);
//dbSprite(5,400,420,4)
ballCord.x = 200;
ballCord.y = 300;
ballV.x = 3;
ballV.y = 3;
byte MaxPoints = 9;
bool isPaused = false;
int timer = dbTimer();
while ( LoopGDK ( ) )
{
dbCLS();
if (dbKeyState(25) && (dbTimer() > timer + 500)) {
timer = dbTimer();
if (!isPaused)
isPaused = true;
else
isPaused = false;
}
if (isPaused) {
dbSprite (60,160,110,60);//pause
} else {
dbHideSprite(60);//pause
switch (state){ case 0:
/////////////////////////////////////////////////////////////////////////////
player1.movement();
player2.movement();
if( acceleration > 0 )
if (acceleration < 0.1)
acceleration = 0;
else
if (acceleration < 0.2)
acceleration -=0.01;
else acceleration -= 0.1;
if(ballCord.x < 10 )
{
ballV.x *= -1 ;
dbPlaySound(1);
if(acceleration >= 1 )playerPoints2+= int(acceleration*1);else playerPoints2++;
if( playerPoints2 > MaxPoints )
{
dbPlaySound(1);
dbSprite (26+playerPoints2,331,49,playerPoints2+26);//1point,playerleft
} else
{
playerPoints2 = 0; playerPoints1 = 0;
ballCord.x = 200; ballCord.y = 200; dbSprite(1 ,ballCord.x , ballCord.y ,1);acceleration = 0;//acceleration
dbShowSprite(5);
dbShowSprite(37);
dbShowSprite(38);
dbShowSprite(39);
dbShowSprite(40);
dbSprite (49,60,360,49);//youwin2
///////////////////////////////////////////<-
state = 1;
for(int i = 17; i <=36 ; i++)
dbHideSprite(i);
}
// dbSprite (playerPoints2+26,331,49,playerPoints2+26);
}
if( ballCord.x > 619 )
{
ballV.x *= -1;
dbPlaySound(1);
if(acceleration >= 1 )playerPoints1+= int(acceleration*1);else playerPoints1++;
if( playerPoints1 > MaxPoints )
{ //if(ballyvelocity<10){ballxvelocity++; ballyvelocity++;}
dbPlaySound(1);
dbSprite (16+playerPoints1,281,49,playerPoints1+16);//1point,playerleft
} else
{
//dbSprite (16+playerPoints1,281,49,playerPoints1+17);//1point,playerleft
playerPoints1 = 0; playerPoints2 = 0; acceleration = 0;
ballCord.x = 200; ballCord.y = 200; dbSprite(1 ,ballCord.x , ballCord.y ,1);
dbShowSprite(5);
dbShowSprite(37);
dbShowSprite(38);
dbShowSprite(39);
dbShowSprite(40);
dbSprite (42,60,360,42);//youwin1 ///////////////////////////////////////////////////////////////<-
state = 1;
;
}
//1point,playerright
}
if ( ballCord.y <= 2 || ballCord.y > 459 )// 480 - ball width
ballV.y *= -1;
ballCord.x += ballV.x + int(ballV.x * acceleration);
ballCord.y += ballV.y + int(ballV.y * acceleration);
dbSprite(1 ,ballCord.x, ballCord.y ,1);
if ( (dbSpriteCollision(1,2)==1) || (dbSpriteCollision(1,3)==1) )
{
dbPlaySound(3);
ballV.x *= -1;
acceleration = 4+ rand()%3;
}
if ( (dbSpriteCollision(1,10)==1) || (dbSpriteCollision(1,13)==1) )
{
dbPlaySound(1);
}
if ( dbSpaceKey ( ) ==1 ) // shortcut menu
{
dbShowSprite(5);
dbShowSprite(37);
dbShowSprite(38);
dbShowSprite(39);
dbShowSprite(40);
state = 1; // menu
for(int i = 16; i <=36; i++)
dbHideSprite(i);
continue;
}
break; /////////////////////////////////////////////////////////////////////////
case 1: // change state
dbSprite(6,dbMouseX(),dbMouseY(),6);
dbHideSprite(6);
dbPlayMusic(1);
dbSprite (37,0,0,37);//menu
dbSprite (38,230,130,38);//play
dbSprite (39,230,190,39);//control
dbSprite (40,230,250,40);//author
dbSprite (5,230,310,4);//exit
//dbSprite (42,60,360,42);//youwin
if (dbSpriteCollision(6,38)==1 && dbMouseClick()==0)
dbSprite (41,230,130,41);//playOnMouseOver
if (dbSpriteCollision(6,38)==1 && dbMouseClick()==1)// play
{
state = 0;
dbPlaySound(2);
dbHideSprite(37); dbHideSprite(38);
dbHideSprite(39); dbHideSprite(5);
dbHideSprite(40); dbHideSprite(41);
dbHideSprite(46); dbHideSprite(47);
dbHideSprite(48);
}
dbSprite(6,dbMouseX(),dbMouseY(),6);
dbHideSprite(6);
if (dbSpriteCollision(6,5)==1 && dbMouseClick()==0)
{ dbPlaySound(5);
dbSprite (48,230,310,48);//playOnMouseOver
}
if (dbSpriteCollision(6,5)==1 && dbMouseClick()==1) //exit
{
dbPlaySound(2);
return;
}
dbSprite(6,dbMouseX(),dbMouseY(),6);
dbHideSprite(6);
if (dbSpriteCollision(6,39)==1 && dbMouseClick()==0)
dbSprite (46,230,190,46);//playOnMouseOver
if (dbSpriteCollision(6,39)==1 && dbMouseClick()==1) //control
{
dbPlaySound(2);
dbSprite(44,0,0,44);
}
dbSprite(6,dbMouseX(),dbMouseY(),6);
dbHideSprite(6);
if (dbSpriteCollision(6,40)==1 && dbMouseClick()==0)
dbSprite (47,230,250,47);//playOnMouseOver
if (dbSpriteCollision(6,40)==1 && dbMouseClick()==1) //author
{
dbPlaySound(2);
dbSprite(45,0,0,45);
}
if ( dbSpaceKey ( ) ==1 ) // shortcut menu
{
dbShowSprite(5);
dbShowSprite(37);
dbShowSprite(38);
dbShowSprite(39);
dbShowSprite(40);
state = 1; // menu
for(int i = 16; i <=36; i++)
dbHideSprite(i);
dbHideSprite(45);
dbHideSprite(44);
continue;
}
break;
}
}
dbSync ( );
}//end while
for ( int i = 1; i < 30; i++ )
{
dbDeleteSprite ( i );
dbDeleteImage ( i );
}
// return back to windows
return;
}