Class: HudImage
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#layer ⇒ Object
Returns the value of attribute layer.
-
#name ⇒ Object
Returns the value of attribute name.
-
#position ⇒ Object
Returns the value of attribute position.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#visible ⇒ Object
Returns the value of attribute visible.
Instance Method Summary collapse
- #destroy ⇒ Object
- #draw ⇒ Object
- #draw_debug ⇒ Object
- #height ⇒ Object
-
#initialize(position:, image_name:) ⇒ HudImage
constructor
A new instance of HudImage.
- #move ⇒ Object
- #width ⇒ Object
Methods included from Draggable
Constructor Details
#initialize(position:, image_name:) ⇒ HudImage
Returns a new instance of HudImage.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fantasy/hud_image.rb', line 8 def initialize(position:, image_name:) @image = Image.new(image_name) @name = image_name @position = position @scale = 1 @visible = true @draggable_on_debug = true @dragging = false @layer = 100 Global.hud_images.push(self) end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
6 7 8 |
# File 'lib/fantasy/hud_image.rb', line 6 def color @color end |
#layer ⇒ Object
Returns the value of attribute layer.
6 7 8 |
# File 'lib/fantasy/hud_image.rb', line 6 def layer @layer end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/fantasy/hud_image.rb', line 6 def name @name end |
#position ⇒ Object
Returns the value of attribute position.
6 7 8 |
# File 'lib/fantasy/hud_image.rb', line 6 def position @position end |
#scale ⇒ Object
Returns the value of attribute scale.
6 7 8 |
# File 'lib/fantasy/hud_image.rb', line 6 def scale @scale end |
#visible ⇒ Object
Returns the value of attribute visible.
6 7 8 |
# File 'lib/fantasy/hud_image.rb', line 6 def visible @visible end |
Instance Method Details
#destroy ⇒ Object
45 46 47 |
# File 'lib/fantasy/hud_image.rb', line 45 def destroy Global.hud_images.delete(self) end |
#draw ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/fantasy/hud_image.rb', line 33 def draw if visible @image.draw(x: @position.x, y: @position.y, scale: @scale) end draw_debug if Global.debug end |
#draw_debug ⇒ Object
41 42 43 |
# File 'lib/fantasy/hud_image.rb', line 41 def draw_debug Global.pixel_fonts["medium"].draw_text("#{@position.x.floor},#{@position.y.floor}", @position.x, @position.y - 20, 1) end |
#height ⇒ Object
25 26 27 |
# File 'lib/fantasy/hud_image.rb', line 25 def height @image.height * @scale end |
#move ⇒ Object
29 30 31 |
# File 'lib/fantasy/hud_image.rb', line 29 def move drag if Global.debug end |
#width ⇒ Object
21 22 23 |
# File 'lib/fantasy/hud_image.rb', line 21 def width @image.width * @scale end |