Class: GamesAndRpgParadise::Gtk::Pong::Window
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- GamesAndRpgParadise::Gtk::Pong::Window
- Includes:
- Gtk::BaseModule
- Defined in:
- lib/games_and_rpg_paradise/games/pong/gtk/cairo_pong.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
Instance Method Summary collapse
-
#initialize(speed = 30) ⇒ Window
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#set_expose_event ⇒ Object
# === set_expose_event ========================================================================= #.
Constructor Details
#initialize(speed = 30) ⇒ Window
#
initialize
#
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/games_and_rpg_paradise/games/pong/gtk/cairo_pong.rb', line 212 def initialize(speed = 30) super() reset @speed = speed self.title = 'Pong Demonstration' signal_connect(:destroy) { Gtk.main_quit } signal_connect(:key_press_event) { |, event| if event.state.control_mask? and event.keyval == Gdk::Keyval::GDK_q destroy true else false end } set_default_size(260, 200) @field = Field.new @drawing_area = gtk_drawing_area set_expose_event vb = Gtk::VBox.new(false, 5) vb.border_width = 10 vb.pack_start(@drawing_area, true, true, 0) vb.show_all add(vb) Gtk.timeout_add(@speed) { @field.update @drawing_area.queue_draw unless @drawing_area.destroyed? } move(0, 0) end |
Instance Method Details
#reset ⇒ Object
#
reset
#
247 248 249 250 251 252 |
# File 'lib/games_and_rpg_paradise/games/pong/gtk/cairo_pong.rb', line 247 def reset # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] end |
#set_expose_event ⇒ Object
#
set_expose_event
#
257 258 259 260 261 262 263 |
# File 'lib/games_and_rpg_paradise/games/pong/gtk/cairo_pong.rb', line 257 def set_expose_event @drawing_area.signal_connect(:expose_event) { |, event| cr = .window.create_cairo_context cr.scale(*.window.size) @field.draw(cr) } end |