summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelik Houij <houijmelik08@protonmail.com>2022-09-09 09:01:09 +0200
committerMelik Houij <houijmelik08@protonmail.com>2022-09-09 09:01:09 +0200
commit8793b704734677d548239b4cbb62b1ac0d644d41 (patch)
treeb4c3ab375e33636fac310d34ea9d8883d5b33f83
parent1be23de45836b86223bc4bd6c92ddecab8c2d385 (diff)
fixed the bug somehow
-rw-r--r--gobject.h54
-rw-r--r--scene.h4
2 files changed, 42 insertions, 16 deletions
diff --git a/gobject.h b/gobject.h
index 08d2195..260bc41 100644
--- a/gobject.h
+++ b/gobject.h
@@ -110,7 +110,7 @@ class gobject
this->xPos = xP;
this->yPos = yP;
}
- void update(/*GLFWwindow *window,*/ bool paused, std::array<inGameInput,8> gameInput)
+ virtual void update(/*GLFWwindow *window,*/ 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
@@ -141,29 +141,57 @@ class gobject
}
}
+
+
};
-class Projectile : public gobject
+class test:public gobject
{
+ private:
+ std::vector<Animation2D> anilist;
+ float xPos, yPos, scale;
+ unsigned int currentanim = 0;
+ Shader *shader;
public:
- Projectile(const float scale, Shader *shader, float xStart = 0.5, float yStart = 0.5):gobject(scale, shader)
+ test(const float scale, Shader *shader):gobject(scale, shader)
{
// NOTE game object Constructor
- this->xPos = xStart;
- this->yPos = yStart;
+ this->xPos = 0.0f;
+ this->yPos = 0.0f;
this->scale = scale;
this->shader = shader;
}
-
- void update(/*GLFWwindow *window,*/ bool paused, std::array<inGameInput,8> gameInput)
+ void update(bool paused, std::array<inGameInput,8> gameInput)
{
-
- shader->use();
- anilist.at(currentanim).draw();
+ // NOTE Update function, almost all of this code is temporary and for testing
+ // TODO add a proper reaction to inputs
+ bool reset = false;
+ // NOTE lord forgive me
+ if (!paused)
+ {
+ if (gameInput[2].bState >= PRESSED)
+ this->move(-0.1f);
+ if (gameInput[3].bState >= PRESSED)
+ this->move(0.1f);
+ if (gameInput[4].bState == PRESSED)
+ {
+ this->currentanim = 0;
+ reset = true;
+ }
+ if (gameInput[5].bState == PRESSED)
+ {
+ this->currentanim = 1;
+ reset = true;
+ }
+ play(this->currentanim, reset);
+ reset = false;
+ }
+ else {
+ shader->use();
+ anilist.at(this->currentanim).draw();
+ }
}
-
-
-
};
+
#endif
diff --git a/scene.h b/scene.h
index 53eba3f..599c986 100644
--- a/scene.h
+++ b/scene.h
@@ -105,11 +105,9 @@ class Scene
// NOTE temporary Code,used for Testing
// TODO test how the Engine handles multiple objects at the same time
- objects.push_back(gobject(0.5f, shade));
- objects.push_back(Projectile(0.5f, shade));
+ 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.at(1).addAnim("resources/sprite2.png", 10, VAO, 4);
printf("scene created\n");
}