-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHitBox.h
More file actions
103 lines (96 loc) · 3.4 KB
/
HitBox.h
File metadata and controls
103 lines (96 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Authors: Christine Seng, Erick Martinez, Georgia Rushing, Graham Balas, Nolan Schirripa
* Assignment Title: Group Project (HitBox.h)
* Assignment Description: declares 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
*/
#ifndef hitbox_h
#define hitbox_h
#include "SDL_Plotter.h"
#include <cmath>
class HitBox{
private:
point location;
int length;
int width;
public:
//CONSTRUCTORS
HitBox(){
location.x = 0;
location.y = 0;
length = 0;
width = 0;
}
HitBox(point loc, int l = 0, int w = 0){
location = loc;
length = l;
width = w;
}
//SETTER METHODS
//************************************************************
// description: sets hitbox point to point parameter
// return: void
// pre: loc is a valid point on the screen
// post: hitbox point changed to point parameter
//************************************************************
void setPoint(point loc){
location = loc;
}
//************************************************************
// description: sets hitbox length to int l
// return: void
// pre: l is non-negative int
// post: hitbox length changed to parameter
//************************************************************
void setLength(int l){
length = l;
}
//************************************************************
// description: sets hitbox width to int w
// return: void
// pre: w is non-negative int
// post: hitbox width changed to parameter
//************************************************************
void setWidth(int w){
width = w;
}
//GETTER METHODS
//************************************************************
// description: returns hitbox point
// return: point
// pre: location initialized
// post: hitbox remains unchanged
//************************************************************
point getPoint()const{
return location;
}
//************************************************************
// description: returns hitbox length
// return: int
// pre: length initialized
// post: hitbox remains unchanged
//************************************************************
int getLength()const{
return length;
}
//************************************************************
// description: returns hitbox width
// return: int
// pre: width initialized
// post: hitbox remains unchanged
//************************************************************
int getWidth()const{
return width;
}
//METHODS
//************************************************************
// description: returns bool if two hitbox parameters are hit
// return: bool
// pre: both hitboxes initialized
// post: hitboxex remains unchanged
//************************************************************
static bool isHit(HitBox h1, HitBox h2);
};
#endif