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


Java Key.getCharacter方法代码示例

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


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

示例1: show

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public void show() {
	_terminal.clearScreen();
	while (true) {
		Key key = _terminal.readInput();
		if (_presenter.isGameOver())
			return;
		if(key != null && key.getCharacter() == Space){
			isStoped = !isStoped;
		}
		if (key != null && key.getKind() == Kind.Escape){
			if(isStoped)_presenter.saveState();
			return;
		}
		if(!isStoped)
			_presenter.tick(convertToDirection(key));
		Sleep();
	}
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:20,代码来源:TerminalMazeView.java

示例2: show

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public void show() {
	_terminal.clearScreen();
	String[] names = { "        Game Over        ",
			"Do you want to play again?", "  Press Y to play again.",
			"  Press N or ESC to quit." };
	TerminalSize screenSize = _terminal.getTerminalSize();

	for (int i = 0; i < names.length; i++) {
		_terminal.moveCursor(screenSize.getColumns() / 2 - 15,
				screenSize.getRows() / 2 - 2 + i);
		writeLine(String.format("%s", names[i]));
	}

	_terminal.flush();
	while (true) {
		Key p = _terminal.readInput();
		if (p == null)
			continue;
		char ch = p.getCharacter();
		if (p.getKind() == Kind.Escape || ch == 'n')
			break;
		if (ch == 'y') {
			_continueGame = true;
			break;
		}
	}
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:29,代码来源:TerminalGameOverView.java

示例3: show

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public void show() {
	_terminal.clearScreen();
	String[] names = _presenter.getLevelNames();
	_lvlCount = names.length;

	for (int i = 0; i < names.length; i++) {
		_terminal.moveCursor(6, 6 + i);
		writeLine(String.format("[%1$s] - %2$s", i+1, names[i]));
	}

	_terminal.flush();

	boolean isAccepted = false;
	boolean isSelected = false;
	while (!isAccepted) {
		Key p = _terminal.readInput();
		if (p == null) continue;
		if (p.getKind() == Key.Kind.Enter && isSelected) {
			isAccepted = true;
			break;
		}
		char ch = p.getCharacter();
		if (!Character.isDigit(ch)) continue;
		int index = Character.getNumericValue(ch) - 1;
		updateIndexTracker(index);
		isSelected = _presenter.setSelection(index);
	}
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:30,代码来源:TerminalLevelView.java

示例4: getActionForKey

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	switch (k.getKind()) {
	case NormalKey: 
		switch (k.getCharacter()) {
		case ' ':
			return new GameAction(2, 1); //next page
		default:
			return new GameAction(2, 0); // do nothing
		}
	default:
		return new GameAction(2, 0); // do nothing
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:15,代码来源:InventoryLayer.java

示例5: getActionForKey

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
    switch (k.getKind()) {
    case NormalKey: {
        switch (k.getCharacter()) {
        case 'N':
            return new GameAction(1, 1); // generate new level
        case 'S':
            return new GameAction(1, 2); // save current level
        case 'L':
            return new GameAction(1, 3); // load saved level
        case 'q':
            return new GameAction(1, 4); // quit
        case 'h':
            return new GameAction(1, 5); // Move left
        case 'j':
            return new GameAction(1, 7); // Move down
        case 'k':
            return new GameAction(1, 6); // Move up
        case 'l':
            return new GameAction(1, 8); // Move right
        default:
            return new GameAction(1, 0); // do nothing
        }
    }
    case ArrowLeft:
        return new GameAction(1, 5); // Move left
    case ArrowUp:
        return new GameAction(1, 6); // Move up
    case ArrowDown:
        return new GameAction(1, 7); // Move down
    case ArrowRight:
        return new GameAction(1, 8); // Move right
    default:
        return new GameAction(1, 0); // do nothing
    }
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:38,代码来源:DemoLayer.java

示例6: getActionForKey

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	if(k.getKind() == Kind.NormalKey && k.getCharacter() == ' ') {
		return new GameAction(7,1);
	}
	else {
		app.getLayers().pop();
		Layer layerBelow = app.getLayers().peek();
		app.getLayers().push(this);
		return layerBelow.getActionForKey(k);
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:13,代码来源:AnnounceLayer.java

示例7: getActionForKey

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	if (k.getCharacter() >= 'a' && k.getCharacter() <= 'z') {
		int slot = k.getCharacter() - 'a';
		return new GameAction(2,slot); //Quaff potion in slot 
	}
	else {
		return new GameAction(2,-1); //Not valid key
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:11,代码来源:UseItemLayer.java

示例8: getActionForKey

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
public GameAction getActionForKey(Key k) {
	switch (k.getKind()) {
	case NormalKey: {
		switch (k.getCharacter()) {
		case 'h':
			return new GameAction(1, 1); // Move left
		case 'j':
			return new GameAction(1, 2); // Move down
		case 'k':
			return new GameAction(1, 3); // Move up
		case 'l':
			return new GameAction(1, 4); // Move right
		case ' ':
			return new GameAction(1, 5); // Close
		default:
			return new GameAction(1, 0); // do nothing
		}
	}
	case ArrowLeft:
		return new GameAction(1, 1); // Move left
	case ArrowDown:
		return new GameAction(1, 2); // Move down
	case ArrowUp:
		return new GameAction(1, 3); // Move up
	case ArrowRight:
		return new GameAction(1, 4); // Move right
	case Escape:
		return new GameAction(1,5); //Close
	default:
		return new GameAction(1, 0); // do nothing
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:33,代码来源:LookLayer.java

示例9: handleGlobalKeyPressed

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
public boolean handleGlobalKeyPressed(final Window sender, final Key key)
{
    if (key.getCharacter() == 'q' || key.getKind() == Kind.Escape)
    {
        shutdown();
        return true;
    }
    else if (key.getCharacter() == '?')
    {
        helpPopup.show();
        return true;
    }

    return false;
}
 
开发者ID:d0x,项目名称:nchadoop,代码行数:16,代码来源:Controller.java

示例10: onKeyPressed

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public void onKeyPressed(final Key key)
{
    if (this.controller.handleGlobalKeyPressed(this, key))
    {
        return;
    }

    if (key.getCharacter() != 'd')
    {
        super.onKeyPressed(key);
        return;
    }

    final Object selectedItem = this.directoryPanel.getListBox().getSelectedItem();

    if (selectedItem == null)
    {
        MessageBox.showMessageBox(this.gui, "Error", "No item selected.");
        return;
    }

    final Displayable displayable = (Displayable) selectedItem;

    final Object reference = displayable.getReference();

    if (reference instanceof Directory)
    {
        this.controller.deleteDiretory((Directory) reference);
    }
    else if (reference instanceof FileStatus)
    {
        this.controller.deleteFile(this.directoryPanel.getCurrentDirectory(), (FileStatus) reference);
    }
    else
    {
        MessageBox.showMessageBox(this.gui, "Error", "Can't delete this.");
    }
}
 
开发者ID:d0x,项目名称:nchadoop,代码行数:40,代码来源:MainWindow.java

示例11: keyboardInteraction

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public Result keyboardInteraction(Key key)
{
    final Displayable selectedItem = (Displayable) getSelectedItem();

    switch (key.getKind())
    {
        case Enter:
        case ArrowRight:
            selectedItem.navigate();
            return Result.EVENT_HANDLED;

        case ArrowLeft:
            selectedItem.navigateToParent();
            return Result.EVENT_HANDLED;

        default:
            break;
    }

    switch (key.getCharacter())
    {
        case 'l':
            return super.keyboardInteraction(new Key(Kind.ArrowRight));

        case 'h':
            return super.keyboardInteraction(new Key(Kind.ArrowLeft));

        case 'k':
            return super.keyboardInteraction(new Key(Kind.ArrowUp));

        case 'j':
            return super.keyboardInteraction(new Key(Kind.ArrowDown));

        default:
            break;
    }

    return super.keyboardInteraction(key);
}
 
开发者ID:d0x,项目名称:nchadoop,代码行数:41,代码来源:DirectoryListBox.java

示例12: getActionForKey

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	switch (k.getKind()) {
	case NormalKey: {
		switch (k.getCharacter()) {
		case 'N':
			return new GameAction(1, 1); // generate new level
		case 'S':
			return new GameAction(1, 2); // save current level
			// 			case 'L':
			// return new GameAction(1, 3); // load saved level
		case 'Q':
			return new GameAction(1, 4); // quit
		case 'h':
			return new GameAction(1, 5); // Move left
		case 'j':
			return new GameAction(1, 7); // Move down
		case 'k':
			return new GameAction(1, 6); // Move up
		case 'l':
			return new GameAction(1, 8); // Move right
		case 'i':
			return new GameAction(1, 9); // Open Inventory
		case 'q':
			return new GameAction(1, 10); // QuaffPotion
		case 'w':
			return new GameAction(1, 11); // Wield
		case 'o':
			return new GameAction(1, 12); // observe
		case '<':
			return new GameAction(1, 13); // up stairs
		case '>':
			return new GameAction(1, 14); // down stairs
		case 'd':
			return new GameAction(1, 15); // drop
		case '?':
			return new GameAction(1, 16); // help
		default:
			return new GameAction(1, 0); // do nothing
		}
	}
	case ArrowLeft:
		return new GameAction(1, 5); // Move left
	case ArrowUp:
		return new GameAction(1, 6); // Move up
	case ArrowDown:
		return new GameAction(1, 7); // Move down
	case ArrowRight:
		return new GameAction(1, 8); // Move right
	default:
		return new GameAction(1, 0); // do nothing
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:54,代码来源:MainLayer.java

示例13: onKeyPressed

import com.googlecode.lanterna.input.Key; //导入方法依赖的package包/类
@Override
public void onKeyPressed(Key key) {

	super.onKeyPressed(key);

	if (key.getKind() == Key.Kind.Escape) {
		askExit();
	}

	if ('s' == key.getCharacter() && key.isCtrlPressed()) scanFolder();

	if ('a' == key.getCharacter() && key.isCtrlPressed()) new AboutDialog(screen);

}
 
开发者ID:swapii,项目名称:condi,代码行数:15,代码来源:CondiWindow.java


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