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


Java Keyboard.isKeyDown方法代碼示例

本文整理匯總了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;
}
 
開發者ID:jaredlll08,項目名稱:Machines-and-Stuff,代碼行數:19,代碼來源:BlockAccumulator.java

示例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));
}
 
開發者ID:TheThinMatrix,項目名稱:OcclusionQueries,代碼行數:19,代碼來源:Camera.java

示例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;
				}
			}
		}
	}
}
 
開發者ID:marcioz98,項目名稱:MRCEngine,代碼行數:12,代碼來源:GameOfLifeTest.java

示例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);
}
 
開發者ID:GryPLOfficial,項目名稱:EcoSystem-Official,代碼行數:13,代碼來源:Camera.java

示例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();
}
 
開發者ID:jaredlll08,項目名稱:Machines-and-Stuff,代碼行數:15,代碼來源:GuiBase.java

示例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;
}
 
開發者ID:SerenityEnterprises,項目名稱:SerenityCE,代碼行數:13,代碼來源:Sneak.java

示例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);
	}
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:10,代碼來源:PongGame.java

示例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);
    }
}
 
開發者ID:McJty,項目名稱:needtobreath,代碼行數:14,代碼來源:PurifierBlock.java

示例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();
        }
    }
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:12,代碼來源:ExPHandlerClient.java

示例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);
	}
}
 
開發者ID:TheThinMatrix,項目名稱:LowPolyTerrain,代碼行數:21,代碼來源:RenderEngine.java

示例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);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:8,代碼來源:GuiScreen.java

示例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);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:8,代碼來源:GuiScreen.java

示例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);
}
 
開發者ID:PearXTeam,項目名稱:PurificatiMagicae,代碼行數:65,代碼來源:GuiTranslationDeskPanel.java

示例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;
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:5,代碼來源:GuiWheel.java

示例15: isKeyDown

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public static boolean isKeyDown(IKeybind bind) {
	return Keyboard.isKeyDown(bind.bind.getKeyCode());
}
 
開發者ID:Moudoux,項目名稱:EMC,代碼行數:4,代碼來源:IKeybindWrapper.java


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