Class: Gtk::Games::Tetris
- Inherits:
-
HBox
- Object
- HBox
- Gtk::Games::Tetris
- Includes:
- BaseModule
- Defined in:
- lib/games_paradise/tetris/gtk2/tetris.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
Instance Method Summary collapse
-
#connect_skeleton ⇒ Object
# === connect_skeleton ========================================================================= #.
-
#draw_shapes(cairo_context) ⇒ Object
# === draw_shapes ========================================================================= #.
-
#favicon? ⇒ Boolean
# === favicon? ========================================================================= #.
-
#initialize ⇒ Tetris
constructor
# === initialize ========================================================================= #.
-
#initialize_the_drawing_area ⇒ Object
# === initialize_the_drawing_area ========================================================================= #.
-
#on_draw ⇒ Object
# === on_draw.
-
#reset ⇒ Object
# === reset ========================================================================= #.
Constructor Details
#initialize ⇒ Tetris
#
initialize
#
26 27 28 29 30 31 |
# File 'lib/games_paradise/tetris/gtk2/tetris.rb', line 26 def initialize super() reset initialize_the_drawing_area connect_skeleton end |
Instance Method Details
#connect_skeleton ⇒ Object
#
connect_skeleton
#
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/games_paradise/tetris/gtk2/tetris.rb', line 46 def connect_skeleton @table = Gtk::Table.new(20, 2, true) @table.set_row_spacings(0) @table.set_border_width(0) @table.attach_defaults(('HELLO WORLD1'), 0,1, 0, 1) @table.attach_defaults(('HELLO WORLD2'), 0,1, 1, 2) add(@table) add(@drawing_area) show_all end |
#draw_shapes(cairo_context) ⇒ Object
#
draw_shapes
#
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/games_paradise/tetris/gtk2/tetris.rb', line 79 def draw_shapes(cairo_context) # ======================================================================= # # 1st rectangle # ======================================================================= # # cairo_context.set_source_rgb(:steelblue) cairo_context.background_colour = :steelblue cairo_context.rectangle(20, 20, 120, 80) cairo_context.fill # ======================================================================= # # 1st square, which is essentially a rectangle # ======================================================================= # cairo_context.background_colour = :lightblue cairo_context.rectangle(180, 20, 80, 80) cairo_context.fill end |
#favicon? ⇒ Boolean
#
favicon?
#
98 99 100 |
# File 'lib/games_paradise/tetris/gtk2/tetris.rb', line 98 def favicon? :tabble end |
#initialize_the_drawing_area ⇒ Object
#
initialize_the_drawing_area
#
60 61 62 63 64 |
# File 'lib/games_paradise/tetris/gtk2/tetris.rb', line 60 def initialize_the_drawing_area @drawing_area = Gtk::DrawingArea.new # @drawing_area.signal_connect(:draw) { on_draw } @drawing_area.signal_connect(:expose_event) { on_draw } end |
#on_draw ⇒ Object
#
on_draw
This is triggered by .initialize_the_drawing_area().
#
71 72 73 74 |
# File 'lib/games_paradise/tetris/gtk2/tetris.rb', line 71 def on_draw cairo_context = @drawing_area.window.create_cairo_context draw_shapes(cairo_context) end |
#reset ⇒ Object
#
reset
#
36 37 38 39 40 41 |
# File 'lib/games_paradise/tetris/gtk2/tetris.rb', line 36 def reset # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] end |