summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelik Houij <houijmelik08@protonmail.com>2022-09-21 17:19:03 +0200
committerMelik Houij <houijmelik08@protonmail.com>2022-09-21 17:19:03 +0200
commit4373a07f662e6f9dc4f8f4f2a8b34df7151c47ce (patch)
tree98c1b53d98663b73a1415dffb952b4c2988557dd
parent9f52a01d9c4b549afe183914527dc8e15d537ffb (diff)
im about to do something
-rw-r--r--animation.h2
-rw-r--r--gobject.h21
-rw-r--r--scene.h4
3 files changed, 14 insertions, 13 deletions
diff --git a/animation.h b/animation.h
index dde2108..2b25af0 100644
--- a/animation.h
+++ b/animation.h
@@ -13,7 +13,7 @@
// shader header
#include "shader.h"
-class Animation2D
+struct Animation2D
{
// NOTE information about Animations
unsigned int framesCount = 1;
diff --git a/gobject.h b/gobject.h
index e9489dd..d7467e2 100644
--- a/gobject.h
+++ b/gobject.h
@@ -84,6 +84,8 @@ struct hitbox{
printf("Collision!!");
return true;
}
+ else
+ return false;
}
};
@@ -94,9 +96,9 @@ class gobject
// TODO might have to give my try at polymorthy
protected:
- std::vector<Animation2D> anilist;
float xPos, yPos, scale;
unsigned int currentanim = 0;
+ std::vector<Animation2D> anilist;
// NOTE shader is a pointer
Shader *shader;
public:
@@ -133,6 +135,11 @@ class gobject
this->xPos = xP;
this->yPos = yP;
}
+ void draw()
+ {
+ shader->use();
+ anilist.at(currentanim).draw();
+ }
public:
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
@@ -172,11 +179,11 @@ class gobject
class test:public gobject
{
private:
- std::vector<Animation2D> anilist;
float xPos, yPos, scale;
- unsigned int currentanim = 0;
+ int currentanim = 0;
Shader *shader;
public:
+ std::vector<Animation2D> anilist;
test(const float scale, Shader *shader):gobject(scale, shader)
{
// NOTE game object Constructor
@@ -211,8 +218,7 @@ class test:public gobject
reset = false;
}
else {
- shader->use();
- anilist.at(this->currentanim).draw();
+ draw();
}
}
};
@@ -232,14 +238,12 @@ class nothing:public gobject
this->yPos = 0.0f;
this->scale = scale;
this->shader = shader;
- printf("created");
}
void update(bool paused, std::array<inGameInput,8> gameInput) override
{
// 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)
@@ -249,8 +253,7 @@ class nothing:public gobject
reset = false;
}
else {
- shader->use();
- anilist.at(this->currentanim).draw();
+ draw();
}
}
};
diff --git a/scene.h b/scene.h
index 3b582ff..fe9b614 100644
--- a/scene.h
+++ b/scene.h
@@ -34,9 +34,6 @@ class Scene
// TODO change code around to be able to work off of any input
- // NOTE boilerplate dump, will make a proper loop or smthn later lmao
- //
- //
for (unsigned int i = 0; i < 8; i++ )
buttons[i].pressed(glfwGetKey(window, bConfig[i]));
};
@@ -171,6 +168,7 @@ class Scene
this->~Scene();
// TODO this is bad, the main while loop should manage killing the scenes
Scene *second = new Scene(window);
+
return second;
delete shade;
delete uiObj;