summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelik Houij <houijmelik08@protonmail.com>2022-09-01 12:35:25 +0200
committerMelik Houij <houijmelik08@protonmail.com>2022-09-01 12:35:25 +0200
commit15fbb2a11c8a8af77cda9491d72cf67dc3a51e20 (patch)
treefd8ddc63df8cd3b3db8f886c7ff4cdde9080bd97
parent2c17f2f68241a9b239fc915077c6f473584e5e10 (diff)
added in game display for inputs and fixed a bug
-rw-r--r--UI.hpp4
-rw-r--r--gobject.h1
-rw-r--r--main.cpp2
-rw-r--r--readme.org4
-rw-r--r--scene.h10
5 files changed, 14 insertions, 7 deletions
diff --git a/UI.hpp b/UI.hpp
index 94fae17..3ab5cd9 100644
--- a/UI.hpp
+++ b/UI.hpp
@@ -10,7 +10,8 @@
enum uiMenus {
PAUSE,
EXIT
-} currentMenu = PAUSE;
+};
+
class UI
{
@@ -19,6 +20,7 @@ class UI
Shader *uiShader = new Shader("resources/shaders/uishader.vert", "resources/shaders/uishader.frag");
Text textObj;
int selectedUI = 0;
+ uiMenus currentMenu = PAUSE;
// TODO maybe use arrays instead?
std::vector<std::string> pauseMenu = {"Resume","Exit", "Print" };
std::vector<std::string> exitMenu = {"Quit Game", "Cancel"};
diff --git a/gobject.h b/gobject.h
index 6fb31b6..ca22a4d 100644
--- a/gobject.h
+++ b/gobject.h
@@ -41,6 +41,7 @@ uint16_t timeHeld = 0; // time held
timeHeld++;
break;
default:
+ bState = HELD;
break;
}
diff --git a/main.cpp b/main.cpp
index 2a82cca..aadf615 100644
--- a/main.cpp
+++ b/main.cpp
@@ -19,7 +19,7 @@ Scene* current;
int SCR_WIDTH = 960;
int SCR_HEIGHT = 540;
// NOTE target FPS, the end game will run at 60 frames, however i am putting it on 20 to make it easier to observe
-int targetFps = 60;
+int targetFps = 20;
// define base function
// NOTE another way of input is probably better int Input = 0;
// TODO Add Scaling, this is probably done on the shader level
diff --git a/readme.org b/readme.org
index e82c009..147c4e7 100644
--- a/readme.org
+++ b/readme.org
@@ -32,9 +32,9 @@ on Windows:
g++ main.cpp -o GAME glad.a -lglfw -lopenGL32 -lGID32
*** Known Bugs
-TODO after restarting the scene and pulling up the pause menu you need to press 7 twice for the button to work, according to buttons and the scene the buttons are set to -1(UNPRESSED)
+DONE after restarting the scene and pulling up the pause menu you need to press 7 twice for the button to work, according to buttons and the scene the buttons are set to -1(UNPRESSED)
i believed the bug was caused due to the scene believing one of the buttons were set to 0(RELEASED) but they are all -1 which causes me to believe the problem lies in the UI object
-
+fix: in the definition of uiMenus, i made a variable that persists, i replaced it with a variable that gets replaced
** Game Engine Functionality
Basic Game engine For Fighting game, with the Idea of having minimalist functionality
TODO Add more that come to mind
diff --git a/scene.h b/scene.h
index d63e744..452ca3f 100644
--- a/scene.h
+++ b/scene.h
@@ -12,6 +12,7 @@
#include "text.h"
#include "UI.hpp"
+#include <string>
// NOTE using bitwise operators for storing inputs
// first 4 bits are going to store directional input
@@ -53,7 +54,7 @@ class Scene
Text texty;
Shader *shade = new Shader("resources/shaders/shader.vert", "resources/shaders/shader.frag");
// NOTE for some reason cant point itself
- UI *uiObj = new UI(&paused, &killNow);
+ UI *uiObj;
//enum buttonState {OFF, PRESSED, HELD};
//buttonState state = OFF;
bool pausePressed = false;
@@ -64,6 +65,7 @@ class Scene
// NOTE temporary
this->window = window;
this->texty = Text();
+ uiObj = new UI(&paused, &killNow);
buffer.loadFromFile("resources/test.wav");
sound.setBuffer(buffer);
@@ -143,9 +145,11 @@ class Scene
else {
uiObj->draw(buttons);
}
+ std::string S = "";
for (unsigned short int i = 0; i < 8; i++ )
- std::cout << buttons[i].bState << " ";
- std::cout << "\r";
+ S += std::to_string(buttons[i].bState);
+
+ texty.Render(S, 25.0f, 25.0f, 1.5f, glm::vec3(1.0, 0.8f, 0.2f));
// NOTE when the Scene is ready to be discarded it returns true on update
return killNow;