Hi. I'm trying to finish my AABB class, but I'm having some issues getting the two objects to actually collide. As it is at the moment I have a player (25x25 little blue block). He is moving down the screen using Euler Integration. When the player hits the block, the collision is meant to return true and the console print out "Collision". Unfortunately it doesn't.
This is my collision.h header.
#ifndef collision_H
#define collision_H
#include "moveable.h"
#include <SFML\Graphics.hpp>
class collision : public moveable
{
protected:
vector2D min;
vector2D max;
public:
collision(); //<! Default Constructor
bool AABB(collision & other);
bool collide;
};
#endif
My cpp:
#include "collision.h"
#include <iostream>
collision::collision()
{
}
bool collision::AABB(collision & other)
{
if(max.x < other.min.x || min.y > other.max.y)std::cout<<"No Collision\n";return false;
if(max.y < other.min.y || min.y > other.max.y)std::cout<<"No Collision\n";return false;
std::cout<<"Collision";return true;
}
I call it in my game.cpp with
void game::collision()
{
p.AABB(l);
}
I'm quite sure that my syntax in my game.cpp is incorrect.
In each player and level cpp I am setting the min.x and max.y to the playertexture.getSize().x/y.
Any ideas?