Class: Hemi::Render::Window
- Inherits:
-
Object
- Object
- Hemi::Render::Window
- Includes:
- Singleton
- Defined in:
- lib/hemi/render/window.rb
Constant Summary collapse
- DEFAULT_WINDOW_WIDTH =
640
- DEFAULT_WINDOW_HEIGHT =
480
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(width = DEFAULT_WINDOW_WIDTH, height = DEFAULT_WINDOW_HEIGHT) ⇒ Window
constructor
A new instance of Window.
- #renderer ⇒ Object
- #sdl_window ⇒ Object
Constructor Details
#initialize(width = DEFAULT_WINDOW_WIDTH, height = DEFAULT_WINDOW_HEIGHT) ⇒ Window
Returns a new instance of Window.
8 9 10 |
# File 'lib/hemi/render/window.rb', line 8 def initialize(width = DEFAULT_WINDOW_WIDTH, height = DEFAULT_WINDOW_HEIGHT) @size = Size.new(width: width, height: height) end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
12 13 14 |
# File 'lib/hemi/render/window.rb', line 12 def size @size end |
Class Method Details
.renderer ⇒ Object
33 34 35 |
# File 'lib/hemi/render/window.rb', line 33 def self.renderer instance.renderer end |
.wipe_screen ⇒ Object
28 29 30 31 |
# File 'lib/hemi/render/window.rb', line 28 def self.wipe_screen instance.renderer.draw_color = [0, 0, 0] instance.renderer.fill_rect(SDL2::Rect.new(0, 0, *instance.size)) end |
Instance Method Details
#renderer ⇒ Object
14 15 16 |
# File 'lib/hemi/render/window.rb', line 14 def renderer @renderer ||= sdl_window.create_renderer(-1, 0) end |
#sdl_window ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/hemi/render/window.rb', line 18 def sdl_window @sdl_window ||= SDL2::Window.create( "Hemi", SDL2::Window::POS_CENTERED, SDL2::Window::POS_CENTERED, *size, 0 ) end |