summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelik Houij <houijmelik08@protonmail.com>2022-09-01 10:43:37 +0200
committerMelik Houij <houijmelik08@protonmail.com>2022-09-01 10:43:37 +0200
commit2c17f2f68241a9b239fc915077c6f473584e5e10 (patch)
treeeeacda12e1f9df85efad939831e6efddd2237adb
parentfde10b7e32bde1ffe8a77620a338100a29cefc85 (diff)
fixed segmentation fault at the end of runtime, check readme
-rw-r--r--gobject.h3
-rw-r--r--main.cpp14
-rw-r--r--readme.org6
-rw-r--r--scene.h35
4 files changed, 28 insertions, 30 deletions
diff --git a/gobject.h b/gobject.h
index 0fa9737..6fb31b6 100644
--- a/gobject.h
+++ b/gobject.h
@@ -53,7 +53,8 @@ uint16_t timeHeld = 0; // time held
bState = RELEASED;
break;
- default :
+ case RELEASED :
+ case UNPRESSED :
bState = UNPRESSED;
timeHeld = 0;
}
diff --git a/main.cpp b/main.cpp
index d348c3e..2a82cca 100644
--- a/main.cpp
+++ b/main.cpp
@@ -43,7 +43,7 @@ int main()
#endif
// NOTE create Pointer and window
- GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "MilkerTest 0.0.5", NULL, NULL);
+ GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "MilkerTest 0.0.9", NULL, NULL);
if (window == NULL)
{
std::cout << "failed to create GLFW window" << std::endl;
@@ -65,11 +65,10 @@ int main()
printf("initialization complete\n");
printf("grabbing shaders\n");
- Scene main(window/*, SCR_WIDTH, SCR_HEIGHT*/);
// NOTE the game will have a Pointer Pointing to the current scene to be displayed
// at the End of the scene's lifetime the pointer will point to a different scene then promptly kill itself
// TODO integrate a smart pointer instead
- current = &main;
+ Scene *current = new Scene(window);
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
@@ -77,9 +76,8 @@ int main()
while(!glfwWindowShouldClose(window))
{
if(current->update())
- {
current = (current->kill());
- }
+
glfwSwapBuffers(window);
glfwPollEvents();
@@ -96,10 +94,12 @@ while(!glfwWindowShouldClose(window))
lasttime += 1.0/targetFps;
}
- glfwTerminate();
- return 0;
+delete current;
+glfwTerminate();
+return 0;
}
+
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
diff --git a/readme.org b/readme.org
index 2e2f906..e82c009 100644
--- a/readme.org
+++ b/readme.org
@@ -1,4 +1,4 @@
-* Milker Engine
+* Milker Engine 0.0.9
The MIT License (MIT)
Copyright (c) 2022 Melik Houij
@@ -31,6 +31,10 @@ g++ main.cpp -o GAME ./lib/glad.o -lglfw -lGL -ldl -lsfml-audio -lfreetype
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)
+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
+
** 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 eb0ec01..d63e744 100644
--- a/scene.h
+++ b/scene.h
@@ -58,9 +58,10 @@ class Scene
//buttonState state = OFF;
bool pausePressed = false;
- Scene(GLFWwindow* window/*, const int &mode*/)
+ Scene(GLFWwindow* window, unsigned short int real=0/*, const int &mode*/)
{
// NOTE assign window Pointer and Create a Text Object;
+ // NOTE temporary
this->window = window;
this->texty = Text();
@@ -105,7 +106,7 @@ class Scene
objects.push_back(gobject(0.5f, shade));
objects.at(0).addAnim("resources/sprite1.png", 10, VAO, 4);
objects.at(0).addAnim("resources/sprite2.png", 10, VAO, 4);
-
+ printf("scene created\n \n");
}
@@ -114,23 +115,7 @@ class Scene
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
- /*
- if(this->paused == false)
- {
-
- if(glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS)
- sound.play();
-
- }
- else if (this->paused == true)
- {
- // NOTE to test basic uiOBJ
- uiObj->draw();
- if(glfwGetKey(window, GLFW_KEY_Q) == GLFW_REPEAT)
- this->paused = false;
- }
- */
- pollGInputs();
+ pollGInputs();
if(glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
{
if(!pausePressed)
@@ -158,10 +143,15 @@ class Scene
else {
uiObj->draw(buttons);
}
- // NOTE to test audio playback
+ for (unsigned short int i = 0; i < 8; i++ )
+ std::cout << buttons[i].bState << " ";
+ std::cout << "\r";
+
+ // NOTE when the Scene is ready to be discarded it returns true on update
return killNow;
// NOTE testing Text Rendering
//texty.Render("SDSDSD", 25.0f, 25.0f, 2.0f, glm::vec3(1.0, 0.8f, 0.2f));
+
}
Scene* kill()
@@ -172,13 +162,16 @@ class Scene
glDeleteBuffers(1, &VBO);
glDeleteBuffers(1, &EBO);
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;
+
}
~Scene()
{
printf("scene killed successfully\n");
- glfwWindowShouldClose(window);
}