示例#1
0
void keypress(unsigned char key, int x, int y){

    // Test if user pressed ESCAPE (ascii 27)
    // If so, exit the program
    if(key==27){
        exitScene();
    }

    // 'W' key toggles wireframe mode on & off
    /*if(key == 'w' || key == 'W'){
        wireframe=!wireframe;
        if(wireframe){
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        }
        else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }*/

    // Other possible keypresses go here
    if(key == 'a'){   field.addBlackHoleMagnitude( -0.1 ) ;    }
    if(key == 'd'){   field.addBlackHoleMagnitude(  0.1 ) ;    }

    if(key == 's'){   field.addBlackHoleCentreY (-0.1 ) ;    }
    if(key == 'w'){   field.addBlackHoleCentreY ( 0.1 ) ;    }

}
示例#2
0
void keypressSub(unsigned char key, int x, int y)
{
	// If so, exit the program
    if(key == 27)
	{
		exitScene();
	}

	if(key == '+')
	{
		if(texIndex < 4)
		{
			texIndex++;
			if(texIndex == 4)
				texIndex = 3;
		}
	}

	if(key == '-')
	{
		if(texIndex > -1)
		{
			texIndex--;
			if(texIndex == -1)
				texIndex = 0;
		}
	}

	glutPostRedisplay();
}
示例#3
0
void GameplayScene::handleEvents() {
    sf::Event event;
    while( game->window.pollEvent(event ) )
    {
        if( event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape ) {
            exitScene(new MenuScene(game));
        }
        else if( event.type == sf::Event::KeyPressed) {
            if (event.key.code == sf::Keyboard::Left) {
                platform->changeDirection(DIRECTION::LEFT);
                isKeyHeld[DIRECTION::LEFT] = true;
            }
            else if (event.key.code == sf::Keyboard::Right) {
                platform->changeDirection(DIRECTION::RIGHT);
                isKeyHeld[DIRECTION::RIGHT] = true;
            }
        }
        else if( event.type == sf::Event::KeyReleased ) {
            if( event.key.code == sf::Keyboard::Left ) {
                platform->resetDirection(DIRECTION::LEFT);
                isKeyHeld[DIRECTION::LEFT] = false;
                if (isKeyHeld[DIRECTION::RIGHT]) platform->changeDirection(DIRECTION::RIGHT);
            }
            else if( event.key.code == sf::Keyboard::Right ) {
                platform->resetDirection(DIRECTION::RIGHT);
                isKeyHeld[DIRECTION::RIGHT] = false;
                if (isKeyHeld[DIRECTION::LEFT]) platform->changeDirection(DIRECTION::LEFT);
            }
        }
        else break;
    }
}
示例#4
0
void keypress(unsigned char key, int x, int y)
{
	// If so, exit the program
    if(key == 27)
	{
		exitScene();
	}

	rayCaster.rayCastKeyPress(key, x, y);

	glutPostRedisplay();
}
示例#5
0
void keyPressed(unsigned char key, int x, int y){
	
	switch (key)
	{
	case 27:
		// Test if user pressed ESCAPE (ascii 27)
		// If so, exit the program
		exitScene();
		break;

	case 'w':
	case 'W':
		wireframe=!wireframe;
		glPolygonMode(GL_FRONT_AND_BACK, (wireframe ? GL_LINE : GL_FILL));
		break;

	case 'i':
	case 'I':
		invertedSolution=!invertedSolution;
		break;

	case 'z':
	case 'Z':
		BoneA_Length -= deltaPos;
		break;

	case 'a':
	case 'A':
		BoneA_Length += deltaPos;
		break;

	case 'x':
	case 'X':
		BoneB_Length -= deltaPos;
		break;

	case 's':
	case 'S':
		BoneB_Length += deltaPos;
		break;

	// Other possible keypresses go here
	/*case 'a':
		...
		break;*/

	default:
		break;
	}
}
示例#6
0
文件: Lab2.cpp 项目: daruane/college
void keypress(unsigned char key, int x, int y)
{
    switch (key) {
    case ('w' | 'W'):
	{
	    wireframe = !wireframe;
        wireframe?glPolygonMode(GL_FRONT_AND_BACK, GL_LINE):
                  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	    break;
	}
    case (27):
	exitScene();
	break;
    }
}
void keypress(unsigned char key, int x, int y) {
    int mod = glutGetModifiers();

    int run = 1;
    if (mod == GLUT_ACTIVE_SHIFT) {
        run = run * 2;
    }

    // Test if user pressed ESCAPE (ascii 27)
    // If so, exit the program
    if(key==27) { // ESC
        exitScene();
    }

    if (key==32) { // Space bar
    }
    if (key=='w')
        wPressed=true;

    if (key=='a')
        aPressed=true;

    if (key=='s')
        sPressed=true;

    if (key=='d')
        dPressed=true;
    if (key== 'x') {
        multiplier += 0.5;
    }
    if (key== 'c') {
        multiplier -= 0.5;
    }
    // Change the view
    if (key=='v') {
        if (thirdPerson) thirdPerson=false;
        else thirdPerson=true;
    }


    if (key=='y') {
        if (disco) {
            disco = false;
        }
        else {
            disco = true;
        }
    }

    if (key=='f') {
        toggleFullscreen();
    }
    if (key=='l') {
        // Cheat!
        //	for (int i=0; i<enemyCount[level]; i++){
        //	enemies[i]->kill();
        //}
        //checkLevelComplete();
        /*
        if (!lighting){
        	glEnable(GL_LIGHTING);
        	lighting = true;
        }else{
        	glDisable(GL_LIGHTING);
        	lighting = false;
        }
        */
    }



}
示例#8
0
void keypress(unsigned char key, int x, int y){

    // Test if user pressed ESCAPE (ascii 27)
    // If so, exit the program
    if(key==27){
        exitScene();
    }

    // 'W' key toggles wireframe mode on & off
    /*if(key == 'w' || key == 'W'){
        wireframe=!wireframe;
        if(wireframe){
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        }
        else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }*/

    // Other possible keypresses go here
    if(key == 'a'){
        collection.at(0).position.x--;
    }
    if(key == 'd'){
        collection.at(0).position.x++;
    }

    if(key == 's'){
        collection.at(0).position.z--;
    }
    if(key == 'w'){
        collection.at(0).position.z++;
    }

    if(key == 'q'){
        collection.at(0).position.y--;
    }
    if(key == 'e'){
        collection.at(0).position.y++;
    }

    if(key == '4'){
        collection.at(1).position.x--;
    }
    if(key == '6'){
        collection.at(1).position.x++;
    }

    if(key == '8'){
        collection.at(1).position.z--;
    }
    if(key == '2'){
        collection.at(1).position.z++;
    }

    if(key == '7'){
        collection.at(1).position.y--;
    }
    if(key == '9'){
        collection.at(1).position.y++;
    }

}