Class: EscapeToRubyConf
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- EscapeToRubyConf
- Defined in:
- lib/escape_to_rubyconf.rb
Constant Summary collapse
- VERSION =
"1.0"
Instance Attribute Summary collapse
-
#sounds ⇒ Object
readonly
Returns the value of attribute sounds.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #button_up(id) ⇒ Object
- #draw ⇒ Object
- #fail! ⇒ Object
-
#initialize(width = 800, height = 600, fullscreen = false) ⇒ EscapeToRubyConf
constructor
A new instance of EscapeToRubyConf.
- #play! ⇒ Object
- #snakes_count ⇒ Object
- #update ⇒ Object
- #win! ⇒ Object
Constructor Details
#initialize(width = 800, height = 600, fullscreen = false) ⇒ EscapeToRubyConf
Returns a new instance of EscapeToRubyConf.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/escape_to_rubyconf.rb', line 11 def initialize width=800, height=600, fullscreen=false super self.caption = 'ESCAPE TO RUBYCONF!!!' # So multiple sprites don't create duplicate objects @sounds = {} # Levels @play = PlayLevel.new self @win = WinLevel.new self @fail = FailLevel.new self # @play.on_start { do_something_here! } @play.on_win { win! } @play.on_fail { fail! } @play.on_quit { close } @fail.on_continue { play! } @fail.on_quit { close } @win.on_continue { @play.add_snake!; play!} @win.on_quit { close } play! end |
Instance Attribute Details
#sounds ⇒ Object (readonly)
Returns the value of attribute sounds.
10 11 12 |
# File 'lib/escape_to_rubyconf.rb', line 10 def sounds @sounds end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
10 11 12 |
# File 'lib/escape_to_rubyconf.rb', line 10 def time @time end |
Instance Method Details
#button_down(id) ⇒ Object
53 54 55 |
# File 'lib/escape_to_rubyconf.rb', line 53 def id @level. id if @level.respond_to? :button_down end |
#button_up(id) ⇒ Object
57 58 59 |
# File 'lib/escape_to_rubyconf.rb', line 57 def id @level. id if @level.respond_to? :button_up end |
#draw ⇒ Object
70 71 72 |
# File 'lib/escape_to_rubyconf.rb', line 70 def draw @level.draw end |
#fail! ⇒ Object
43 44 45 46 |
# File 'lib/escape_to_rubyconf.rb', line 43 def fail! @level = @fail @fail.start! end |
#play! ⇒ Object
38 39 40 41 |
# File 'lib/escape_to_rubyconf.rb', line 38 def play! @level = @play @play.start! end |
#snakes_count ⇒ Object
61 62 63 |
# File 'lib/escape_to_rubyconf.rb', line 61 def snakes_count @play.snakes_count end |
#update ⇒ Object
65 66 67 68 |
# File 'lib/escape_to_rubyconf.rb', line 65 def update @time = Time.now.to_f @level.update end |
#win! ⇒ Object
48 49 50 51 |
# File 'lib/escape_to_rubyconf.rb', line 48 def win! @level = @win @win.start! end |