Class: GamesAndRpgParadise::GUI::Gtk::Screen

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

Instance Method Summary collapse

Constructor Details

#initialize(use_this_as_background_colour = :BLACK) ⇒ Screen

#

initialize

#


29
30
31
32
33
34
35
36
37
38
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/screen.rb', line 29

def initialize(
    use_this_as_background_colour = :BLACK
  )
  super(
    680,
    480,
    **{ bgcolor: use_this_as_background_colour }
  )
  reset
end

Instance Method Details

#drawObject

#

draw

#


69
70
71
72
73
74
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/screen.rb', line 69

def draw
  @blocks.draw
  @walls.draw
  @paddle.draw
  @ball.draw
end

#resetObject

#

reset

#


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/screen.rb', line 43

def reset
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, inspect]
  # ======================================================================= #
  # === @blocks
  # ======================================================================= #
  @blocks = Blocks.new
  # ======================================================================= #
  # === @walls
  # ======================================================================= #
  @walls  = Walls.new
  # ======================================================================= #
  # === @paddle
  # ======================================================================= #
  @paddle = Paddle.new(0, 460)
  # ======================================================================= #
  # === @ball
  # ======================================================================= #
  @ball   = Ball.new(300, 400)
end

#updateObject

#

update

#


79
80
81
82
83
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/screen.rb', line 79

def update
  @paddle.update(Nyle.mouse_x, Nyle.mouse_y)
  @ball.update(@walls, @blocks, @paddle)
  Nyle.quit if Nyle.key_press?(KEY_Escape)
end