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

The following examples show how to use org.newdawn.slick.Input#KEY_UP . 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: TestState3.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char)
 */
public void keyReleased(int key, char c) {
	if (key == Input.KEY_DOWN) {
		selected++;
		if (selected >= options.length) {
			selected = 0;
		}
	}
	if (key == Input.KEY_UP) {
		selected--;
		if (selected < 0) {
			selected = options.length - 1;
		}
	}
	if (key == Input.KEY_1) {
		game.enterState(TestState1.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
	}
	if (key == Input.KEY_2) {
		game.enterState(TestState2.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
	}
}
 
Example 2
Source File: TransformTest2.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 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_Q) {
      scaleUp = true;
   }
   if (key == Input.KEY_A) {
      scaleDown = true;
   }

   if( key == Input.KEY_LEFT) {
      moveLeft = true;
   }
   if( key == Input.KEY_UP ) {
      moveUp = true;
   }
   if( key == Input.KEY_RIGHT ) {
      moveRight = true;
   }
   if( key == Input.KEY_DOWN ) {
      moveDown = true;
   }
}
 
Example 3
Source File: TransformTest2.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#keyReleased(int, char)
 */
public void keyReleased(int key, char c) {
   if (key == Input.KEY_Q) {
      scaleUp = false;
   }
   if (key == Input.KEY_A) {
      scaleDown = false;
   }
   
   if( key == Input.KEY_LEFT) {
      moveLeft = false;
   }
   if( key == Input.KEY_UP ) {
      moveUp = false;
   }
   if( key == Input.KEY_RIGHT ) {
      moveRight = false;
   }
   if( key == Input.KEY_DOWN ) {
      moveDown = false;
   }
}
 
Example 4
Source File: StateConfigJoystickButton.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * When a key is pressed
 * @param key Keycode
 */
protected void onKey(int key) {
	if(frame >= KEYACCEPTFRAME) {
		// Up
		if(key == Input.KEY_UP) {
			ResourceHolderSlick.soundManager.play("cursor");
			keynum--;
			if(keynum < 4) keynum = 15;
		}
		// Down
		else if(key == Input.KEY_DOWN) {
			ResourceHolderSlick.soundManager.play("cursor");
			keynum++;
			if(keynum > 15) keynum = 4;
		}
		// Delete
		else if(key == Input.KEY_DELETE) {
			ResourceHolderSlick.soundManager.play("change");
			buttonmap[keynum] = -1;
		}
		// Backspace
		else if(key == Input.KEY_BACK) {
			gameObj.enterState(StateConfigJoystickMain.ID);
			return;
		}
		// Enter/Return
		else if(key == Input.KEY_ENTER) {
			ResourceHolderSlick.soundManager.play("decide");

			for(int i = 0; i < GameKeySlick.MAX_BUTTON; i++) {
				GameKeySlick.gamekey[player].buttonmap[i] = buttonmap[i];
			}
			GameKeySlick.gamekey[player].saveConfig(NullpoMinoSlick.propConfig);
			NullpoMinoSlick.saveConfig();

			gameObj.enterState(StateConfigJoystickMain.ID);
			return;
		}
	}
}
 
Example 5
Source File: StateConfigKeyboard.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * When a key is released
 * @param key Keycode
 */
protected void onKey(int key) {
	if(frame >= KEYACCEPTFRAME) {
		if(keyConfigRestFrame > 0) {
			// Key-set mode
			ResourceHolderSlick.soundManager.play("move");
			keymap[keynum] = key;
			keyConfigRestFrame = 0;
		} else {
			// Menu mode
			if(key == Input.KEY_UP) {
				ResourceHolderSlick.soundManager.play("cursor");
				keynum--;
				if(keynum < 0) keynum = NUM_KEYS;
			}
			if(key == Input.KEY_DOWN) {
				ResourceHolderSlick.soundManager.play("cursor");
				keynum++;
				if(keynum > NUM_KEYS) keynum = 0;
			}

			// Enter
			if(key == Input.KEY_ENTER) {
				ResourceHolderSlick.soundManager.play("decide");

				if(keynum >= NUM_KEYS) {
					// Save & Exit
					for(int i = 0; i < NUM_KEYS; i++) {
						if(!isNavSetting)
							GameKeySlick.gamekey[player].keymap[i] = keymap[i];
						else
							GameKeySlick.gamekey[player].keymapNav[i] = keymap[i];
					}
					GameKeySlick.gamekey[player].saveConfig(NullpoMinoSlick.propConfig);
					NullpoMinoSlick.saveConfig();
					gameObj.enterState(StateConfigMainMenu.ID);
				} else {
					// Set key
					keyConfigRestFrame = 60 * 5;
				}
				return;
			}

			// Delete
			if(key == Input.KEY_DELETE) {
				if((keynum < NUM_KEYS) && (keymap[keynum] != 0)) {
					ResourceHolderSlick.soundManager.play("change");
					keymap[keynum] = 0;
				}
			}

			// Backspace
			if(key == Input.KEY_BACK) {
				if(isNavSetting)
					gameObj.enterState(StateConfigKeyboardNavi.ID);
				else
					gameObj.enterState(StateConfigMainMenu.ID);
			}
		}
	}
}
 
Example 6
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;
	}
}