class Core::GameWindow
Attributes
saved[RW]
state[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/game_window.rb, line 20 def initialize super(1024, 768, false) self.caption = "Essytas - v#{Core::VERSION}" Core.window = self Core.particles = Core::Parse.particles Core.animations = Core::Parse.animations @state = StartMenu.new(self) @unpress = [] @font = Core.font(Core::DEFAULT_FONT, 20) @bg = Core.sprite("pixel", true) if (Core.config[:contrast] != 1.0 and Core.config[:opengl]) @contrast = Shader.new(self, "glsl/contrast") @contrast["contrast"] = Core.config[:contrast] else @contrast = nil end end
Public Instance Methods
advance(state)
click to toggle source
Advance to the next state
Requires an EH::States::State instance
# File lib/game_window.rb, line 58 def advance(state) @state.finish @state = state end
draw()
click to toggle source
# File lib/game_window.rb, line 44 def draw @state.draw if $DEBUG @bg.draw(16, 16, 999999, 160, 48, 0x99000000) @font.draw("Mouse: #{mouse_x.to_i}|#{mouse_y.to_i}", 32, 32, 999999) end if @contrast @contrast.apply end end
load()
click to toggle source
# File lib/game_window.rb, line 70 def load @state = @saved end
pressed?(key)
click to toggle source
Checks if a specific key is pressed
Only returns true again if the key was held loose
# File lib/game_window.rb, line 76 def pressed?(key) p = button_down?(key) if p if @unpress.include?(key) p = false else @unpress.push(key) end end return p end
save()
click to toggle source
Save current state so we can go back to it later
The GameState is saved when switching to a MenuState
# File lib/game_window.rb, line 66 def save @saved = @state end
unpress()
click to toggle source
# File lib/game_window.rb, line 87 def unpress @unpress.each { |key| if !button_down?(key) @unpress.delete(key) end } end
update()
click to toggle source
# File lib/game_window.rb, line 38 def update @state.update unpress self.caption = "Essytas - v#{Core::VERSION} - #{Gosu.fps} FPS" end