mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-13 09:02:10 +00:00
Changed collision
This commit is contained in:
parent
4546c8e2a2
commit
735a20c224
@ -129,17 +129,17 @@ boost::any EditClassSubComponent(boost::any value, string oper, boost::any other
|
|||||||
return nullType;
|
return nullType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AxisAlignedCollision(const Sprite& a, const Sprite& b)
|
bool AxisAlignedCollision(const Sprite& a, const Sprite& b) // AABB - AABB collision
|
||||||
{
|
{
|
||||||
bool colX = false;
|
// collision x-axis?
|
||||||
if ((a.position.x + (a.scale.x / 2) <= b.position.x + (b.scale.x / 2)) && (a.position.x - (a.scale.x / 2) >= b.position.x - (b.scale.x / 2)))
|
bool collisionX = a.position.x + a.scale.x >= b.position.x &&
|
||||||
colX = true;
|
b.position.x + b.scale.x >= a.position.x;
|
||||||
bool colY = false;
|
// collision y-axis?
|
||||||
if ((a.position.y + (a.scale.y / 2) <= b.position.y + (b.scale.y / 2)) && (a.position.y - (a.scale.y / 2) >= b.position.y - (b.scale.y / 2)))
|
bool collisionY = a.position.y + a.scale.y >= b.position.y &&
|
||||||
colY = true;
|
b.position.y + b.scale.y >= b.position.y;
|
||||||
|
// collision only if on both axes
|
||||||
return colX && colY;
|
return collisionX && collisionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial script processing, which loads variables and functions from builtin
|
// Initial script processing, which loads variables and functions from builtin
|
||||||
int GetBuiltins(const string& s)
|
int GetBuiltins(const string& s)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user