blob: c2177226f281d63a603054a78980acb18113f0a5 (
plain)
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
|
#include "config.h"
#include "graphics.h"
#include "gameobject.h"
#include <string>
using namespace std;
GameObject::GameObject(float pos_x, float pos_y, float size_x, float size_y, float orientation, string texture){
this -> pos_x = pos_x;
this -> pos_y = pos_y;
this -> size_x = size_x;
this -> size_y = size_y;
this -> orientation = orientation;
this -> texture = texture;
terminate = false;
}
GameObject::~GameObject(){
}
void GameObject::update(){
if((pos_x < 0 - WINDOW_WIDTH) || (pos_x > WINDOW_WIDTH*2) || (pos_y < 0 - WINDOW_HEIGHT) || (pos_y > WINDOW_HEIGHT*2)) terminate = true;
}
void GameObject::draw(){
graphics::Brush br;
br.outline_opacity = 0.0f;
br.texture = string(ASSET_PATH) + texture + ".png";
graphics::setOrientation(orientation);
graphics::drawRect(pos_x, pos_y, size_x, size_y, br);
graphics::resetPose();
}
float GameObject::getPosX(){
return pos_x;
}
float GameObject::getPosY(){
return pos_y;
}
float GameObject::getSizeX(){
return size_x;
}
float GameObject::getSizeY(){
return size_y;
}
float GameObject::getOrientation(){
return orientation;
}
float GameObject::getRadius(){
return (size_y + size_x)/4;
}
bool GameObject::getTerminate(){
return terminate;
}
string GameObject::getTexture(){
return texture;
}
void GameObject::setPosX(float pos_x){
this -> pos_x = pos_x;
}
void GameObject::setPosY(float pos_y){
this -> pos_y = pos_y;
}
void GameObject::setTerminate(bool terminate){
this -> terminate = terminate;
}
bool GameObject::collidable(){
return true;
}
|