Class: GamesAndRpgParadise::GUI::Gtk::Paddle

Inherits:
Object
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb

Constant Summary collapse

WIDTH =
#

WIDTH

#
95

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Paddle

#

initialize

#


32
33
34
35
36
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 32

def initialize(x, y)
  @x = x
  @y = y
  reset
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



22
23
24
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 22

def height
  @height
end

#widthObject

Returns the value of attribute width.



21
22
23
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 21

def width
  @width
end

#xObject

Returns the value of attribute x.



19
20
21
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 19

def x
  @x
end

#yObject

Returns the value of attribute y.



20
21
22
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 20

def y
  @y
end

Instance Method Details

#drawObject

#

draw

#


67
68
69
70
71
72
73
74
75
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 67

def draw
  Nyle.draw_rect(
    @x,
    @y,
    @width,
    @height,
    **{color: :WHITE, fill: true}
  )
end

#resetObject

#

reset

#


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 41

def reset 
  # reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, inspect]
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  @height = 20
end

#update(mx, my) ⇒ Object

#

update

#


60
61
62
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/paddle.rb', line 60

def update(mx, my)
  @x = mx - @width / 2
end