summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelik Houij <houijmelik08@protonmail.com>2022-09-20 18:55:12 +0200
committerMelik Houij <houijmelik08@protonmail.com>2022-09-20 18:55:12 +0200
commit16e51967022e48da790dac4c2168324f352d5669 (patch)
tree8fe9bf5893645007cc165e3d56ad1a2583e5194c
parent8793b704734677d548239b4cbb62b1ac0d644d41 (diff)
broken: virtual function
-rw-r--r--gobject.h74
-rw-r--r--scene.h3
2 files changed, 72 insertions, 5 deletions
diff --git a/gobject.h b/gobject.h
index 260bc41..e914498 100644
--- a/gobject.h
+++ b/gobject.h
@@ -64,6 +64,29 @@ uint16_t timeHeld = 0; // time held
}
};
+struct hitbox{
+ float y, x, width, height;
+ hitbox(float Y, float X, float Width,float Height)
+ {
+ y = Y;
+ x = X;
+ width = Width;
+ height = Height;
+ }
+
+ bool check(const hitbox &oppos)
+ {
+ if(this->x < oppos.x + oppos.width &&
+ this->x + this->width > oppos.x &&
+ this->y < oppos.y + oppos.height &&
+ this->y + this->height > oppos.y)
+ {
+ printf("Collision!!");
+ return true;
+ }
+
+ }
+};
class gobject
{
@@ -110,12 +133,15 @@ class gobject
this->xPos = xP;
this->yPos = yP;
}
- virtual void update(/*GLFWwindow *window,*/ bool paused, std::array<inGameInput,8> gameInput)
- {
+ public:
+ virtual void update(/*GLFWwindow *window,*/ bool paused, std::array<inGameInput,8> gameInput) = 0;
+ //{
// NOTE Update function, almost all of this code is temporary and for testing
// TODO add a proper reaction to inputs
- bool reset = false;
+ //bool reset = false;
// NOTE lord forgive me
+ //
+ /**
if (!paused)
{
if (gameInput[2].bState >= PRESSED)
@@ -139,9 +165,9 @@ class gobject
shader->use();
anilist.at(currentanim).draw();
}
- }
-
+ */
+ //}
};
@@ -193,5 +219,43 @@ class test:public gobject
}
};
+class nothing:public gobject
+{
+ private:
+ std::vector<Animation2D> anilist;
+ float xPos, yPos, scale;
+ unsigned int currentanim = 0;
+ Shader *shader;
+ public:
+ nothing(const float scale, Shader *shader):gobject(scale, shader)
+ {
+ // NOTE game object Constructor
+ this->xPos = 0.0f;
+ this->yPos = 0.0f;
+ this->scale = scale;
+ this->shader = shader;
+ printf("created");
+ }
+ void update(bool paused, std::array<inGameInput,8> gameInput)
+ {
+ // NOTE Update function, almost all of this code is temporary and for testing
+ // TODO add a proper reaction to inputs
+ bool reset = false;
+ printf("updated");
+
+ // NOTE lord forgive me
+ if (!paused)
+ {
+ shader->use();
+ play(this->currentanim, reset);
+ reset = false;
+ }
+ else {
+ shader->use();
+ anilist.at(this->currentanim).draw();
+ }
+ }
+};
+
#endif
diff --git a/scene.h b/scene.h
index 599c986..151a1af 100644
--- a/scene.h
+++ b/scene.h
@@ -108,6 +108,9 @@ class Scene
objects.push_back(test(0.5f, shade));
objects.at(0).addAnim("resources/sprite1.png", 10, VAO, 4);
objects.at(0).addAnim("resources/sprite2.png", 10, VAO, 4);
+ objects.push_back(nothing(0.5f, shade));
+ objects.at(1).addAnim("resources/sprite1.png", 10, VAO, 4);
+ objects.at(1).addAnim("resources/sprite2.png", 10, VAO, 4);
printf("scene created\n");
}