Hey iv'e just goten GDK and have been playing around with it and visual C++ for a while now. Anyway I decided to make a simple pong game and everything seems to work ok.
The only problem is I keep getting this compilation error. There appears to be no reason for it appearing and if i attempt to compile again it will dissapear and run just fine. However it is getting annoying as it tends to occur quite frequently when I compile and I dont like to have any errors in my game.
Anway I am quite new to everything and am not sure entirely what is going on. I would like to fix whatever is causing this error but it is quite confusing as sometimes it is there and sometimes it is not, even though I have not touched the code in anyway. I have tried unsuccesfully to isolate what code is causing the error.
Which leads me to believe something else is causing the error"
#include "darkSDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
/// Set the window size
dbSetDisplayMode ( 800, 600, 0) ;
int ballx=128; // ball x pos
int bally=64; // ball y pos
int ballxspeed=-4; // ball speed
int ballyspeed=4;
int ballwidth=32; // the width of the ball, also used for height, as it is square
int paddlewidth=32; /// the width of each paddle
int paddleheight=96; /// the height of each paddle
int PaddleSpeed=5; // speed with which the paddle moves
int aX1=8, aX2=700, aY1=8, aY2=500; // set the boundary for the ball, i.e the play area,
// also used for ball collision checks and initial paddle placement
int Player1Score=0; // Set the player scores to 0
int Player2Score=0;
class Paddles /// creat a class called paddles, this will be for paddle1, paddle2 instances
{
public:
int xpos; /// this will store the current x position for each paddle
int ypos; /// this will store the current y position for each paddle
};
Paddles paddle1; /// declare to new instances paddle1, paddle2 of class paddle ///
paddle1.xpos = 32; /// then set there corresponding xpos and ypos
paddle1.ypos = 128;
Paddles paddle2;
paddle2.xpos = 128;
paddle2.ypos = 128;
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbCLS( dbRGB(35,35,250) ); /// clear the background with a given color defined by dbRGB
/// Load paddle sprite
dbCreateAnimatedSprite( 1, "PongPaddle.png", 1,1,1);
dbSprite( 1, paddle1.xpos, paddle1.ypos, 1 );
// load ball sprite
dbCreateAnimatedSprite( 2, "PongBall.png", 1,1,2);
dbSetSprite ( 2, 1, 1 );
dbSprite( 2, ballx, bally, 2 );
dbCenterText ( 152, 32, "PONG" ) ; // draw the game title
// our main loop
while ( LoopGDK ( ) )
{
/// Set the ink colour and draw a box of the play area with the ink color
dbInk ( 0,0 ); // set the ink colour to black
dbBox ( aX1, aY1, aX2, aY2 ) ; // draw a box in the ink color of the play area
if ( ballxspeed < 0 ) // if ball is travelling to the left
{
if ( ballx> aX1 ) // if ball x position is greater then left play area, ie not past the left hand wall
{
if ( ballx==(paddle1.xpos+32) && (bally+ballwidth)>=(paddle1.ypos) && bally<=(paddle1.ypos+paddleheight) ) // if in contact with player1 paddle
{ ballxspeed = -ballxspeed; } /// then reverse the balls x direction
else
{ ballx+=ballxspeed; } // otherwise allow the ball to continue moving in the - x direction
}
else { ballx = 128; Player2Score+=1; } // if it ball is past left hand wall, then the player has
// missed the ball and the other player scores a point
}
if ( ballxspeed > 0 )
{
if ( (ballx+ballwidth)<aX2 ) { ballx+=ballxspeed; } // if not on right edge of screen
else { ballxspeed = -ballxspeed; } // if on right edge of screen reverse x direction
}
if ( ballyspeed < 0 ) // if ball is moving upwards
{
if ( (bally)>aY1 ) { bally+=ballyspeed; } // if not on top edge of screen continue moving
else { ballyspeed = -ballyspeed; } // if on top edge of screen reverse y direction
}
if ( ballyspeed > 0 ) // if ball is moving downwards
{
if ( (bally+ballwidth)<aY2 ) { bally+=ballyspeed; } // if not on bottom edge of screen
else { ballyspeed = -ballyspeed; } // if on bottom edge of screen reverse y direction
}
// check if paddle mpvement keys are being pressed if so update there y co-ords
if ( dbUpKey() && paddle1.ypos > aY1 ) { paddle1.ypos -= PaddleSpeed; }
if ( dbDownKey() && (paddle1.ypos+paddleheight+1) < aY2 ) { paddle1.ypos += PaddleSpeed; }
dbSprite( 1, paddle1.xpos, paddle1.ypos, 1 ); // draw the new position of the paddles
dbSprite( 2, ballx, bally, 2 );
dbSync ( ); // Update the screen
}
// return back to windows
return;
}
The compile log below says error result 31 returned. Is there anyway to determine what exactly this error is?
1>------ Build started: Project: Pong, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>Linking...
1>LINK : Debug\Pong.exe not found or not built by the last incremental link; performing full link
1>Embedding manifest...
1>Project : error PRJ0002 : Error result 31 returned from 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe'.
1>Build log was saved at "file://c:\Users\0ther\Documents\Visual Studio 2008\C++ Projects\Pong\Pong\Debug\BuildLog.htm"
1>Pong - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========