本文整理匯總了Java中org.lwjgl.input.Keyboard.isKeyDown方法的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.isKeyDown方法的具體用法?Java Keyboard.isKeyDown怎麽用?Java Keyboard.isKeyDown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.input.Keyboard
的用法示例。
在下文中一共展示了Keyboard.isKeyDown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBlockActivated
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote) {
if(playerIn.inventory.getCurrentItem().getItem() == MItems.WRENCH) {
TileEntityAccumulator tile = (TileEntityAccumulator) worldIn.getTileEntity(pos);
EnumFacing face = facing;
if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)){
face = face.getOpposite();
}
AccumulatorInfo info = tile.getInfoForFace(face);
tile.getInfoForFace(face).setIoInfo(info.getIoInfo().getNext());
tile.markDirty();
return true;
} else
playerIn.openGui(MAS.INSTANCE, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
示例2: movePosition
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
private void movePosition(){
float speed = 0;
if(Keyboard.isKeyDown(Keyboard.KEY_W)||Keyboard.isKeyDown(Keyboard.KEY_UP)){
speed = 0.05f;
}else if(Keyboard.isKeyDown(Keyboard.KEY_S)||Keyboard.isKeyDown(Keyboard.KEY_DOWN)){
speed = -0.05f;
}
center.x += speed * Math.sin(Math.toRadians(yaw));
center.y += speed * -Math.cos(Math.toRadians(yaw));
speed = 0;
if(Keyboard.isKeyDown(Keyboard.KEY_A)||Keyboard.isKeyDown(Keyboard.KEY_LEFT)){
speed = -0.05f;
}else if(Keyboard.isKeyDown(Keyboard.KEY_D)||Keyboard.isKeyDown(Keyboard.KEY_RIGHT)){
speed = 0.05f;
}
center.x += speed * Math.sin(Math.toRadians(yaw + 90));
center.y += speed * -Math.cos(Math.toRadians(yaw + 90));
}
示例3: shuffleMatrix
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
private static void shuffleMatrix(int[][] matrix){
if(Keyboard.isKeyDown(Keyboard.KEY_X)) {
for(int x = 0; x < BOARD_WIDTH; x++) {
for(int y = 0; y < BOARD_HEIGHT; y++) {
if((int) (Math.random() * 2) > 0.2 && matrix[x][y] == 0) {
matrix[x][y] = 1;
}
}
}
}
}
示例4: calculateAngleAroundPlayer
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
/**
* Calculate the angle of the camera around the player (when looking down at
* the camera from above). Basically the yaw. Changes the yaw when the user
* moves the mouse horizontally with the LMB down.
*/
private void calculateAngleAroundPlayer() {
if (Mouse.isButtonDown(0) && !Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
float angleChange = Mouse.getDX() * YAW_SENSITIVITY;
angleAroundPlayer.increaseTarget(-angleChange);
}
angleAroundPlayer.update(1f / 60);
}
示例5: drawGuiContainerForegroundLayer
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Override
protected void drawGuiContainerForegroundLayer(int mx, int my) {
if(title)
this.fontRendererObj.drawString(this.name, this.xSize / 2 - this.fontRendererObj.getStringWidth(this.name) / 2, 6, 0xa0a0a0);
GlStateManager.pushAttrib();
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture());
GlStateManager.popAttrib();
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && getShouldOutline() != null)
drawOutlines();
}
示例6: onDisable
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Override
protected void onDisable() {
if (!Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode())) {
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), false);
if (this.sneaking) {
mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.STOP_SNEAKING));
this.sneaking = false;
}
}
this.sneaking = false;
}
示例7: input
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
private void input() {
if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
paddle.setDY(-.5);
} else if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
paddle.setDY(.5);
} else {
paddle.setDY(0);
}
}
示例8: addInformation
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, World player, List<String> list, ITooltipFlag whatIsThis) {
super.addInformation(itemStack, player, list, whatIsThis);
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
list.add(TextFormatting.WHITE + "This machine cleans air");
list.add(TextFormatting.WHITE + "using power and coal or charcoal");
list.add(TextFormatting.WHITE + "Works best in closed area!");
} else {
list.add(TextFormatting.WHITE + NeedToBreathe.SHIFT_MESSAGE);
}
}
示例9: onKeyboardEvent
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@SubscribeEvent
public static void onKeyboardEvent(InputEvent.KeyInputEvent event)
{
if (ExPetrum.isDevEnvironment)
{
if (Keyboard.isKeyDown(Keyboard.KEY_F3) && Keyboard.isKeyDown(Keyboard.KEY_R))
{
EntityModelDynamic.reloadAllModels();
}
}
}
示例10: prepare
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
/**
* A few general settings. Clears the colour and depth buffer before
* rendering, turns on backface culling, enables depth testing, turns on
* antialiasing and allows for wireframe rendering if the "G" key is
* pressed. The provoking vertex convention is also set here, indicating
* that the first vertex of each triangle should be the provoking vertex.
* This is important when using the "flat" type qualifier in the shaders.
*/
private void prepare() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL32.glProvokingVertex(GL32.GL_FIRST_VERTEX_CONVENTION);
OpenGlUtils.cullBackFaces(true);
OpenGlUtils.enableDepthTesting(true);
OpenGlUtils.antialias(true);
if (Keyboard.isKeyDown(Keyboard.KEY_G)) {
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
} else {
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
}
}
示例11: isCtrlKeyDown
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
/**
* Returns true if either windows ctrl key is down or if either mac meta key is down
*/
public static boolean isCtrlKeyDown()
{
return Minecraft.isRunningOnMac ? Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220) : Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157);
}
示例12: isAltKeyDown
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
/**
* Returns true if either alt key is down
*/
public static boolean isAltKeyDown()
{
return Keyboard.isKeyDown(56) || Keyboard.isKeyDown(184);
}
示例13: render
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Override
public void render()
{
int bit = DrawingTools.drawStencil(getWidth(), getHeight());
DrawingTools.drawRectangle(0, 0, getWidth(), getHeight());
List<Entry> toRemove = new ArrayList<>();
for (int i = 0; i < cooldowns.length; i++)
if (cooldowns[i] > 0)
cooldowns[i] -= (System.currentTimeMillis() - lastms);
for (Entry entr : entries)
{
entr.range -= ((System.currentTimeMillis() - lastms) * 0.1f);
int x = 32 * entr.line;
int y = getHeight() - entr.range;
int w = 32;
int h = 20;
if (y > 0)
{
if (entr.isCompleted())
GlStateManager.color(0, 1, 0);
else
{
if (y > getHeight() - (45 + h))
{
cooldowns[entr.line] = 300;
boolean compl = Keyboard.isKeyDown(keyMap.get(entr.line));
if (compl)
{
entr.setCompleted(true);
rate++;
Minecraft.getMinecraft().player.playSound(SoundEvents.BLOCK_NOTE_SNARE, 1, 1);
}
GlStateManager.color(0, 0, 1);
}
else
GlStateManager.color(1, 0, 0);
}
GlStateManager.enableBlend();
DrawingTools.drawTexture(TEXTURE_BUTTON, x, y, w, h, 0, 0, w, h);
GlStateManager.disableBlend();
}
if (entr.range <= 0)
{
if (!entr.isCompleted())
minRate();
toRemove.add(entr);
}
}
entries.removeAll(toRemove);
GlStateManager.color(0, 0, 1);
DrawingTools.drawRectangle(0, getHeight() - 45, getWidth(), 1);
GlStateManager.color(1, 1, 1);
lastms = System.currentTimeMillis();
GlStateManager.enableBlend();
DrawingTools.drawTexture(TEXTURE_DISPLAY, 0, 0, getWidth(), getHeight());
GlStateManager.disableBlend();
if (entries.size() == 0 && getDesk().status == GuiTranslationDesk.Status.TRANSLATING)
done();
DrawingTools.removeStencil(bit);
}
示例14: isKeyDown
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
private static boolean isKeyDown(KeyBinding key) {
int i = key.getKeyCode();
return ((i != 0) && (i < 256)) ? ((i < 0) ? Mouse.isButtonDown(i + 100) : Keyboard.isKeyDown(i)) : false;
}
示例15: isKeyDown
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public static boolean isKeyDown(IKeybind bind) {
return Keyboard.isKeyDown(bind.bind.getKeyCode());
}