class Rubyhop
Constants
- VERSION
Attributes
high_score[R]
score[R]
sounds[R]
time[R]
Public Class Methods
image(filename)
click to toggle source
# File lib/rubyhop.rb, line 42 def self.image filename Image.new filename end
method_missing(method, *args)
click to toggle source
# File lib/rubyhop.rb, line 66 def self.method_missing method, *args self.instance.send(method, *args) end
new(width=800, height=600, fullscreen=false)
click to toggle source
Calls superclass method
# File lib/rubyhop.rb, line 70 def initialize width=800, height=600, fullscreen=false super end
play!()
click to toggle source
# File lib/rubyhop.rb, line 62 def self.play! self.instance.setup.show end
score_font()
click to toggle source
# File lib/rubyhop.rb, line 58 def self.score_font @@font ||= Gosu::Font.new Rubyhop.instance, Gosu::default_font_name, 20 end
song(filename)
click to toggle source
# File lib/rubyhop.rb, line 50 def self.song filename Song.new filename end
sound(filename)
click to toggle source
# File lib/rubyhop.rb, line 54 def self.sound filename Sound.new filename end
text_image(message, font = Gosu::default_font_name, size = 24)
click to toggle source
# File lib/rubyhop.rb, line 46 def self.text_image message, font = Gosu::default_font_name, size = 24 Image.from_text message, font, size end
Public Instance Methods
draw()
click to toggle source
# File lib/rubyhop.rb, line 129 def draw @background.draw 0, 0, 0 @level.draw end
fail!()
click to toggle source
# File lib/rubyhop.rb, line 109 def fail! @score = @hop.score @high_score = @score if @score > @high_score @level = @fail @level.start! end
play!()
click to toggle source
# File lib/rubyhop.rb, line 104 def play! @level = @hop @level.start! end
setup()
click to toggle source
# File lib/rubyhop.rb, line 74 def setup self.caption = "Ruby Hop - #{VERSION}" @background = Rubyhop.image "background.png" # Scores @score = @high_score = 0 # Levels @title = TitleLevel.new @hop = HopLevel.new @fail = FailLevel.new @title.on_continue { play! } @title.on_quit { close } @hop.on_fail { fail! } @hop.on_quit { close } @fail.on_continue { play! } @fail.on_quit { close } title! self end
title!()
click to toggle source
# File lib/rubyhop.rb, line 99 def title! @level = @title @level.start! end
update()
click to toggle source
# File lib/rubyhop.rb, line 124 def update @time = Time.now.to_f @level.update end