Module: GamesParadise::GUI::Gtk::SnakeModule
- Includes:
- Gtk::BaseModule
- Included in:
- Snake
- Defined in:
- lib/games_paradise/gui/shared_code/snake/snake_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Foobar'
- WIDTH =
#
WIDTH
#
1200
- HEIGHT =
#
HEIGHT
#
500
Class Method Summary collapse
-
.run(i = ARGV) ⇒ Object
# === GtkParadise::GUI::Gtk::SnakeModule.run ========================================================================= #.
Instance Method Summary collapse
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#connect_skeleton ⇒ Object
# === connect_skeleton (connect tag) ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton (create tag) ========================================================================= #.
-
#init_timeout ⇒ Object
adds the timeout to the Gtk.Window.
-
#initialize(optional_file = nil, run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
Class Method Details
.run(i = ARGV) ⇒ Object
#
GtkParadise::GUI::Gtk::SnakeModule.run
#
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 133 def self.run( i = ARGV ) require 'gtk_paradise/run' _ = ::GamesParadise::GUI::Gtk::Snake.new(i) r = ::Gtk.run r << _ r.set_size_request(_.width?, _.height?) r.resize(_.width?, _.height?) r.automatic_title r.top_left_then_run end |
Instance Method Details
#border_size? ⇒ Boolean
#
border_size?
#
94 95 96 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 94 def border_size? 2 end |
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
113 114 115 116 117 118 119 120 121 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 113 def connect_skeleton abort_on_exception queue_draw minimal( gtk_left_aligned_label( 'Hello world! This is a test.' ) ) end |
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
101 102 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 101 def create_skeleton end |
#init_timeout ⇒ Object
adds the timeout to the Gtk.Window
105 106 107 108 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 105 def init_timeout @timeout_id = GLib.timeout_add(@speed, @on_timeout, nil) @timeout_on = true end |
#initialize(optional_file = nil, run_already = true) ⇒ Object
#
initialize
#
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 44 def initialize( optional_file = nil, run_already = true ) super(:vertical) reset init_ui() @direc = [0,1,2,3].sample @timeout_on = true @allow_change = true run if run_already end |
#padding? ⇒ Boolean
#
padding?
#
87 88 89 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 87 def padding? 2 end |
#reset ⇒ Object
#
reset (reset tag)
#
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 60 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] # ======================================================================= # # === @title # ======================================================================= # @title = TITLE # ======================================================================= # # === @width # ======================================================================= # set_width(WIDTH) # ======================================================================= # # === @height # ======================================================================= # set_height(HEIGHT) set_use_this_font(:dejavu_condensed_22) @speed = 100 use_project_css_file # or use use_gtk_paradise_project_css_file infer_the_size_automatically end |
#run ⇒ Object
#
run (run tag)
#
126 127 128 |
# File 'lib/games_paradise/gui/shared_code/snake/snake_module.rb', line 126 def run create_skeleton_then_connect_skeleton end |