Class: Badline::GUI::Application
- Inherits:
-
Object
- Object
- Badline::GUI::Application
- Defined in:
- lib/badline/gui/application.rb
Constant Summary collapse
- PAL_CLOCK_HZ =
985_248- TITLE =
"Badline"- TOGGLE_SYM =
SDL2::Key::TAB
- SHARED_KEYS =
%i[up left cursor_h cursor_v space].freeze
Instance Method Summary collapse
-
#initialize(media_path: nil, autostart: true, debug: false) ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
Constructor Details
#initialize(media_path: nil, autostart: true, debug: false) ⇒ Application
Returns a new instance of Application.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/badline/gui/application.rb', line 12 def initialize(media_path: nil, autostart: true, debug: false) @computer = Computer.new(debug:) puts Media.attach(@computer, media_path, autostart:) if media_path @joystick_mode = false @panes = [ScreenPane.new(@computer)] @window = Window.new( title: TITLE, width: canvas_width, height: canvas_height, vsync: ENV["NOVSYNC"].nil? ) rate = @window.refresh_rate @cycles_per_frame = PAL_CLOCK_HZ / rate puts "Display #{rate} Hz -> #{@cycles_per_frame} cycles/frame" end |
Instance Method Details
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/badline/gui/application.rb', line 29 def run @running = true while @running handle_events @cycles_per_frame.times { @computer.cycle! } @window.draw(@panes) end ensure puts @computer.cpu.inspect end |