Class: RubyhopGame
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- RubyhopGame
- Defined in:
- lib/rubyhop.rb
Constant Summary collapse
- VERSION =
"1.3.0"
Instance Attribute Summary collapse
-
#high_score ⇒ Object
readonly
Returns the value of attribute high_score.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#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) ⇒ RubyhopGame
constructor
A new instance of RubyhopGame.
- #play! ⇒ Object
- #title! ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(width = 800, height = 600, fullscreen = false) ⇒ RubyhopGame
Returns a new instance of RubyhopGame.
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/rubyhop.rb', line 316 def initialize width=800, height=600, fullscreen=false super self.caption = 'Ruby Hop' @background = Gosu::Image.new self, get_my_file("background.png") # Scores @score = @high_score = 0 # Levels @title = TitleLevel.new self @hop = HopLevel.new self @fail = FailLevel.new self @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! end |
Instance Attribute Details
#high_score ⇒ Object (readonly)
Returns the value of attribute high_score.
315 316 317 |
# File 'lib/rubyhop.rb', line 315 def high_score @high_score end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
315 316 317 |
# File 'lib/rubyhop.rb', line 315 def score @score end |
#sounds ⇒ Object (readonly)
Returns the value of attribute sounds.
315 316 317 |
# File 'lib/rubyhop.rb', line 315 def sounds @sounds end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
315 316 317 |
# File 'lib/rubyhop.rb', line 315 def time @time end |
Instance Method Details
#button_down(id) ⇒ Object
359 360 361 |
# File 'lib/rubyhop.rb', line 359 def id @level. id if @level.respond_to? :button_down end |
#button_up(id) ⇒ Object
363 364 365 |
# File 'lib/rubyhop.rb', line 363 def id @level. id if @level.respond_to? :button_up end |
#draw ⇒ Object
372 373 374 375 |
# File 'lib/rubyhop.rb', line 372 def draw @background.draw 0, 0, 0 @level.draw end |
#fail! ⇒ Object
352 353 354 355 356 357 |
# File 'lib/rubyhop.rb', line 352 def fail! @score = @hop.score @high_score = @score if @score > @high_score @level = @fail @level.start! end |
#play! ⇒ Object
347 348 349 350 |
# File 'lib/rubyhop.rb', line 347 def play! @level = @hop @level.start! end |
#title! ⇒ Object
342 343 344 345 |
# File 'lib/rubyhop.rb', line 342 def title! @level = @title @level.start! end |
#update ⇒ Object
367 368 369 370 |
# File 'lib/rubyhop.rb', line 367 def update @time = Time.now.to_f @level.update end |