Exemplo n.º 1
0
//called when a key is pressed
void keyboardDown(unsigned char key, int mousePositionX, int mousePositionY)
{
	key = tolower(key);
	keys[key] = true;
	if (key == KEY_ESCAPE) glutExit();
	if (key == ' ' && MenOption == 3 && State=="Menu"){
		glutExit();
	}
}
Exemplo n.º 2
0
void keyboardControl(unsigned char key, int x, int y)
{
    switch(key) {
    case GLUT_KEY_F:
        freeCam = !freeCam; break;
    case GLUT_KEY_UP:
        camMoveSpeed += 0.01; break;
    case GLUT_KEY_DOWN:
        camMoveSpeed -= 0.01; break;
    case GLUT_KEY_J:
        ballX += 0.1f; break;
    case GLUT_KEY_L:
        ballX -= 0.1f; break;
    case GLUT_KEY_I:
        ballZ += 0.1f; break;
    case GLUT_KEY_K:
        ballZ -= 0.1f; break;
    case GLUT_KEY_H:
        glutToggleFullScreen(); break;
    case GLUT_KEY_ESC:
        glutExit(); break;
        //        default:
        //printf("Key code: %d\n", key);
    }
}
Exemplo n.º 3
0
static char* textFileRead(const char *fileName) {
	char* text = 0;



	if (fileName != 0) {
		FILE *file = fopen(fileName, "rt");

		if (file != 0) {
			fseek(file, 0, SEEK_END);
			int count = ftell(file);
			rewind(file);

			if (count > 0) {
				text = (char*)malloc(sizeof(char) * (count + 1));
				count = fread(text, sizeof(char), count, file);
				text[count] = '\0';
			}
			fclose(file);
		}
		else {
			std::cerr<< "File not found"<<std::endl<<fileName<<std::endl;
#ifdef __APPLE__
            exit(0);
#else
            glutExit();
#endif
		}
	}
	return text;
}
Exemplo n.º 4
0
void
keys(unsigned char c, int x, int y)
{

  if (c == 0x1b)
	glutExit();            /* escape */
#ifdef STEREO
  else switch (c) {
	/* adjust stereo3d parallax settings */
	case '+': 	fDxViewpoint += 0.010;
				calcStereoMatrix();
				break;
	case '-': 	fDxViewpoint -= 0.010;
				if (fDxViewpoint < 0.0)
					fDxViewpoint = 0.0;
				calcStereoMatrix();
				break;
	case '*': 	fDxImageShift += 0.001;
				calcStereoMatrix();
				break;
	case '/': 	fDxImageShift -= 0.001;
				calcStereoMatrix();
				break;
  }
#endif
}
Exemplo n.º 5
0
HRESULT CVideoMixerOpenGL::Close()
{
	if(!m_bOpen)	return E_FAIL;
	
	if(m_pDMCP)
	{
		m_pDMCP->Close();
		m_pDMCP->Release();
		m_pDMCP = NULL;
	}

	EnterCriticalSection(&m_csDisplay);
	
	glutExit();
	if(m_hThread)
	{
		::TerminateThread(m_hThread,0);
		m_hThread = NULL;
	}
	LeaveCriticalSection(&m_csDisplay);

	m_hWndParent = NULL;
	m_bOpen = false;
	return S_OK;
}
Exemplo n.º 6
0
//Initialisierungsfunktion
void Initialize(int argc, char* argv[])
{
    GLenum GlewInitResult;//neue Variable vom Typ GLenum (um GLEW initialisation zu prüfen)

    //initialisiert das anzeige-Window
    InitWindow(argc, argv);

    glewExperimental = GL_TRUE;//GLEW erhät Informationen zu den Erweiterungen des Grafiktreibers
    GlewInitResult = glewInit();//initialisieren von GLEW

    //Überprüfen, ob GLEW Initialisierung erfolgreich, wenn nicht wird ein Error geworfen und Programm beendet
    if (GLEW_OK != GlewInitResult)
    {
        fprintf(
            stderr,
            "ERROR: %s\n",
            glewGetErrorString(GlewInitResult)
        );
        glutExit();
    }

    //Ausgabe der OpenGL Version
    fprintf(
        stdout,
        "INFO: OpenGL Version: %s\n",
        glGetString(GL_VERSION)
    );

    glGetError();//gibt Fehlerinformationen aus
    glClearColor(0.20f, 0.2f, 0.2f, 0.0f); //setzt die Farbe, mit der die Buffer gecleart werden (Parameter bezüglich GLUT_RGBA)

    glEnable(GL_DEPTH_TEST);//aktiviert: Tiefenvergleiche und update des Tiefenbuffers (Wenn nicht aktiviert: kein tiefenvergleich, selbst mit aktiviertem Tiefenbuffer)
    glDepthFunc(GL_LESS);//Spezifiziert die Variable, die für den Tiefenbuffer genutzt wird (in diesem Fall: wenn Übergebene Tiefenvariable kleiner(Less) als die gespeicherte ist)

    ModelViewMatrixStack.loadIdentity();//setzt die aktuelle Matrix als Identitätsmatrix
    ProjectionMatrix.setIdentity();//setzt die Projektionsmatrix als Identitätsmatrix
    SetupShader();//Lädt und linked die shader
    LoadModel();//Lädt modelle
    loadTextures();//texturen laden
    initParticleSystem();//initialize particle system
    std::cout<<"\nChange Shader:\n"<<
             "1 - simple Shader\n"<<
             "2 - phong Shader\n"<<
             "\n"<<
             "Particle System:\n"<<
             "y - decrease maximum Lifetime of the particles\n"<<
             "x - increase maximum Lifetime of the particles\n"<<
             "\n"<<
             "c - decrease color alpha\n"<<
             "v - increase color alpha\n"<<
             "\n"<<
             "b - decrease particle count\n"<<
             "n - increase particle count\n"<<
             "\n"<<
             "o - increase comet speed\n"<<
             "l - decrease comet speed\n";
}
Exemplo n.º 7
0
/**************************************************************************//**
* @author Paul Blasi
*
* @par Description:
* Stores the state of the pressed key and does an initial update of the left
* player. Also handles the key presses for space, which pauses, escape, which
* exits the game, and +/-, which incresses and decreases the speed of the ball
* respectively.
*
* @param[in] key - the key that was pressed
* @param[in] x - the x position of the mouse when the key was pressed
* @param[in] y - the y position of the mouse when the key was pressed
*
*****************************************************************************/
void Keyboard(unsigned char key, int x, int y)
{
	KEYSTATE[key] = true;

	if ((KEYSTATE['w'] || KEYSTATE['W']) && !PAUSED)
	{
		LEFT_PLAYER.ChangeYSpeed(PADDLE_INC);
	}

	if ((KEYSTATE['a'] || KEYSTATE['A']) && !PAUSED)
	{
		LEFT_PLAYER.ChangeXSpeed((-1)*PADDLE_INC);
	}

	if ((KEYSTATE['s'] || KEYSTATE['S']) && !PAUSED)
	{
		LEFT_PLAYER.ChangeYSpeed(-1 * PADDLE_INC);
	}

	if ((KEYSTATE['d'] || KEYSTATE['D']) && !PAUSED)
	{
		LEFT_PLAYER.ChangeXSpeed(PADDLE_INC);
	}

	if (KEYSTATE['+'] && !PAUSED)
    {
        BALL.IncreaseMinVelocity();
    }

	if (KEYSTATE['-'] && !PAUSED)
    {
        BALL.DecreaseMinVelocity();
    }

    if (KEYSTATE[' '])
    {
        PAUSED = !PAUSED;

		if (PAUSED)
		{
			glutPostRedisplay();
		}
		else
		{
			glutTimerFunc(30, Animate, 0);
		}
    }

    if (KEYSTATE[ESCAPE_KEY])
    {
        glutExit();
    }
}
Exemplo n.º 8
0
void glut_display()
{
    bool signaled_shutdown = false;
    if (management_ != nullptr)
    {
        signaled_shutdown = management_->MainLoop(); 
        glutSwapBuffers();
    }

    if(signaled_shutdown)
    {
        glutExit();
        exit(0);
    }
}
Exemplo n.º 9
0
//Ruft alle FreeGLUT Funktionen um ein Window zu öffnen auf
void InitWindow(int argc, char* argv[])
{
    //Initialisiert die FreeGLUT lib (ist die erste FreeGLUT Funktion, die aufgerufen werden sollte)
    glutInit(&argc, argv);

    //*************Angabe des OpenGL Kontextes*************
    glutInitContextVersion(3, 3);//OpenGL Version 3.3
    glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);//Setzt die Kompatibilität so, dass es auch mit späteren OpenGL Versionen funktioniert
    glutInitContextProfile(GLUT_CORE_PROFILE);//nutzt OpenGL nur mit den neuesten Funktionen (compatibility mode = um ältere Versionen zu nutzen)
    //*****************************************************

    //GLUT_ACTION_ON_WINDOW_CLOSE und GLUT_ACTION_GLUTMAINLOOP_RETURNS bewirkt, dass die mainLoop Funktion das Programm nicht beendet sondern zum Programm zurückkehrt
    glutSetOption(
        GLUT_ACTION_ON_WINDOW_CLOSE,
        GLUT_ACTION_GLUTMAINLOOP_RETURNS
    );

    //setzt die Größe des render-Fensters
    glutInitWindowSize(CurrentWidth, CurrentHeight);

    //Displaymode gibt an, wie das Gerät die Szene rendern soll
    //GLUT_DEPTH = enthält die Tiefeninformation von Z für jeden Pixel (verhindert, dass neue Objekte nicht Objekte näher an der Kamera überlappen)
    //GLUT_DOUBLE = Flag um doppelbuffering zu aktivieren (reduziert flackern - 2 Buffer werden immer wieder Ausgewechselt - einer zum anzeigen, der andere zum rendern)
    //GLUT_RGBA = Flag um Farbkompositionen anzugeben (RGBA = Rot, Grün, Blau, Alpha)
    //es sind mehrere zusätzliche Optionen möglich
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);

    //erstellt ein Window und speichert das Handle dazu in WindowHandle (Parameter ist Window Title String)
    WindowHandle = glutCreateWindow("Test");

    //Handle checken, ob er kleiner als 1 ist, wenn ja wird Error geworfen und Programm beendet
    if(WindowHandle < 1)
    {
        fprintf(
            stderr,
            "ERROR: Could not create a new rendering window.\n"
        );
        glutExit();
    }

    //Glut function callbacks
    //TODO: add keyboard and mouse functions
    glutTimerFunc(0, TimerFunction, 0); //startet direkt die Funktion TimerFunction und übergibt 0 (damit der Titel am anfang nicht geändert wird)
    glutReshapeFunc(ResizeFunction); //wird jedes mal aufgerufen, wenn das Window verkleinert oder vergrößert wird
    glutDisplayFunc(RenderFunction); //wird jedes mal ausgeführt, wenn die szene auf den Bildschirm gezeichnet werden soll
    glutIdleFunc(IdleFunction); //macht die Idle Funktion bekannt
    glutKeyboardFunc(KeyEventProcessing);
}
Exemplo n.º 10
0
void keyboardControl(unsigned char key, int x, int y)
{
    vec3 camRight = Normalize(CrossProduct(camDir, camUp));
    mat4 rot;
    switch(key) {
        case GLUT_KEY_F:
            rot = ArbRotate(camRight, CAM_ROT_SPEED);
            camDir = Normalize(MultVec3(rot, camDir)); break;
        case GLUT_KEY_H:
            glutToggleFullScreen(); break;
        case GLUT_KEY_ESC:
            glutExit(); break;
            //        default:
            //printf("Key code: %d\n", key);
    }
 }
Exemplo n.º 11
0
/* ARGSUSED1 */
void parsekey(unsigned char key, int x, int y)
{
	switch (key)
	{
	case 27: glutExit(); break;
	case 13: break;
	case ' ': progress = 1; randomize(); break;
#ifdef STEREO
	/* update stereo parallax settings */
	case '+': dxViewpt += 0.100; break;
	case '-': dxViewpt -= 0.100; break;
	case '*': dxAdjust += 0.0001; break;
	case '/': dxAdjust -= 0.0001; break;
	case 's': stereo = (stereo) ? 0 : 1; break;
#endif
	}
}
Exemplo n.º 12
0
void glut_wrapper::keyboard(unsigned char key, int x, int y)
{
    switch(key)
    {
        case 27:
            glutExit();
            exit(0);
            break;

        case '.':
            glutFullScreenToggle();
            break;

        default:
            if (glut_wrapper::manager != nullptr)
            {
                glut_wrapper::manager->dispatchKeyboardInput(key);
            }
            break;
    }
}
Exemplo n.º 13
0
void glut_keyboard(unsigned char key, int x, int y)
{
    switch(key)
    {
        case 27:
            //Cleanup();
            glutExit();
            exit(0);
            break;
        case '.':
            if(!quality_measurement_mode_enabled_)
                glutFullScreenToggle();
            break;

        default:
            if (management_ != nullptr)
            {
                management_->dispatchKeyboardInput(key);
            }
            break;

    }
}
Exemplo n.º 14
0
void mouse(int button, int state, int x, int y)
{
	glutExit();
}
Exemplo n.º 15
0
void glut_wrapper::quit()
{
    glutExit();
}
Exemplo n.º 16
0
// All key events are processed here
void WorldDrawer::keyOperations()
{
	if (keyStates[KEY_ESC])			// On Escape, program exits
		glutExit();
	
	float rotateStep = 0.04f;
	float moveStep = 0.25f;

	if (camera.mode == MODE_FPS)
	{
		if (keySpecialStates[KEY_UP])			// Rotate FPS up
		{
			camera.rotateFPS_OX(-rotateStep);
		}
		if (keySpecialStates[KEY_DOWN])			// Rotate FPS down
		{
			camera.rotateFPS_OX(rotateStep);
		}
		if (keySpecialStates[KEY_LEFT])			// Rotate FPS left
		{
			camera.rotateFPS_OY(-rotateStep);
		}
		if (keySpecialStates[KEY_RIGHT])		// Rotate FPS right
		{
			camera.rotateFPS_OY(rotateStep);
		}
	}
	else if (camera.mode == MODE_TPS)
	{
		if (keySpecialStates[KEY_UP])					// Rotate TPS up
		{
			camera.rotateTPS_OX(-rotateStep, distanceToTPSTarget);
		}
		if (keySpecialStates[KEY_DOWN])					// Rotate TPS down
		{
			camera.rotateTPS_OX(rotateStep, distanceToTPSTarget);
		}
		if (keySpecialStates[KEY_LEFT])					// Rotate TPS left
		{
			camera.rotateTPS_OY(-rotateStep, distanceToTPSTarget);
		}
		if (keySpecialStates[KEY_RIGHT])				// Rotate TPS right
		{
			camera.rotateTPS_OY(rotateStep, distanceToTPSTarget);
		}
	}
	else if (camera.mode == MODE_TOP)
	{
		if (keySpecialStates[KEY_LEFT])					// Rotate left
		{
			camera.rotateTPS_OY(-rotateStep, distanceToTop);
		}
		if (keySpecialStates[KEY_RIGHT])				// Rotate right
		{
			camera.rotateTPS_OY(rotateStep, distanceToTop);
		}
	}

	float eyeDistanceStep = 1.f;

	// Zoom closer
	if (keyStates['['])
	{
		eyeDistance -= eyeDistanceStep;		// Move closer to the viewer
		if (camera.mode == MODE_TPS && distanceToTPSTarget - zoomSensivity > 0)
		{
			distanceToTPSTarget -= zoomSensivity;
			camera.translate_ForwardFree(zoomSensivity);
		}
		else if (camera.mode == MODE_TOP && distanceToTop - zoomSensivity * 20 > 0)
		{
			distanceToTop -= zoomSensivity * 20;
			camera.translate_ForwardFree(zoomSensivity * 20);
		}
	}
	if (keyStates[']'])
	{
		eyeDistance += eyeDistanceStep;		// Move farther from the viewer
		if (camera.mode == MODE_TPS)
		{
			distanceToTPSTarget += zoomSensivity;
			camera.translate_ForwardFree(-zoomSensivity);
		}
		else if (camera.mode == MODE_TOP)
		{
			distanceToTop += zoomSensivity * 20;
			camera.translate_ForwardFree(-zoomSensivity * 20);
		}
	}

	if (keyStates['w'])						// Move forward
	{
		camera.translate_Forward(moveStep);

		// Check colision
		
		Vector3D newPos = getPlayerPosition();
		std::vector<Point2d> neighbours = labyrinth.getNeighbours(labyrinth.playerPos);

		bool updatedCell = labyrinth.updateCell(neighbours, newPos);

		if (labyrinth.foundPortal())
		{
			Sleep(1000);
			int mode = camera.mode;
			switchCameraMode(MODE_FPS);
			init();
			switchCameraMode(mode);
		}
		if (!updatedCell)
		{
			for (unsigned int i = 0; i < neighbours.size(); ++i)
				if (labyrinth.isColision(neighbours[i], newPos))
				{
					camera.translate_Forward(-moveStep);
				}
		}

	}
	if (keyStates['s'])						// Move backwards
	{
		camera.translate_Forward(-moveStep);

		// Check colision
		Vector3D newPos = getPlayerPosition();
		std::vector<Point2d> neighbours = labyrinth.getNeighbours(labyrinth.playerPos);
		bool updatedCell = labyrinth.updateCell(neighbours, newPos);

		if (labyrinth.foundPortal())
		{
			Sleep(1000);
			int mode = camera.mode;
			switchCameraMode(MODE_FPS);
			init();
			switchCameraMode(mode);
		}
		if (!updatedCell)
		{
			for (unsigned int i = 0; i < neighbours.size(); ++i)
				if (labyrinth.isColision(neighbours[i], newPos))
				{
					camera.translate_Forward(moveStep);
				}
		}
	}
	if (keyStates['a'])						// Move left
	{
		camera.translate_Right(-moveStep);

		// Check colision
		Vector3D newPos = getPlayerPosition();
		std::vector<Point2d> neighbours = labyrinth.getNeighbours(labyrinth.playerPos);
		bool updatedCell = labyrinth.updateCell(neighbours, newPos);

		if (labyrinth.foundPortal())
		{
			Sleep(1000);
			int mode = camera.mode;
			switchCameraMode(MODE_FPS);
			init();
			switchCameraMode(mode);
		}
		if (!updatedCell)
		{
			for (unsigned int i = 0; i < neighbours.size(); ++i)
				if (labyrinth.isColision(neighbours[i], newPos))
				{
					camera.translate_Right(moveStep);
				}
		}
	}
	if (keyStates['d'])						// Move right
	{
		camera.translate_Right(moveStep);

		// Check colision
		Vector3D newPos = getPlayerPosition();
		std::vector<Point2d> neighbours = labyrinth.getNeighbours(labyrinth.playerPos);
		bool updatedCell = labyrinth.updateCell(neighbours, newPos);

		if (labyrinth.foundPortal())
		{
			Sleep(1000);
			int mode = camera.mode;
			switchCameraMode(MODE_FPS);
			init();
			switchCameraMode(mode);
		}
		if (!updatedCell)
		{
			for (unsigned int i = 0; i < neighbours.size(); ++i)
				if (labyrinth.isColision(neighbours[i], newPos))
				{
					camera.translate_Right(-moveStep);
				}
		}
	}
}
Exemplo n.º 17
0
Arquivo: main.cpp Projeto: Pinkii-/IDI
void teclado(unsigned char c, int x, int y) {
    (void)x;(void)y;
    switch (c) {
    case 27:
        glutExit();
        break;
    case 'h':
        help; //Nesisito aiuda amiho servesa bier
        std::cout << "You can see the state of the camera type on the up left corner." << std::endl;
        std::cout << "Press H to display the help(lolol)" << std::endl;
        std::cout << "Press R to reset the camera" << std::endl;
        std::cout << "Press P to switch between perspective and ortho camera" << std::endl;
        std::cout << "Press C to switch between first person camera and third person camera" << std::endl;
        std::cout << "Press WASD to move the Patricio" << std::endl;
        std::cout << "Press Z or X to increment/decrement the speed of the Patricio" << std::endl;
        std::cout << "Press V to make the walls visible/invisible" << std::endl;
        std::cout << "Press B to make the sfere of the scene visible/invisible" << std::endl;
        std::cout << "Press M to switch the model of the main character" << std::endl;
        std::cout << "Press O to change the polygon mode" << std::endl;
        std::cout << "Press Space to unleash the hidden and destructive power of the Killer Patricio" << std::endl;
        std::cout << std::endl;
        break;
    case 'w':
        patricio1.posFinal = patricio1.posFinal + Vector3f(sin(direccionPatricio*M_PI/180)*speed,0,cos(direccionPatricio*M_PI/180)*speed);
        updateCamera(); // Por si el patricio se ha salido de la esfera i ase iorar al ninio jisus
        glutPostRedisplay();
        break;
    case 's':
        patricio1.posFinal = patricio1.posFinal - Vector3f(sin(direccionPatricio*M_PI/180)*speed,0,cos(direccionPatricio*M_PI/180)*speed);
        updateCamera(); // Por si el patricio se ha salido de la esfera i ase iorar al ninio jisus
        glutPostRedisplay();
        break;
    case 'a':
        direccionPatricio += 2.5;
        if (fps) updateCamera();
        else glutPostRedisplay();
        break;
    case 'd':
        direccionPatricio -= 2.5;
        if (fps) updateCamera();
        else glutPostRedisplay();
        break;
    case 'z':
        speed += 0.03;
        break;
    case 'x':
        speed -= 0.03; if (speed < 0) speed = 0;
        break;
    case 'r':
        reset();
        glutPostRedisplay();
        break;
    case 'c':
        fps = not fps;
        if (fps) changeCamera(Fps);
        else changeCamera(ortho ? Ortho : Perspective);
        updateCamera();
        break;
    case 'p':
        if (cameraState != Fps) changeCamera(CameraType((cameraState+1)%(qttCameraType-1)));
        updateCameraType();
        break;
    case 'o':
        changeShowing(Showing((showing+1)%qttShowing));
        break;
    case 'm':
        patricio1.changeModel(Models((patricio1.name+1)%qttModels));
        glutPostRedisplay();
        break;
    case 'v':
        wallVisible = not wallVisible;
        glutPostRedisplay();
        break;
    case 'b':
        sferaVisible = not sferaVisible;
        glutPostRedisplay();
        break;
    case ' ':
        balas.push_back(Bala(patricio1.posFinal,direccionPatricio));
        break;
    default:
        break;
    }
}
Exemplo n.º 18
0
void WorldDrawer2d::keyboardCallbackFunction(unsigned char key, int posx, int posy){
	if(key==KEY_ESC) glutExit();
	//call client function
	onKey(key);
}
Exemplo n.º 19
0
//used to handle all user input
void handleInput(int deltatime)
{
	
	float deltaseconds = deltatime / 1000.0f;

	if (State == "Play"){

		Time += deltaseconds;
		glutSetCursor(GLUT_CURSOR_NONE);
		glutPassiveMotionFunc(setMouse);
		glutWarpPointer(win1.width / 2, win1.height / 2);
		float mouseSpeed = 5;
		float xAngle = mouseSpeed * deltaseconds * float(win1.width / 2 - mPosX);
		float yAngle = mouseSpeed * deltaseconds * float(win1.height / 2 - mPosY);

		camera1->mouseLook(xAngle, yAngle);
		cylinder1.yaw(-xAngle);

		if (keys['w']) {
			if (!jumping)
				PlaySound(TEXT("step.wav"), NULL, SND_FILENAME | SND_ASYNC| SND_NOSTOP);
			camera1->move(deltaseconds * (15 + boost));
			distanceFromMaze = checkCollision(toClosestEdge);
			if (distanceFromMaze > 4.0){
				handleCollision();
			}
			moveTime++;
			if (moveTime > 30){
				legAngle *= -1;
				moveTime = 0;
			}
			thighLeft.pitch(legAngle);
			thighRight.pitch(-legAngle);

		}
		else{
			moveTime = 15;
			thighLeft.resetOrientation();
			thighRight.resetOrientation();


		}
		if (keys['f']){
			savePlayer = cylinder1;
			savePoint = camera1->getPosition();
			saveUP = camera1->getCameraUp();
			saveFOR = camera1->getForward();
			savePoint.y = 2;
			hasSavePoint = true;
			keys['f'] = false;
		}
		if (keys['g'] && hasSavePoint){
			cylinder1 = savePlayer;
			camera1->setPosition(savePoint);
			camera1->setCameraUp(saveUP);
			camera1->setForward(saveFOR);
			keys['g'] = false;
		}
		if (keys['s']){
			if (!jumping)
				PlaySound(TEXT("step.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_NOSTOP);
			camera1->move(-deltaseconds * (15 + boost));
			distanceFromMaze = checkCollision(toClosestEdge);
			if (distanceFromMaze > 4.0){
				handleCollision();
			}

		}
		if (keys['a']) {
			if (!jumping)
				PlaySound(TEXT("step.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_NOSTOP);
			camera1->strafe(-deltaseconds * (15 + boost));
			distanceFromMaze = checkCollision(toClosestEdge);
			if (distanceFromMaze > 4.0){
				handleCollision();
			}
		}
		if (keys['d']) {
			if (!jumping)
				PlaySound(TEXT("step.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_NOSTOP);
			camera1->strafe(deltaseconds * (15 + boost));
			distanceFromMaze = checkCollision(toClosestEdge);
			if (distanceFromMaze > 4.0){
				handleCollision();
			}
		}
		if (keys['p']) {
			State = "Menu";
			isPaused = true;
		}
		if (keys[' '] && Stamina > 5 && !jumping) {
			PlaySound(TEXT("jump.wav"), NULL, SND_FILENAME | SND_ASYNC );
			jumping = true;
			Stamina -= 5;
			keys[' '] = false;
		}
		if (jumping) camera1->jump(deltaseconds * 10);
	
		
		if (camera1->getPosition().y <= 2){
			camera1->setPosition(Vector3(camera1->getPosition().x, 2, camera1->getPosition().z));
			jumping = false;
			camera1->gravity = 0.25;
		}

		if (special[GLUT_KEY_SHIFT_L] && Stamina > 0){
			Stamina -= (0.001 / deltaseconds);
			if (Stamina < 0){
				Stamina = 0;
				boost = 0;
			}
			else{
				boost = 10;
			}
		}
		else{
			boost = 0;
			Stamina += (0.001 / deltaseconds);
			if (Stamina >= 100){
				Stamina = 100;
			}
		}
	
	}
	if (State == "Menu"){
		if (!isPaused){
			if (special[GLUT_KEY_UP]){
				MenOption--;
				PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
				special[GLUT_KEY_UP] = false;
				if (MenOption < 0){
					MenOption = 3;
				}
			}

			if (special[GLUT_KEY_DOWN]){
				MenOption++;
				PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
				special[GLUT_KEY_DOWN] = false;
				if (MenOption > 3){
					MenOption = 0;
				}
			}
		}
		else{
			if (special[GLUT_KEY_UP]){
				PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
				MenOption--;
				special[GLUT_KEY_UP] = false;
				if (MenOption < 0){
					MenOption = 4;
				}
			}

			if (special[GLUT_KEY_DOWN]){
				PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
				MenOption++;
				special[GLUT_KEY_DOWN] = false;
				if (MenOption > 4){
					MenOption = 0;
				}
			}
		}

		if (keys[' '] && MenOption == 0){
			PlaySound(TEXT("play.wav"), NULL, SND_FILENAME | SND_ASYNC);
			if (!isPaused)
				State = "Loading";
			else
				State = "Play";
			keys[' '] = false;
			isPaused = false;
		}
		if (keys[' '] && MenOption == 1){
			PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
			State = "Controls";
			keys[' '] = false;
		}
		if (keys[' '] && MenOption == 2){
			PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
			State = "Credits";
			keys[' '] = false;
		}
		if (keys[' '] && MenOption == 3){
			PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
			glutExit();
		}
		if (keys[' '] && MenOption == 4){
			PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
			Stamina = 100;
			camera1 = new Camera(Vector3(levels[currLevel]->startPoint->x, 2, levels[currLevel]->startPoint->y), findPosition(levels[currLevel]), Vector3(0, 1, 0));
			State = "Loading";
			keys[' '] = false;
			isPaused = false;
		}
	}

	if (State == "Credits"){
		if (keys[' ']){
			PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
			State = "Menu";
			keys[' '] = false;
		}
	}
	if (State == "Controls"){
		if (keys[' ']){
			PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
			State = "Menu";
			keys[' '] = false;
		}
	}
	if (State == "Loading"){
		if (keys[' ']){
			PlaySound(TEXT("switch.wav"), NULL, SND_FILENAME | SND_ASYNC);
			State = "Play";
			keys[' '] = false;
		}
	}
}