Module: GamesAndRpgParadise::GUI::Gtk::TetrisModule
- Includes:
- Gtk::BaseModule
- Included in:
- Tetris
- Defined in:
- lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Tetris'
- WIDTH =
#
WIDTH
#
1200
- HEIGHT =
#
HEIGHT
#
500
Class Method Summary collapse
-
.run(i = ARGV) ⇒ Object
# === GtkParadise::GUI::Gtk::TetrisModule.run ========================================================================= #.
Instance Method Summary collapse
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#connect_skeleton ⇒ Object
# === connect_skeleton (connect tag) ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton (create tag) ========================================================================= #.
-
#initialize(optional_file = nil, run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#position? ⇒ Boolean
# === position? ========================================================================= #.
-
#relocate_the_main_pox_to(a, b = @position) ⇒ Object
# === relocate_the_main_pox_to ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
Class Method Details
.run(i = ARGV) ⇒ Object
#
GtkParadise::GUI::Gtk::TetrisModule.run
#
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 158 def self.run( i = ARGV ) require 'gtk_paradise/run' _ = ::GamesAndRpgParadise::GUI::Gtk::Tetris.new(i) r = ::Gtk.run r << _ r.set_size_request(_.width?, _.height?) r.automatic_title r.signal_connect(:key_press_event) {|, event| if event.is_key?(:down) position = _.position? # The user pressed the down-key here. position += 40 position = 400 if position > 400 puts "Position is now at: #{position}" _.relocate_the_main_pox_to(10, position) # else end } r.top_left_then_run end |
Instance Method Details
#border_size? ⇒ Boolean
#
border_size?
#
95 96 97 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 95 def border_size? 2 end |
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 115 def connect_skeleton abort_on_exception set_size_request(600, 600) @vbox = gtk_vbox @vbox.css_class('bblack3') @vbox.css_class('BG_blue') @vbox.show_all @vbox.set_size_request(50, 50) @vbox.background_color(:royalblue) @position = 20+rand(15) put(@vbox, 10, @position) counter = 0 GLib::Timeout.add(500) { counter += 1 if counter < 10 @position += 40 @position = 400 if @position > 400 e "Position is now at: #{@position}" move(@vbox, 10, @position) true else false end } end |
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
102 103 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 102 def create_skeleton end |
#initialize(optional_file = nil, run_already = true) ⇒ Object
#
initialize
#
46 47 48 49 50 51 52 53 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 46 def initialize( optional_file = nil, run_already = true ) super() reset run if run_already end |
#padding? ⇒ Boolean
#
padding?
#
88 89 90 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 88 def padding? 2 end |
#position? ⇒ Boolean
#
position?
#
108 109 110 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 108 def position? @position end |
#relocate_the_main_pox_to(a, b = @position) ⇒ Object
#
relocate_the_main_pox_to
#
144 145 146 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 144 def relocate_the_main_pox_to(a, b = @position) move(@vbox, a, b) end |
#reset ⇒ Object
#
reset (reset tag)
#
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 58 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] # ======================================================================= # # === @title # ======================================================================= # @title = TITLE # ======================================================================= # # === @width # ======================================================================= # set_width(WIDTH) # ======================================================================= # # === @height # ======================================================================= # set_height(HEIGHT) # ======================================================================= # # === @position # ======================================================================= # @position = 0 set_font(:hack_25) use_project_css_file # or use use_gtk_paradise_project_css_file infer_the_size_automatically end |
#run ⇒ Object
#
run (run tag)
#
151 152 153 |
# File 'lib/games_and_rpg_paradise/games/tetris/shared_code/tetris/tetris_module.rb', line 151 def run create_skeleton_then_connect_skeleton end |