1

ゲームのシェル出力を作成しますが、ゲーム ボードの更新ごとにウィンドウをスクロールしたくありません。どうやってするの?

Ruby での作業。

4

2 に答える 2

4

cursesアプリケーションのテキスト出力を細かく制御できますか。

于 2013-01-11T22:10:15.543 に答える
0

以下を使用するとうまくいきます。宝石は使用しません。

require "curses"
include Curses

class Display
  def self.show board
    win = Window.new(20, 200, 0, 0) # 20 lines x 200 chars
    win.addstr board
    win.refresh
    win.close
  end

  def self.initialize
    crmode
    curs_set 0 # Hide cursor
    init_screen
  end
end

使い方:

Display.initialize

while true do
  Display.show board
  board.update # Or whatever the game needs to do...
end

参考:http ://www.ruby-doc.org/stdlib-1.9.3/libdoc/curses/rdoc/Curses.html

于 2013-01-13T02:37:48.473 に答える