-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHitBox.cpp
More file actions
20 lines (18 loc) · 733 Bytes
/
HitBox.cpp
File metadata and controls
20 lines (18 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
* Authors: Christine Seng, Erick Martinez, Georgia Rushing, Graham Balas, Nolan Schirripa
* Assignment Title: Group Project (HitBox.cpp)
* Assignment Description: defines HitBox class that makes an invisible box around a block and detects collisions
* Due Date: 12/09/2024
* Date Created: 10/25/2024
* Date Last Modified: 12/07/2024
*/
#include "HitBox.h"
bool HitBox::isHit(HitBox h1, HitBox h2){
bool result;
int xDist = fabs(h1.getPoint().x - h2.getPoint().x);
int yDist = fabs(h1.getPoint().y - h2.getPoint().y);
int xBoundary = h1.getLength() / 2 + h2.getLength() / 2;
int yBoundary = h1.getWidth() / 2 + h2.getWidth() / 2;
result = (xDist < xBoundary) && (yDist < yBoundary);
return result;
}