summaryrefslogtreecommitdiff
path: root/src/gameobject.cpp
diff options
context:
space:
mode:
authorNikolas <nikolas@boutalas.com>2024-10-27 12:52:55 +0200
committerNikolas <nikolas@boutalas.com>2024-10-27 12:52:55 +0200
commit43394c8a8908442982e3a7e25975c31b3c952923 (patch)
tree2facd563e29f48fe3b0653ac5c113998940b4d5e /src/gameobject.cpp
Diffstat (limited to 'src/gameobject.cpp')
-rw-r--r--src/gameobject.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/gameobject.cpp b/src/gameobject.cpp
new file mode 100644
index 0000000..c217722
--- /dev/null
+++ b/src/gameobject.cpp
@@ -0,0 +1,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;
+} \ No newline at end of file