Class: WinLevel
- Inherits:
-
Object
- Object
- WinLevel
- Defined in:
- lib/escape_to_rubyconf/win_level.rb
Instance Attribute Summary collapse
-
#difficulty ⇒ Object
Returns the value of attribute difficulty.
-
#window ⇒ Object
Returns the value of attribute window.
Instance Method Summary collapse
- #continue! ⇒ Object
- #create_msg! ⇒ Object
- #draw ⇒ Object
-
#initialize(window) ⇒ WinLevel
constructor
A new instance of WinLevel.
- #on_continue(&block) ⇒ Object
- #on_quit(&block) ⇒ Object
- #quit! ⇒ Object
- #start! ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(window) ⇒ WinLevel
Returns a new instance of WinLevel.
5 6 7 8 9 10 11 12 13 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 5 def initialize window @window = window @win = Gosu::Image.new @window, File.dirname(__FILE__) + '/assets/win.png' @sound = Gosu::Sample.new @window, File.dirname(__FILE__) + '/assets/win.wav' # Add callback holders @continue_callbacks = [] @quit_callbacks = [] end |
Instance Attribute Details
#difficulty ⇒ Object
Returns the value of attribute difficulty.
4 5 6 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 4 def difficulty @difficulty end |
#window ⇒ Object
Returns the value of attribute window.
4 5 6 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 4 def window @window end |
Instance Method Details
#continue! ⇒ Object
28 29 30 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 28 def continue! @continue_callbacks.each { |c| c.call } end |
#create_msg! ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 36 def create_msg! @msg = Gosu::Image.from_text @window, "You are a RUBY NINJA ROCKSTAR!!1!\n" + "You avoided #{@window.snakes_count} snakes!!!\n" + "Press SPACE if you dare to continue...\n" + "Or ESCAPE if it is just too much for you.", Gosu::default_font_name, 24 @msg_x = @window.width/2 - @msg.width/2 @msg_y = @window.height * 2 / 3 end |
#draw ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 54 def draw c = Math.cos(@window.time*4) a = Math.cos(@window.time) @win.draw_rot(((@window.width)/2), ((@window.height)/2 - 80), 1, a, 0.5, 0.5, 1.0+c*0.25, 1.0+c*0.25) @msg.draw @msg_x, @msg_y, 1, 1.0, 1.0, Gosu::Color::RED if @msg end |
#on_continue(&block) ⇒ Object
15 16 17 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 15 def on_continue &block @continue_callbacks << block end |
#on_quit(&block) ⇒ Object
19 20 21 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 19 def on_quit &block @quit_callbacks << block end |
#quit! ⇒ Object
32 33 34 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 32 def quit! @quit_callbacks.each { |c| c.call } end |
#start! ⇒ Object
23 24 25 26 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 23 def start! @sound.play create_msg! end |
#update ⇒ Object
47 48 49 50 51 52 |
# File 'lib/escape_to_rubyconf/win_level.rb', line 47 def update quit! if @window. Gosu::KbEscape continue! if ( @window.(Gosu::KbSpace) || @window.(Gosu::KbReturn) || @window.(Gosu::KbEnter) ) end |