class BoundingBox
{
public:
BoundingBox();
~BoundingBox();
void setX(float value);
float getX();
void incrementX(float value);
void setY(float value);
float getY();
void incrementY(float value);
void setWidth(int value);
int getWidth();
void incrementWidth(int value);
void setHeight(int value);
int getHeight();
void incrementHeight(int value);
float getLeftX();
float getRightX();
float getTopY();
float getBottomY();
float getTextureLeftX();
float getTextureRightX();
float getTextureTopY();
float getTextureBottomY();
void setOffsets(float left, float right, float top, float bottom);
void setTopOffset(float top);
float getTopOffset();
void setBottomOffset(float bottom);
float getBottomOffset();
void setLeftOffset(float left);
float getLeftOffset();
void setRightOffset(float right);
float getRightOffset();
private:
float x, y, leftOffset, rightOffset, topOffset, bottomOffset;
int width, height;
};
Now I have created an engine library which checks for collisions, but I can't use my BoundingBox object no matter what I do, this is what my Engine header and class look like:
My header
#include "BoundingBox.h" extern bool Collision(BoundingBox *box1, BoundingBox *box2); extern bool Collision(BoundingBox &box1, BoundingBox &box2);
My cpp file
#include "Engine.h"
#include "BoundingBox.h"
bool Collision(BoundingBox *box1, BoundingBox *box2)
{
if(box1->getLeftX() <= box2->getRightX() && box1->getRightX() >= box2->getLeftX())
{
if(box1->getTopY() <= box2->getBottomY() && box1->getBottomY() >= box2->getTopY())
{
return true;
}
}
return false;
}
bool Collision(BoundingBox &box1, BoundingBox &box2)
{
if(box1.getLeftX() <= box2.getRightX() && box1.getRightX() >= box2.getLeftX())
{
if(box1.getTopY() <= box2.getBottomY() && box1.getBottomY() >= box2.getTopY())
{
return true;
}
}
return false;
}
I have tried searching everywhere, but I can not find the reason why this issue occurs. I am using Visual C++ 2010 express if it is of any help. Thank you very much again for all your help in advance, I am quiet lost and been stuck on this for two days now.


Sign In
Create Account

Back to top









