ok Scottie Dog i done what u said but now i get these error messages
Initialise.obj : error LNK2001: unresolved external symbol "int b" (?b@@3HA)
Input.obj : error LNK2019: unresolved external symbol "int b" (?b@@3HA) referenced in function "void __cdecl _ProcessInput(void)" (?_ProcessInput@@YAXXZ)
initiate.obj : error LNK2001: unresolved external symbol "int b" (?b@@3HA)
Initialise.obj : error LNK2001: unresolved external symbol "int XCord" (?XCord@@3HA)
Input.obj : error LNK2019: unresolved external symbol "int XCord" (?XCord@@3HA) referenced in function "void __cdecl _ProcessInput(void)" (?_ProcessInput@@YAXXZ)
Initialise.obj : error LNK2001: unresolved external symbol "int YCord" (?YCord@@3HA)
Input.obj : error LNK2001: unresolved external symbol "int YCord" (?YCord@@3HA)
Initialise.obj : error LNK2001: unresolved external symbol "int g" (?g@@3HA)
Input.obj : error LNK2019: unresolved external symbol "int g" (?g@@3HA) referenced in function "void __cdecl _ProcessInput(void)" (?_ProcessInput@@YAXXZ)
Input.obj : error LNK2001: unresolved external symbol "int AC" (?AC@@3HA)
initiate.obj : error LNK2019: unresolved external symbol "int AC" (?AC@@3HA) referenced in function "void __cdecl _Initiate(void)" (?_Initiate@@YAXXZ)
initiate.obj : error LNK2001: unresolved external symbol "int score" (?score@@3HA)
Debug\DeepSpace.exe : fatal error LNK1120: 6 unresolved externals
My code is as follows
main.cpp
#include "DarkGDK.h"
#include "Main.h"
void DarkGDK ( void )
{
char score;
int b = 51;
int g = 2;
int XCord=450;
int YCord=460;
int AC = 50;
_Initialise();
while ( LoopGDK ())
{
_ProcessInput(); // Get current state of keys/mouse
_Initiate();
dbSync();
_CloseDown();
return;
}
}
Main.h
void _Initialise(void);
void _ProcessInput(void);
void _Initiate(void);
void _CloseDown(void);
extern int g;
extern int XCord;
extern int YCord;
extern int b;
extern int AC;
extern int score;
Input.cpp
#include "DarkGDK.h"
#include "Main.h"
void _ProcessInput(void)
{
if( dbSpaceKey())
{
if(AC == 50)
{
dbSprite(b, (XCord + 60), YCord, b);
AC = 1;
dbPlaySound(5);
}
}
if(AC < 50)//If the projectile is active,
{
dbMoveSprite(b, 16.4);//then make it move
AC++;
}
if( AC > 50)
{
dbSprite(b, (XCord + 60), YCord, b);
AC = 1;
dbPlaySound(5);
}
if(AC < 50)//If the projectile is active,
{
dbMoveSprite(b, 16.4);//then make it move
AC++;
}
if(dbDownKey())//move down
{
YCord++;
YCord++;
YCord++;
YCord++;
YCord++;
}
if(dbUpKey())//move up
{
YCord=YCord-5;
}
if(dbRightKey())//move right
{
XCord++;
XCord++;
XCord++;
XCord++;
XCord++;
}
if(dbLeftKey())//move left
{
XCord=XCord-5;
}
dbSprite(g, XCord, YCord, g);//Set The Cordinates To XCord And YCord
{if (XCord > dbScreenWidth())
XCord = 0;
if (XCord < 0)
XCord = dbScreenWidth();
if (YCord > dbScreenHeight())
YCord = 0;
if (YCord < 0)
YCord = dbScreenHeight();
}
}
initiate.cpp
#include "DarkGDK.h"
#include "Main.h"
void _Initiate(void)
//asteroid, missile and ship collision detection
{
for ( int i = 3; i < 30; i++ )
{
// move the sprite down and play its animation
// moving from frame 1 to 16 with a delay of 60 ms
dbMoveSprite ( i, -2 );
dbPlaySprite ( i, 1, 16, 60 );
// check the position of the sprite, if it has gone off scren
// then reposition it back to the top
if ( dbSpriteY ( i ) > 768 )
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
if(AC < 50)
{
if (dbSpriteHit(b, i)==true)
{
score = score + 1;
MessageBox ( NULL , "Game over you won \nThanks for playing" , "Game over" , MB_OK );
//dbWaitKey ( );
}
}
}
}
Initialise.cpp
#include "DarkGDK.h"
#include "Main.h"
void _Initialise(void)
{
dbText ( 180 , 200, "Welcome To DEEPSCPACE");
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSyncOn ( );
dbSyncRate ( 60 );
dbDisableEscapeKey ( );
dbRandomize ( dbTimer ( ) );
dbMaximiseWindow();
dbLoadSound ( "shoot.wav", 5);
dbLoadMusic ( "background music.mp3", 4 );
dbSetDisplayMode ( 1024 , 768 , 32 );
dbLoadImage ( "background.jpg", 1 );
dbSprite ( 1, 0, 0, 1 );
for ( int i = 3; i < 30; i++ )
{
dbCreateAnimatedSprite ( i, "sprite.png", 4, 4, i );
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
dbLoadImage("spaceship.png", g);
dbSprite(g, XCord, YCord, g);//this will display the object
dbPlayMusic(4);
dbLoopMusic(4);
dbLoadImage ("bolt.png", b);
}
Close Down.cpp
#include "DarkGDK.h"
#include "Main.h"
void _CloseDown(void)
{
if ( dbEscapeKey ( ) )
dbSync ( );
for ( int i = 1; i < 30; i++ )
dbDeleteSprite ( i );
dbDeleteImage ( 1 );
}
any help as to why i get these error messages would be greatly appreciated lol hopefully the code is also a little easier to read thanks to theintervention of
Scottie Dog