Module: GamesAndRpgParadise::GUI::Gtk::SnakeModule

Includes:
Gtk::BaseModule
Included in:
Snake
Defined in:
lib/games_and_rpg_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

Instance Method Summary collapse

Class Method Details

.run(i = ARGV) ⇒ Object

#

GtkParadise::GUI::Gtk::SnakeModule.run

#


124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 124

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::GamesAndRpgParadise::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?

#

Returns:

  • (Boolean)


83
84
85
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 83

def border_size?
  2
end

#connect_skeletonObject

#

connect_skeleton (connect tag)

#


104
105
106
107
108
109
110
111
112
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 104

def connect_skeleton
  abort_on_exception
  queue_draw
  minimal(
gtk_left_aligned_label(
'Hello world! This is a test.'
)
  )
end

#create_skeletonObject

#

create_skeleton (create tag)

#


90
91
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 90

def create_skeleton
end

#init_timeoutObject

init_timeout

adds the timeout to the Gtk.Window



96
97
98
99
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 96

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_and_rpg_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?

#

Returns:

  • (Boolean)


76
77
78
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 76

def padding?
  2
end

#resetObject

#

reset (reset tag)

#


60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 60

def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  title_width_height(TITLE, WIDTH, HEIGHT)
  set_use_this_font(:dejavu_condensed_22)
  @speed = 100
  use_project_css_file
  infer_the_size_automatically
end

#runObject

#

run (run tag)

#


117
118
119
# File 'lib/games_and_rpg_paradise/gui/shared_code/snake/snake_module.rb', line 117

def run
  create_skeleton_then_connect_skeleton
end