Java Code Examples for org.newdawn.slick.Input#KEY_P

The following examples show how to use org.newdawn.slick.Input#KEY_P . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainMenu.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	if (UI.globalKeyPressed(key))
		return;

	switch (key) {
	case Input.KEY_ESCAPE:
	case Input.KEY_Q:
		((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.EXIT);
		game.enterState(Opsu.STATE_BUTTONMENU);
		break;
	case Input.KEY_P:
		SoundController.playSound(SoundEffect.MENUHIT);
		if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING)
			openLogoMenu();
		else
			enterSongMenu();
		break;
	case Input.KEY_D:
		SoundController.playSound(SoundEffect.MENUHIT);
		game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
		break;
	case Input.KEY_O:
		SoundController.playSound(SoundEffect.MENUHIT);
		if ((logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) &&
		    !(input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)))
			openLogoMenu();
		else {
			showOptionsOverlay = true;
			optionsOverlayProgress.setTime(0);
			optionsOverlay.activate();
			input.consumeEvent();  // don't let options overlay consume this keypress
		}
		break;
	case Input.KEY_F:
		Options.toggleFPSCounter();
		break;
	case Input.KEY_Z:
		previousTrack();
		UI.getNotificationManager().sendBarNotification("<< Prev");
		break;
	case Input.KEY_X:
		if (MusicController.isPlaying()) {
			lastMeasureProgress = 0f;
			MusicController.setPosition(0);
		} else if (!MusicController.isTrackLoading())
			MusicController.resume();
		UI.getNotificationManager().sendBarNotification("Play");
		break;
	case Input.KEY_C:
		if (MusicController.isPlaying()) {
			MusicController.pause();
			UI.getNotificationManager().sendBarNotification("Pause");
		} else if (!MusicController.isTrackLoading()) {
			MusicController.resume();
			UI.getNotificationManager().sendBarNotification("Unpause");
		}
		break;
	case Input.KEY_V:
		nextTrack(true);
		UI.getNotificationManager().sendBarNotification(">> Next");
		break;
	case Input.KEY_R:
		nextTrack(true);
		break;
	case Input.KEY_UP:
		UI.changeVolume(1);
		break;
	case Input.KEY_DOWN:
		UI.changeVolume(-1);
		break;
	}
}
 
Example 2
Source File: SoundURLTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	if (key == Input.KEY_ESCAPE) {
		System.exit(0);
	}
	if (key == Input.KEY_SPACE) {
		sound.play();
	}
	if (key == Input.KEY_B) {
		burp.play();
	}
	if (key == Input.KEY_A) {
		sound.playAt(-1, 0, 0);
	}
	if (key == Input.KEY_L) {
		sound.playAt(1, 0, 0);
	}
	if (key == Input.KEY_RETURN) {
		charlie.play(1.0f,1.0f);
	}
	if (key == Input.KEY_P) {
		if (music.playing()) {
			music.pause();
		} else {
			music.resume();
		}
	}
	if (key == Input.KEY_C) {
		music.stop();
		if (music == musica) {
			music = musicb;
		} else {
			music = musica;
		}
		
		music.loop();
	}
	if (key == Input.KEY_E) {
		if (engine.playing()) {
			engine.stop();
		} else {
			engine.loop();
		}
	}
	
	if (c == '+') {
		volume += 1;
		setVolume();
	}
	
	if (c == '-') {
		volume -= 1;
		setVolume();
	}

}