coll

  • タグ:
  • タグはありません
// 座標
struct Point
{
	int x;
	int y;
	Point(int x_, int y_) : x(x_), y(y_) {};
};

// 当たり判定
struct HitBox
{
	Point pos;
	Point size;
};

// aとbが接触しているか
bool isHit(HitBox a, HitBox b)
{
	if (a.pos.x < b.pos.x + b.size.x &&
	    b.pos.x < a.pos.x + a.size.x &&
	    a.pos.y < b.pos.y + b.size.y &&
	    b.pos.y < a.pos.y + a.size.y)
	{
		return true;
	}
	return false;
}