Class: Termfront::TitleScreen
- Inherits:
-
Object
- Object
- Termfront::TitleScreen
- Defined in:
- lib/termfront/title_screen.rb
Constant Summary collapse
- DEMO_WAYPOINTS =
[ [2.5, 5.0], [7.0, 2.5], [11.0, 3.5], [13.0, 5.0], [13.0, 8.0], [10.0, 8.5], [5.0, 8.5], [2.5, 5.0] ].freeze
Instance Method Summary collapse
-
#initialize(stdout) ⇒ TitleScreen
constructor
A new instance of TitleScreen.
- #show ⇒ Object
Constructor Details
#initialize(stdout) ⇒ TitleScreen
Returns a new instance of TitleScreen.
10 11 12 13 14 15 16 |
# File 'lib/termfront/title_screen.rb', line 10 def initialize(stdout) @stdout = stdout @title_spin = 0.0 @demo_wp_idx = 0 @demo_wp_t = 0.0 @demo_fire = 0 end |
Instance Method Details
#show ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/termfront/title_screen.rb', line 18 def show @title_spin = 0.0 @demo_wp_idx = 0 @demo_wp_t = 0.0 @demo_fire = 0 TerminalOutput.write_all(@stdout, TerminalOutput.begin_frame(home: true, clear: true) + TerminalOutput.end_frame) STDIN.raw do |stdin| loop do now = clock @title_spin += 0.015 render while IO.select([stdin], nil, nil, 0) begin ch = stdin.read_nonblock(64) ch.each_byte do |b| case b when 102, 70 then return :wavesfight when 115, 83 then return :singleplayer when 99, 67 then return :campaign when 112, 80 then return :pvp when 113, 81, 27 then return :quit end end rescue IO::WaitReadable break end end spent = clock - now remain = Config::FRAME_DT - spent sleep(remain) if remain > 0 end end end |