当前位置: 首页>>代码示例>>Java>>正文


Java Keyboard.next方法代码示例

本文整理汇总了Java中org.lwjgl.input.Keyboard.next方法的典型用法代码示例。如果您正苦于以下问题:Java Keyboard.next方法的具体用法?Java Keyboard.next怎么用?Java Keyboard.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.input.Keyboard的用法示例。


在下文中一共展示了Keyboard.next方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleInput

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
/**
 * Delegates mouse and keyboard input.
 */
public void handleInput() throws IOException
{
    if (Mouse.isCreated())
    {
        while (Mouse.next())
        {
            this.handleMouseInput();
        }
    }

    if (Keyboard.isCreated())
    {
        while (Keyboard.next())
        {
            this.handleKeyboardInput();
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:22,代码来源:GuiScreen.java

示例2: handleInput

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
/**
 * Delegates mouse and keyboard input.
 */
public void handleInput() throws IOException
{
    if (Mouse.isCreated())
    {
        while (Mouse.next())
        {
            if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Pre(this))) continue;
            this.handleMouseInput();
            if (this.equals(this.mc.currentScreen)) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Post(this));
        }
    }

    if (Keyboard.isCreated())
    {
        while (Keyboard.next())
        {
            if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Pre(this))) continue;
            this.handleKeyboardInput();
            if (this.equals(this.mc.currentScreen)) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Post(this));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:GuiScreen.java

示例3: update

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
/**
 * Game loop update
 */
public void update() {
	while (Keyboard.next()) {
		if (Keyboard.getEventKeyState()) {
			if (Keyboard.getEventKey() == Keyboard.KEY_Q) {
				// play as a one off sound effect
				oggEffect.playAsSoundEffect(1.0f, 1.0f, false);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_W) {
				// replace the music thats curretly playing with 
				// the ogg
				oggStream.playAsMusic(1.0f, 1.0f, true);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_E) {
				// replace the music thats curretly playing with 
				// the mod
				modStream.playAsMusic(1.0f, 1.0f, true);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_R) {
				// play as a one off sound effect
				aifEffect.playAsSoundEffect(1.0f, 1.0f, false);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_T) {
				// play as a one off sound effect
				wavEffect.playAsSoundEffect(1.0f, 1.0f, false);
			}
		}
	}
	
	// polling is required to allow streaming to get a chance to
	// queue buffers.
	SoundStore.get().poll(0);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:36,代码来源:TestUtils.java

示例4: input

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
private void input() {
	int mousex = Mouse.getX();
	int mousey = 480 - Mouse.getY() - 1;
	boolean mouseClicked = Mouse.isButtonDown(0);
	
	
	if (mouseClicked) {
		int grid_x = Math.round(mousex / World.BLOCK_SIZE);
		int grid_y = Math.round(mousey / World.BLOCK_SIZE);
		bt = getBT(bt);
		grid.setAt(grid_x, grid_y, bt);
	}
	while (Keyboard.next()) {
		if (Keyboard.getEventKey() == Keyboard.KEY_S) {
			grid.save(new File("save.xml"));
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_L) {
			grid.load(new File("save.xml"));
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_SPACE) {
			if (bt == DIRT) {
				setBT(GRASS);
			} else if (bt == GRASS) {
				setBT(STONE);
			} else if (bt == STONE) {
				setBT(AIR);
			} else if (bt == AIR) {
				setBT(DIRT);
			}
		}
	}
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:33,代码来源:AltBoot.java

示例5: main

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
public static void main(String[] args) throws FileNotFoundException {
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("OpenAL Demo");
        Display.create();
        AL.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        Display.destroy();
        AL.destroy();
        System.exit(1);
    }
    WaveData data = WaveData.create(new BufferedInputStream(new FileInputStream("res" + File.separatorChar +
            "sounds" + File.separatorChar + "thump.wav")));
    int buffer = alGenBuffers();
    alBufferData(buffer, data.format, data.data, data.samplerate);
    data.dispose();
    int source = alGenSources();
    alSourcei(source, AL_BUFFER, buffer);
    while (!Display.isCloseRequested()) {
        while (Keyboard.next()) {
            if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
                alSourcePlay(source);
            }
        }
        Display.update();
        Display.sync(60);
    }
    alDeleteBuffers(buffer);
    AL.destroy();
    Display.destroy();
    System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:34,代码来源:OpenALDemo.java

示例6: update

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
public void update() {
	
	// Update holding tower
	if (holdingTower){
		tempTower.setX(getMouseTile().getX());
		tempTower.setY(getMouseTile().getY());
		tempTower.draw();
	}
	
	// Update all towers in the game
	for (Tower t : towerList){
		t.update();
		t.draw();
		t.updateEnemyList(waveManager.getCurrentWave().getEnemyList());
	}
	
	// Mouse Input
	if (Mouse.isButtonDown(0) && !leftMouseButtonDown)
		placeTower();
	if (Mouse.isButtonDown(1) && !rightMouseButtonDown)
		if (holdingTower)
			unpickTower();
		
	leftMouseButtonDown = Mouse.isButtonDown(0);
	rightMouseButtonDown = Mouse.isButtonDown(1);
	
	// Keyboard Input - Broken mechanics :/
	while (Keyboard.next()){
		if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()){
			Clock.ChangeMulitplier(0.2f);
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.getEventKeyState()){
			Clock.ChangeMulitplier(-0.2f);
		}
	}		
}
 
开发者ID:imaTowan,项目名称:Towan,代码行数:37,代码来源:Player.java

示例7: handleInput

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
public void handleInput()
{
    for(; Mouse.next(); handleMouseInput()) { }
    for(; Keyboard.next(); handleKeyboardInput()) { }
}
 
开发者ID:jd-lang,项目名称:betaexpansion,代码行数:6,代码来源:GuiScreen.java

示例8: input

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
private void input() {
	if (mouseEnabled || Mouse.isButtonDown(0)) {
		mouseEnabled = true;
		int mousex = Mouse.getX();
		int mousey = 480 - Mouse.getY() - 1;
		boolean mouseClicked = Mouse.isButtonDown(0);
		selector_x = Math.round(mousex / World.BLOCK_SIZE);
		selector_y = Math.round(mousey / World.BLOCK_SIZE);
		if (mouseClicked) {
			grid.setAt(selector_x, selector_y, selection);
		}
	}
	
	while (Keyboard.next()) {
		if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()) {
			if (!(selector_x + 1 > World.BLOCKS_WIDTH - 2)) {
				mouseEnabled = false;
				selector_x++;
			}
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.getEventKeyState()) {
			if (!(selector_x - 1 < 0)) {
				mouseEnabled = false;
				selector_x--;
			}
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_UP && Keyboard.getEventKeyState()) {
			if (!(selector_y - 1 < 0)) {
				mouseEnabled = false;
				selector_y--;
			}
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_DOWN && Keyboard.getEventKeyState()) {
			if (!(selector_y + 1 > World.BLOCKS_HEIGHT - 2)) {
				mouseEnabled = false;
				selector_y++;
			}
		}
		
		if (Keyboard.getEventKey() == Keyboard.KEY_S) {
			grid.save(new File("save.xml"));
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_L) {
			grid.load(new File("save.xml"));
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_1) {
			selection = BlockType.STONE;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_2) {
			selection = BlockType.DIRT;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_3) {
			selection = BlockType.GRASS;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_4) {
			selection = BlockType.AIR;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_C) {
			grid.clear();
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_SPACE) {
			grid.setAt(selector_x, selector_y, selection);
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
			Display.destroy();
			System.exit(0);
		}
	}
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:70,代码来源:Boot.java

示例9: SmoothTransitions

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
private SmoothTransitions() {
       // Of course, the default State is INTRO.
       State state = State.INTRO;
	try {
           Display.setDisplayMode(new DisplayMode(640, 480));
           Display.setTitle("LWJGL Template");
           Display.setVSyncEnabled(true); // prevents tearing and choppy animation??
           Display.create();
       } catch (LWJGLException e) {
           System.err.println("Display failed to initialize.");
           System.exit(1);
       }
       
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(1, 1, 1, 1, 1, -1);
       glMatrixMode(GL_MODELVIEW);
       glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	// Fade in degrees (0 to 90)
	float fade = 0f;
	
	while (!Display.isCloseRequested()) {
		// Clear
		glClear(GL_COLOR_BUFFER_BIT);
		
		switch(state) {
			case FADING:
				if (fade < 90) {
					fade += 1.5f;
				} else {
					fade = 0;
					glColor3f(0.5f, 0.5f, 1);
					glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
					state = State.MAIN;
					System.out.println("State changed: " + state);
					break;
				}
				// Opacity = sin(fade)
				glColor4d(0.5, 0.5, 1f, Math.sin(Math.toRadians(fade)));
				// Draws rectangle
				glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
				break;
			case INTRO:
				break;
			case MAIN:
				// Draw the fully opaque rectangle
				glColor3f(0.5f, 0.5f, 1);
				glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
				break;
		}
		
		while (Keyboard.next()) {
			if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) {
				switch (state) {
					case FADING:
						fade = 0;
						state = State.MAIN;
						System.out.println("State changed: " + state);
						break;
					case INTRO:
						state = State.FADING;
						System.out.println("State changed: " + state);
						break;
					case MAIN:
						state = State.INTRO;
						System.out.println("State changed: " + state);
						break;
				}
			}
		}
		Display.update();
		Display.sync(60);
	}
	Display.destroy();
	System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:79,代码来源:SmoothTransitions.java

示例10: update

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
public void update() {
	draw();
	editorUI.drawString(WIDTH + 3, HEIGHT / 2, "Press 's' to");
	editorUI.drawString(WIDTH + 3, HEIGHT / 2 + 20, "save this");
	editorUI.drawString(WIDTH + 3, HEIGHT / 2 + 40, "map!");
	editorUI.drawString(WIDTH + 3, HEIGHT / 2 + 80, "Press 'm' to");
	editorUI.drawString(WIDTH + 3, HEIGHT / 2 + 100, "return to");
	editorUI.drawString(WIDTH + 3, HEIGHT / 2 + 120, "the menu!");
	
	// Mouse Input
	if (Mouse.next()){
		boolean mouseClicked = Mouse.isButtonDown(0);
		if (mouseClicked) {
			if (tilePickerMenu.isButtonClicked("Grass")) {
				index = 0;
			} else if (tilePickerMenu.isButtonClicked("Dirt")){
				index = 1;
			} else if (tilePickerMenu.isButtonClicked("Water")) {
				index = 2;
			} else if (tilePickerMenu.isButtonClicked("DirtStone")) {
				index = 3;
			} else if (tilePickerMenu.isButtonClicked("StoneFloor")) {
				index = 4;
			} else if (tilePickerMenu.isButtonClicked("Sand")) {
				index = 5;
			} else if (tilePickerMenu.isButtonClicked("Crystal")) {
				index = 6;
			} else {
				if (Mouse.getX() < WIDTH)
					setTile();
			}
		}
	}

	// Keyboard Input
	while (Keyboard.next()) {
		if (Keyboard.getEventKey() == Keyboard.KEY_S && Keyboard.getEventKeyState()) {
			SaveMap(MAP_NAME, grid);
			StateManager.checkMap = 0;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_M && Keyboard.getEventKeyState()) {
			StateManager.setState(GameState.MAINMENU);
		}
	}
}
 
开发者ID:imaTowan,项目名称:Towan,代码行数:46,代码来源:Editor.java


注:本文中的org.lwjgl.input.Keyboard.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。