class CyberarmEngine::Window
Constants
- IMAGES
- SAMPLES
- SONGS
Attributes
exit_on_opengl_error[W]
last_frame_time[R]
show_cursor[RW]
Public Class Methods
dt()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 17 def self.dt $window.last_frame_time / 1000.0 end
new(width: 800, height: 600, fullscreen: false, update_interval: 1000.0 / 60, resizable: false, borderless: false)
click to toggle source
Calls superclass method
# File lib/cyberarm_engine/window.rb, line 21 def initialize(width: 800, height: 600, fullscreen: false, update_interval: 1000.0 / 60, resizable: false, borderless: false) @show_cursor = false super(width, height, fullscreen: fullscreen, update_interval: update_interval, resizable: resizable, borderless: borderless) $window = self @last_frame_time = Gosu.milliseconds - 1 @current_frame_time = Gosu.milliseconds self.caption = "CyberarmEngine #{CyberarmEngine::VERSION} #{Gosu.language}" @states = [] @exit_on_opengl_error = false setup if defined?(setup) end
now()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 13 def self.now Gosu.milliseconds end
Public Instance Methods
aspect_ratio()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 56 def aspect_ratio width / height.to_f end
current_state()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 93 def current_state @states.last end
draw()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 36 def draw current_state.draw if current_state end
draw_circle(cx, cy, r, z = 9999, color = Gosu::Color::GREEN, step = 10)
click to toggle source
Sourced from gist.github.com/ippa/662583
# File lib/cyberarm_engine/window.rb, line 112 def draw_circle(cx, cy, r, z = 9999, color = Gosu::Color::GREEN, step = 10) 0.step(360, step) do |a1| a2 = a1 + step draw_line(cx + Gosu.offset_x(a1, r), cy + Gosu.offset_y(a1, r), color, cx + Gosu.offset_x(a2, r), cy + Gosu.offset_y(a2, r), color, z) end end
dt()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 52 def dt @last_frame_time / 1000.0 end
exit_on_opengl_error?()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 60 def exit_on_opengl_error? @exit_on_opengl_error end
needs_cursor?()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 48 def needs_cursor? @show_cursor end
pop_state()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 103 def pop_state @states.pop end
previous_state()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 97 def previous_state if @states.size > 1 && (state = @states[@states.size - 2]) state end end
push_state(klass, options = {})
click to toggle source
# File lib/cyberarm_engine/window.rb, line 74 def push_state(klass, options = {}) options = { setup: true }.merge(options) if klass.instance_of?(klass.class) && defined?(klass.options) @states << klass klass.setup if options[:setup] klass.post_setup if options[:setup] else @states << klass.new(options) if child_of?(klass, GameState) @states << klass.new if child_of?(klass, Element::Container) current_state.setup if current_state.instance_of?(klass) && options[:setup] current_state.post_setup if current_state.instance_of?(klass) && options[:setup] end end
shift_state()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 107 def shift_state @states.shift end
update()
click to toggle source
# File lib/cyberarm_engine/window.rb, line 40 def update Stats.clear current_state.update if current_state @last_frame_time = Gosu.milliseconds - @current_frame_time @current_frame_time = Gosu.milliseconds end
Private Instance Methods
child_of?(input, klass)
click to toggle source
# File lib/cyberarm_engine/window.rb, line 89 def child_of?(input, klass) input.ancestors.detect { |c| c == klass } end