Alright. So here's an annoying error I've been trying to fix. Basically, I'm creating a simple 2D engine. I've been working it on it for an hour or two, but I've hit an error I just can't seem to get rid of. So first, here's the code:
/////////////////////////////////////////////////////////////////////////////////// Importing Stuff
#include "DarkGDK.h"
using namespace std;
/////////////////////////////////////////////////////////////////////////////////// Forwarded Variables
void CollisionMovements(int id,int sID);
void Movements(void);
int Gravity(int id, int sID, int tc);
bool CheckCollision(int id, int sID);
/////////////////////////////////////////////////////////////////////////////////// Global Variables
extern int currentVelocity = 0;
extern bool jumping = true;
extern int spriteX = 0;
extern int spriteY = 0;
/////////////////////////////////////////////////////////////////////////////////// Main
void DarkGDK ( void )
{
/////////////////////////////////////////////////////////////////////////////////// Setup
dbSetImageColorKey(255,0,255);
dbSyncOn();
dbSyncRate(60);
dbDisableEscapeKey();
dbRandomize(dbTimer());
dbLoadImage("box.bmp",1);
dbSprite(1, 0, 0, 1);
dbSprite(2, 0, 450, 1);
char level[256][30];
int currentLevel = 1;
int timeCheck = 0;
/////////////////////////////////////////////////////////////////////////////////// Main
while(LoopGDK())
{
/////////////////////////////////////////////////////////////////////////////////// Quit
if ( dbEscapeKey())
{
break;
}
/////////////////////////////////////////////////////////////////////////////////// Variables
spriteX = dbSpriteX(1);
spriteY = dbSpriteY(1);
/////////////////////////////////////////////////////////////////////////////////// Collisions
CollisionMovements(1,1);
/////////////////////////////////////////////////////////////////////////////////// Movement
Movements();
/////////////////////////////////////////////////////////////////////////////////// Gravity Stuff
currentVelocity = Gravity(1,1,timeCheck);
if (timeCheck == 6)
{
timeCheck = 0;
}
else
{
timeCheck++;
}
/////////////////////////////////////////////////////////////////////////////////// Updates the Position
dbSprite(1,spriteX,spriteY,1);
dbSync();
}
/////////////////////////////////////////////////////////////////////////////////// Clean Up At Exit
for (int i = 0; i < 2; i++)
{
dbDeleteSprite(i);
}
for (int i = 0; i < 1; i++)
{
dbDeleteImage(i);
}
/////////////////////////////////////////////////////////////////////////////////// Exit
return;
}
void CollisionMovements(int mainSprite,int imageID)
{
/////////////////////////////////////////////////////////////////////////////////// Variables
int spriteSecondID = dbSpriteCollision(mainSprite,0);
int spriteSecondX = dbSpriteX(spriteSecondID);
int spriteSecondY = dbSpriteY(spriteSecondID);
/////////////////////////////////////////////////////////////////////////////////// Checks for the Collisions
if (dbSpriteCollision(1,spriteSecondID) == 1)
{
if (spriteY < spriteSecondY)
{
spriteY = spriteSecondY - 32;
jumping = false;
currentVelocity = 0;
}
if (spriteY > spriteSecondY)
{
spriteY = spriteSecondY + 32;
jumping = false;
currentVelocity = 0;
}
}
}
bool CheckCollisions(int mainSprite,int imageID)
{
int spriteSecondID = dbSpriteCollision(mainSprite,0);
int spriteSecondX = dbSpriteX(spriteSecondID);
int spriteSecondY = dbSpriteY(spriteSecondID);
if (dbSpriteCollision(1,spriteSecondID) == 1)
{
return true;
}
else
{
return false;
}
}
int Gravity(int mainSprite, int imageID, int timeCheck)
{
if (timeCheck == 6)
{
currentVelocity++;
}
if (CheckCollision(1,1) == false)
{
spriteY = spriteY + currentVelocity;
}
return currentVelocity;
}
void Movements(void)
{
/////////////////////////////////////////////////////////////////////////////////// W
if (jumping == false)
{
if (dbKeyState(17) == 1)
{
currentVelocity = -4;
jumping = true;
}
}
/////////////////////////////////////////////////////////////////////////////////// A
if (dbKeyState(30) == 1)
{
spriteX = spriteX - 5;
}
/////////////////////////////////////////////////////////////////////////////////// D
if (dbKeyState(32) == 1)
{
spriteX = spriteX + 5;
}
}
Sorry about my commenting, it's only semi-commented. (Enough for me to understand everything.) If you need help understanding anything, just ask away. Now, back to the error. Every time I compile the code, I get the following error:
error LNK2019: unresolved external symbol "bool __cdecl CheckCollision(int,int)" (?CheckCollision@@YA_NHH@Z) referenced in function "int __cdecl Gravity(int,int,int)" (?Gravity@@YAHHHH@Z)
What exactly is it telling me? I've got all the functions declared, so it shouldn't have any issues finding the functions. So how exactly do I fix this?
Thanks!