Note that this does exactly the same thing as a wireframe or the other actors. its just a different way of doing it. Make of it what you will
- Code: Select all
int BoxCollide(float ActX, float ActY, int ULX, int ULY, int LRX, int LRY){
int tmp = 0;
if((ActX > ULX) && (ActX < LRX) && (ActY > ULY) && (ActY < LRY))
{tmp = 1; }
return tmp;
};
float ActX and float ActY are the actor x and y. ULX and ULY are x and y coordinates for an invisible box(the upper left corner) LRX and LRY are the lower right corner values. tmp is a temp value to store a return number that indicates true or false.
What it does is check that player x is more than ULX, and less than LRX. then it checks the same with y values. if any is false, then the function returns zero. Otherwise, it returns 1, which means the actor is inside the invisible box.
use it like this:
- Code: Select all
if (BoxCollide(player.x, player.y, -50, -50, 50, 50) == 1)
{
do something here;
}