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


Java Screen.refresh方法代码示例

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


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

示例1: main

import com.googlecode.lanterna.screen.Screen; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
    SwingTerminalFrame terminal = new SwingTerminalFrame(SwingTerminalFrame.AutoCloseTrigger.CloseOnExitPrivateMode);
    terminal.setCursorVisible(false);

    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();
    
    terminal.setTitle("Freedom: An arena-battle roguelike");
    terminal.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    terminal.setResizable(false);
    terminal.setVisible(true);

    while(screen.pollInput() == null) {
        if(screen.doResizeIfNecessary() != null) {
            screen.refresh();
        }
        Thread.sleep(100);
    }
    screen.stopScreen();
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:21,代码来源:Issue95.java

示例2: doStartup

import com.googlecode.lanterna.screen.Screen; //导入方法依赖的package包/类
/**
   * Contains the main event loop that drives the game. This method will not 
   * return until {@link LanternaFrontend#shutdown} is called.
   */
  final void doStartup() {
Vec2i screenSize = getSize();
if (isTTY) System.out.print("\033[8;" + screenSize.y + ";" + screenSize.x + "t");
      Screen screen = TerminalFacade.createScreen();
      screen.startScreen();
      {
          TerminalSize size = screen.getTerminalSize();
          //onResize(new Vec2i(size.getColumns(),size.getRows()));
          onResize(screenSize);
      }


      long time = new Date().getTime();
      while (running) {
	try {
		// First do anything that we need to do for updating screen size.
		/* if (screen.resizePending()) {
			screen.refresh();
			TerminalSize size = screen.getTerminalSize();
			onResize(new Vec2i(size.getColumns(),size.getRows()));
		} */

		// First do anything that we need to do for updating screen size.
		// Then we draw the screen.
		screen.clear();
		onDraw(new Section(screen, new Vec2i(0,0), screenSize));
		screen.refresh();

		// We can now give the program any key presses
		Key key = screen.readInput();
		if (key != null)
			onKeyPressed(key);

		// Then we take care of ticks.
		long currentTime = new Date().getTime();
		onTick(currentTime - time);
		time = currentTime;
	} catch (NullPointerException e) {
		// For now, ignore it.
	}
      }
      screen.stopScreen();
  }
 
开发者ID:melloc,项目名称:roguelike,代码行数:48,代码来源:LanternaFrontend.java


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