Hay im making my own version of Asteroids and for some reason the collision isnt working. its not returning true.
here is the code for the classes i made to contol the asteroids and bullets
Bullet Class
#include "DarkGDK.h"
class Bullet
{
private:
int BulletSpriteNumber;
int BulletImageNumber;
int BulletSpeed;
public:
Bullet(char BulletImgName[] ,int BulletImageNum, int BulletSpriteNum);
Bullet();
~Bullet(void);
void Fire (int BulletSpd, int StartX, int StartY, float Angle);
void Scale(int ScaleRate);
void Delete ( int SpriteN);
void Sprite();
bool BulletHit(int HitId);
void Hide(int SpriteId);
void Show();
void Update ();
void SetUpBullet( char BulletImgName [], int BulletImageNum, int BulletSpriteNum);
};
Bullet::Bullet()
{
}
Bullet::Bullet(char BulletImgName[], int BulletImageNum,int BulletSpriteNum)
{
BulletSpriteNumber = BulletSpriteNum;
BulletImageNumber = BulletImageNum;
dbLoadImage(BulletImgName,BulletImageNum);
}
Bullet::~Bullet()
{
}
void Bullet::SetUpBullet(char BulletImgName [], int BulletImageNum, int BulletSpriteNum)
{
BulletSpriteNumber = BulletSpriteNum;
BulletImageNumber = BulletImageNum;
dbLoadImage(BulletImgName,BulletImageNum);
}
void Bullet::Fire(int BulletSpd,int StartX,int StartY, float Angle)
{
BulletSpeed = BulletSpd;
dbSprite(BulletImageNumber,StartX,StartY,BulletSpriteNumber);
dbRotateSprite(BulletSpriteNumber,Angle);
}
void Bullet::Scale(int ScaleRate)
{
dbScaleSprite(BulletSpriteNumber,ScaleRate);
}
void Bullet::Delete(int SpriteN)
{
dbDeleteSprite(SpriteN);
}
void Bullet::Sprite()
{
dbSprite(BulletSpriteNumber,0,0,BulletImageNumber);
dbHideSprite(BulletImageNumber);
}
bool Bullet::BulletHit(int HitId)
{
bool Hit;
Hit = dbSpriteCollision(BulletSpriteNumber,HitId);
return Hit;
}
void Bullet::Hide(int SpriteId)
{
dbHideSprite(SpriteId);
}
void Bullet::Show()
{
dbShowSprite(BulletSpriteNumber);
}
void Bullet::Update()
{
dbMoveSprite(BulletSpriteNumber,BulletSpeed);
}
Asteroid Class
#include "DarkGDK.h"
class Asteroid
{
private:
int AsteroidImageNumber;
int AsteroidSpriteNumber;
int CurrX;
int CurrY;
public:
Asteroid();
Asteroid(char ImageName[], int ImageNumber, int SpriteNumber);
~Asteroid();
void SetUpAsteroid( char ImageName[], int ImageNumber, int SpriteNumber);
void Sprite();
void Show();
void Hide();
void Scale(int Amount);
void Bounce();
void Update();
void SetX(int NewX);
void SetY(int NewY);
int AsteroidX();
int AsteroidY();
int GetSpriteNumber();
bool Hit(int HitId);
};
Asteroid::Asteroid()
{
}
Asteroid::Asteroid(char ImageName[], int ImageNumber, int SpriteNumber)
{
AsteroidImageNumber = ImageNumber;
AsteroidSpriteNumber = SpriteNumber;
dbLoadImage(ImageName,ImageNumber);
}
Asteroid::~Asteroid()
{
}
void Asteroid::SetUpAsteroid(char ImageName[], int ImageNumber, int SpriteNumber)
{
AsteroidImageNumber = ImageNumber;
AsteroidSpriteNumber = SpriteNumber;
dbLoadImage(ImageName,ImageNumber);
}
void Asteroid::Sprite()
{
CurrX = 50;
CurrY = 50;
dbSprite(AsteroidSpriteNumber,CurrX,CurrY,AsteroidImageNumber);
dbOffsetSprite(AsteroidSpriteNumber,dbSpriteHeight(AsteroidSpriteNumber) / 2,
dbSpriteWidth(AsteroidSpriteNumber) / 2);
dbHideSprite(AsteroidSpriteNumber);
}
void Asteroid::Hide()
{
dbHideSprite(AsteroidSpriteNumber);
}
void Asteroid::Show()
{
dbShowSprite(AsteroidSpriteNumber);
}
void Asteroid::Scale(int Amount)
{
dbScaleSprite(AsteroidSpriteNumber,Amount);
}
void Asteroid::Update()
{
dbMoveSprite(AsteroidSpriteNumber,2);
CurrX = dbSpriteX(AsteroidSpriteNumber);
CurrY = dbSpriteY(AsteroidSpriteNumber);
}
int Asteroid::AsteroidX()
{
CurrX = dbSpriteX(AsteroidSpriteNumber);
return CurrX;
}
int Asteroid::AsteroidY()
{
CurrY = dbSpriteY(AsteroidSpriteNumber);
return CurrY;
}
void Asteroid::Bounce()
{
dbRotateSprite(AsteroidSpriteNumber,dbRND(180));
}
void Asteroid::SetX(int NewX)
{
CurrX = NewX;
dbSprite(AsteroidSpriteNumber,CurrX,CurrY,AsteroidImageNumber);
}
void Asteroid::SetY(int NewY)
{
CurrY = NewY;
dbSprite(AsteroidSpriteNumber,CurrX,CurrY,AsteroidImageNumber);
}
int Asteroid::GetSpriteNumber()
{
return AsteroidSpriteNumber;
}
bool Asteroid::Hit(int HitId)
{
bool Hit;
Hit = dbSpriteCollision(AsteroidSpriteNumber,HitId);
return Hit;
}
I even tryed to check for a collision not even using the classes so please tell me what im doing wrong
thanks for any help
All is revealed with time.