Beispiel #1
0
void handleKeypress(unsigned char key, int x, int y) {
	switch (key) {
	case 100:
		if(c.mmovement == c.NONE)
		{
			c.mmovement = c.RIGHT;
		}	
		break;
	case 97:
		if(c.mmovement == c.NONE)
		{
			c.mmovement = c.LEFT;
		}	
		
		break;
	case 119: 
		if(c.mmovement == c.NONE)
		{
			c.mmovement = c.UP;
		}	
		
		break;
	case 115:
		if(c.mmovement == c.NONE)
		{
		c.mmovement = c.DOWN;
		}	
		break;
		case 109:
			mute = !mute;
			c.set_sound();
			p.set_sound();
			break;
		case 'r':
			p.prepare_level();
			break;

	case 27: //Escape key
		glutDisplayFunc(screen_title);
		glutKeyboardFunc(handle_titlescreen_key);
			
	}
}
Beispiel #2
0
// Handle the keys pressed on the title screen
void handle_titlescreen_key(unsigned char key, int x, int y)
{
	switch(key)
	{
	case 119:
	case 38:
		if(titleposition != 0.25)
		{
			if(!mute)
			{
				PlaySound(L"select.wav", NULL, SND_ASYNC|SND_FILENAME);
			}
			titleposition += 2;
		}
		break;
	case 's':
		if(titleposition != (0.25 - 3*2))
		{
			if(!mute){
				PlaySound(L"select.wav", NULL, SND_ASYNC|SND_FILENAME);
			}
				titleposition -= 2;
		}
		break;
	case 13:
		// Make the selection automatically the above one
		if(titleposition == 0.25 || titleposition == -1.75)
		{
			if(titleposition == 0.25)
			{
				// Do the level finder
				
				ifstream myfile ("pwd.txt");

				if(myfile == NULL){
					// Nothing to do
				}
				else
				{
					string a; 
					const char* l;
					int lvl;
					getline(myfile, a);
					lvl = a[0];
					p.change_mlevelno(lvl);
				}

			}
			else{
			p.change_mlevelno(1);
			}
			
			titleposition = 0.25;
			p.prepare_level();
			glutDisplayFunc(drawScene);
			glutKeyboardFunc(handleKeypress);
		}
		else if (titleposition == -3.75)
		{
			titleposition = 0.25;
			glutDisplayFunc(instruction_screen);
			glutKeyboardFunc(instruction_keys);

		}
		else if(titleposition == -5.75)
		{
			exit(0);
		}

		break;
	case 109:
		mute = !mute;
		c.set_sound();
		p.set_sound();
		break;

	case 27: //Escape key
			exit(0);
			break;
	}

}