[ADD] menu now works

menu switches to next item when hand is closed and calls OnClick() when hand is closed
This commit is contained in:
Jasper
2021-06-04 16:32:26 +02:00
parent 7cc918fdf8
commit b3412e414e
8 changed files with 171 additions and 72 deletions

View File

@@ -25,9 +25,6 @@
#include "scenes/in_Game_Scene.h"
#include "scenes/startup_Scene.h"
#include "computervision/MenuTest.h"
#include "computervision/ObjectDetection.h"
#pragma comment(lib, "glfw3.lib")
#pragma comment(lib, "glew32s.lib")
#pragma comment(lib, "opengl32.lib")
@@ -35,7 +32,7 @@
static double UpdateDelta();
static GLFWwindow* window;
int chosen_item = 0;
scene::Scene* current_scene;
int main(void)
@@ -43,7 +40,7 @@ int main(void)
#pragma region OPENGL_SETTINGS
if (!glfwInit())
throw "Could not inditialize glwf";
window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGT, "SDBA", NULL, NULL);
window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "SDBA", NULL, NULL);
if (!window)
{
glfwTerminate();
@@ -69,8 +66,7 @@ int main(void)
bool window_open = true;
computervision::ObjectDetection objDetect;
cv::Mat cameraFrame;
// Main game loop
while (!glfwWindowShouldClose(window) && window_open)
@@ -100,56 +96,6 @@ int main(void)
break;
}
////////////////////////// KIMS SHIT ////////////////////////////////////
cameraFrame = objDetect.readCamera();
computervision::MenuTest menu_test;
//Get hand state from camera
bool hand_detection = objDetect.detectHand(cameraFrame);
if (hand_detection)
{
std::cout << "hand is opened" << std::endl;
//Loop through menu items
chosen_item = menu_test.GetMenuItem(true);
//For debug only, to see if chosen item is selected properly when hand is opened
std::cout << "chosen item: " << chosen_item << std::endl;
}
else if (!hand_detection)
{
//for debug only, to see if the chosen item is selected properly when hand is closed
std::cout << "hand is closed" << std::endl;
//std::cout << "item to start: " << chosen_item << std::endl;
//TODO link chosen item to the correct game states
switch (chosen_item)
{
case 1:
//Game state 0
std::cout << "in case: " << chosen_item << std::endl;
break;
case 2:
//Game state 1
std::cout << "in case: " << chosen_item << std::endl;
break;
case 3:
//Game state 2
std::cout << "in case: " << chosen_item << std::endl;
break;
case 4:
//Game state 3
std::cout << "in case: " << chosen_item << std::endl;
default:
break;
}
}
///////////////////////// END OF KIMS SHIT ///////////////////////////////
// Finish up
//shader.Stop();
glfwSwapBuffers(window);