Class: Gtk::Games::Tetris
- Inherits:
-
HBox
- Object
- HBox
- Gtk::Games::Tetris
- Includes:
- BaseModule
- Defined in:
- lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb
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
#
21 22 23 24 25 26 |
# File 'lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb', line 21 def initialize super() reset initialize_the_drawing_area connect_skeleton end |
Instance Method Details
#connect_skeleton ⇒ Object
#
connect_skeleton
#
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb', line 42 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
#
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb', line 75 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?
#
94 95 96 |
# File 'lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb', line 94 def favicon? :tabble end |
#initialize_the_drawing_area ⇒ Object
#
initialize_the_drawing_area
#
56 57 58 59 60 |
# File 'lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb', line 56 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().
#
67 68 69 70 |
# File 'lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb', line 67 def on_draw cairo_context = @drawing_area.window.create_cairo_context draw_shapes(cairo_context) end |
#reset ⇒ Object
#
reset
#
31 32 33 34 35 36 37 |
# File 'lib/games_and_rpg_paradise/games/tetris/gtk2/tetris.rb', line 31 def reset # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] infer_the_namespace end |