Alright...
im trying to learn C++ and implement collision detection into my game. im learning c++ so please be easy on me.
what i have is an Object Class
[SOURCE]
class Object
{
protected:
int x, y;
int direction,speed;
int graphicwidth;
int graphicheight;
int height, width;
int solid;
SDL_Surface *graphic;
public:
Object();
~Object();
void step();
void draw();
void setGraphicHeight(int tempHeigt);
void setGraphicWidth(int tempWidth);
int getGraphicHeight();
int getGraphicWidth();
void setSolid(int tempSolid);
void setX(int tempX);
void setY(int tempY);
int getX();
int getY();
void setGraphic(SDL_Surface *graphic);
};
[/SOURCE]
and I set up an inheritence for it for another object. to handle the input
[SOURCE]
class Blocks : public Object {
public:
void input();
};
[/SOURCE]
but when I try to call my collison code by...
[SOURCE]
//collision detection
int obj_collision(Object *object1, Object *object2)
{
int obj_top1, obj_top2;
int obj_bot1, obj_bot2;
int obj_rigt1, obj_rigt2;
int obj_left1, obj_left2;
obj_left1 = object1->getX();
obj_left2 = object2->getX();
obj_top1 = object1->getY();
obj_top2 = object2->getY();
obj_rigt1 = object1->getX() + object1->getGraphicWidth();
obj_rigt2 = object2->getX() + object2->getGraphicWidth();
obj_bot1 = object1->getY() + object1->getGraphicHeight();
obj_bot2 = object2->getY() + object2->getGraphicHeight();
return 0;
}
[/SOURCE]
but it doesnt work...what did i do wrong?
lol again please be easy on me im learning.