ゲームのシェル出力を作成しますが、ゲーム ボードの更新ごとにウィンドウをスクロールしたくありません。どうやってするの?
Ruby での作業。
curses
アプリケーションのテキスト出力を細かく制御できますか。
以下を使用するとうまくいきます。宝石は使用しません。
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