當前位置: 首頁>>代碼示例>>Java>>正文


Java Input.KEY_2屬性代碼示例

本文整理匯總了Java中org.newdawn.slick.Input.KEY_2屬性的典型用法代碼示例。如果您正苦於以下問題:Java Input.KEY_2屬性的具體用法?Java Input.KEY_2怎麽用?Java Input.KEY_2使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.newdawn.slick.Input的用法示例。


在下文中一共展示了Input.KEY_2屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: keyReleased

/**
 * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char)
 */
public void keyReleased(int key, char c) {
	
	if (key == Input.KEY_2) {
		GameState target = game.getState(TestState2.ID);
		
		final long start = System.currentTimeMillis();
		CrossStateTransition t = new CrossStateTransition(target) {				
			public boolean isComplete() {
				return (System.currentTimeMillis() - start) > 2000;
			}

			public void init(GameState firstState, GameState secondState) {
			}
		};
		
		game.enterState(TestState2.ID, t, new EmptyTransition());
	}
	if (key == Input.KEY_3) {
		game.enterState(TestState3.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:24,代碼來源:TestState1.java

示例2: keyReleased

/**
 * @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));
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:23,代碼來源:TestState3.java

示例3: keyPressed

/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	if (key == Input.KEY_1) {
		world = false;
		clip = false;
	}
	if (key == Input.KEY_2) {
		world = false;
		clip = true;
	}
	if (key == Input.KEY_3) {
		world = true;
		clip = false;
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:17,代碼來源:ClipTest.java

示例4: setControlKeys

private void setControlKeys() {
    if(this instanceof PacMan) {
        comands[0] = Input.KEY_UP;
        comands[1] = Input.KEY_DOWN;
        comands[2] = Input.KEY_LEFT;
        comands[3] = Input.KEY_RIGHT;
    }
    
    if(this instanceof Blinky) {
        comands[0] = Input.KEY_W;
        comands[1] = Input.KEY_S;
        comands[2] = Input.KEY_A;
        comands[3] = Input.KEY_D;
    }
    
    if(this instanceof Clyde) {
        comands[0] = Input.KEY_T;
        comands[1] = Input.KEY_G;
        comands[2] = Input.KEY_F;
        comands[3] = Input.KEY_H;
    }
    
    if(this instanceof Inky) {
        comands[0] = Input.KEY_I;
        comands[1] = Input.KEY_K;
        comands[2] = Input.KEY_J;
        comands[3] = Input.KEY_L;
    }
    
    if(this instanceof Pinky) {
        comands[0] = Input.KEY_5;
        comands[1] = Input.KEY_2;
        comands[2] = Input.KEY_1;
        comands[3] = Input.KEY_3;
    }
        
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:37,代碼來源:Character.java

示例5: update

@Override
public void update(GameState gs, long cTime, int delta) {
	// Make sure player's health is up to date.
	double currentMax = getDoubleAttribute("maxHealth");
	double healthBonus = getIntAttribute("healthUp") * HEALTH_PER_SP;
	if(currentMax != (DEFAULT_MAX_HEALTH + healthBonus)) {
		// Update player's max health.
		setAttribute("maxHealth", (DEFAULT_MAX_HEALTH + healthBonus));
	}
	
	// Need to make sure to update the status effects first.
	Iterator<StatusEffect> it = statusEffects.iterator();
	while(it.hasNext()) {
		StatusEffect status = (StatusEffect) it.next();
		if(status.isActive(cTime)) {
			status.update(this, cTime);
		} else {
			status.onDestroy(this, cTime);
			it.remove();
		}
	}
	
	float adjSpeed = (getSpeed() + (getIntAttribute("speedUp") * (DEFAULT_SPEED * 0.10f))) * (float)getDoubleAttribute("spdMult") * delta;
	if(Globals.inputs.contains(Input.KEY_W)) move(0.0f, -adjSpeed);
	if(Globals.inputs.contains(Input.KEY_A)) move(-adjSpeed, 0.0f);
	if(Globals.inputs.contains(Input.KEY_S)) move(0.0f, adjSpeed);
	if(Globals.inputs.contains(Input.KEY_D)) move(adjSpeed, 0.0f);
	if(Globals.inputs.contains(Input.KEY_R) && 
	   !getCurrentWeapon().isReloading(cTime) &&
	   (getCurrentWeapon().getClipAmmo() != getCurrentWeapon().getClipSize())) {
		getCurrentWeapon().reload(cTime);
	}
	bounds.setLocation((position.x - (getImage().getWidth() / 2)), (position.y - (getImage().getHeight() / 2)));
	
	// Check to see if the player is trying to change weapon by number.
	int [] codes = new int[] { Input.KEY_0, Input.KEY_1, Input.KEY_2, Input.KEY_3, Input.KEY_4,
							   Input.KEY_5, Input.KEY_6, Input.KEY_7, Input.KEY_8, Input.KEY_9 };
	for(int i = 0; i < 10; i++) {
		if(Globals.inputs.contains(codes[i])) {
			if(i == 0) setCurrentWeapon(9);
			else setCurrentWeapon(i - 1);
			break; // To avoid conflicts when holding multiple numerical keys.
		}
	}
	
	Weapon cWeapon = getCurrentWeapon();
	if((Globals.mouse.isMouseDown() || cWeapon.isChargedWeapon()) && cWeapon.canFire(cTime)) {
		cWeapon.fire(this, new Pair<Float>(position.x, position.y), 
					 theta, cTime);
	}
	
	// Update all the player's active weapons.
	getActiveWeapons().stream().forEach(w -> w.update(gs, cTime, delta));
	
	// Calculate the player's rotation based on mouse position.
	theta = Calculate.Hypotenuse(position, Globals.mouse.getPosition()) + (float)(Math.PI / 2);
	flashlight.update(this, cTime);
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:58,代碼來源:Player.java


注:本文中的org.newdawn.slick.Input.KEY_2屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。