-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameObject.cpp
77 lines (55 loc) · 1.25 KB
/
GameObject.cpp
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
#include "GameObject.h"
GameObject::GameObject(void)
{
x = 0;
y = 0;
velX = 0;
velY = 0;
angle = 0;
dirX = 0;
dirY = 0;
boundX = 0;
boundY = 0;
alive = true;
collidable = true;
}
void GameObject::Destroy(){
}
void GameObject::Init(float x, float y, float velX, float velY, int dirX, int dirY, float angle, int boundX, int boundY){
GameObject::x = x;
GameObject::y = y;
GameObject::velY = velY;
GameObject::velX = velX;
GameObject::angle = angle;
GameObject::dirX = dirX;
GameObject::dirY = dirY;
GameObject::boundX = boundX;
GameObject::boundY = boundY;
}
void GameObject::Update(GameObject *otherObject){
//change where they're looking
//determine where they should be after one frame...
x += velX * dirX;
y += velY * dirY;
}
void GameObject::Render(){
}
bool GameObject::CheckCollisions(GameObject *otherObject){
float oX = otherObject->GetX();
float oY = otherObject->GetY();
int obX = otherObject->GetBoundX();
int obY = otherObject->GetBoundY();
if( x + boundX > oX &&
x - boundX < oX + obX &&
y + boundY > oY &&
//y < oY + obY){
y - boundY < oY + obY){
return true;
}
else
return false;
}
void GameObject::Collided(GameObject *otherObject){}
bool GameObject::Collidable(){
return alive && collidable;
}