Class: EhbGameLib::Window

Inherits:
Chingu::Window
  • Object
show all
Defined in:
lib/ehb_game_lib/window.rb

Defined Under Namespace

Classes: GlReadPixelsImage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(canvas_width, canvas_height) ⇒ Window

Returns a new instance of Window.



11
12
13
14
15
16
17
# File 'lib/ehb_game_lib/window.rb', line 11

def initialize(canvas_width, canvas_height)
  @canvas = ::EhbGameLib::Canvas.new(canvas_width, canvas_height)
  @canvas_factor = 1
  self.fit_canvas_to_window = true
  self.draw_retro = true
  super calculated_width, calculated_height
end

Instance Attribute Details

#canvasObject (readonly)

Returns the value of attribute canvas.



9
10
11
# File 'lib/ehb_game_lib/window.rb', line 9

def canvas
  @canvas
end

#canvas_factorObject

Returns the value of attribute canvas_factor.



9
10
11
# File 'lib/ehb_game_lib/window.rb', line 9

def canvas_factor
  @canvas_factor
end

#draw_retroObject

Returns the value of attribute draw_retro.



8
9
10
# File 'lib/ehb_game_lib/window.rb', line 8

def draw_retro
  @draw_retro
end

#fit_canvas_to_windowObject

Returns the value of attribute fit_canvas_to_window.



8
9
10
# File 'lib/ehb_game_lib/window.rb', line 8

def fit_canvas_to_window
  @fit_canvas_to_window
end

Instance Method Details

#calculated_heightObject



23
24
25
# File 'lib/ehb_game_lib/window.rb', line 23

def calculated_height
  canvas.height * canvas_factor
end

#calculated_widthObject



19
20
21
# File 'lib/ehb_game_lib/window.rb', line 19

def calculated_width
  canvas.width * canvas_factor
end

#drawObject



33
34
35
# File 'lib/ehb_game_lib/window.rb', line 33

def draw
  super if ::EhbGameLib::Globals.window
end

#draw_resizedObject



37
38
39
40
41
42
# File 'lib/ehb_game_lib/window.rb', line 37

def draw_resized
  return unless fit_canvas_to_window

  ::Gosu::Image.new(canvas_image_source, retro: draw_retro)
               .draw(0, 0, 100, canvas_factor, canvas_factor)
end