Class: RubyhopGame
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- RubyhopGame
- Defined in:
- lib/rubyhop.rb
Constant Summary collapse
- VERSION =
"1.3.1"
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
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/rubyhop.rb', line 315 def initialize width=800, height=600, fullscreen=false super self.caption = "Ruby Hop - #{VERSION}" @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.
314 315 316 |
# File 'lib/rubyhop.rb', line 314 def high_score @high_score end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
314 315 316 |
# File 'lib/rubyhop.rb', line 314 def score @score end |
#sounds ⇒ Object (readonly)
Returns the value of attribute sounds.
314 315 316 |
# File 'lib/rubyhop.rb', line 314 def sounds @sounds end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
314 315 316 |
# File 'lib/rubyhop.rb', line 314 def time @time end |
Instance Method Details
#button_down(id) ⇒ Object
358 359 360 |
# File 'lib/rubyhop.rb', line 358 def id @level. id if @level.respond_to? :button_down end |
#button_up(id) ⇒ Object
362 363 364 |
# File 'lib/rubyhop.rb', line 362 def id @level. id if @level.respond_to? :button_up end |
#draw ⇒ Object
371 372 373 374 |
# File 'lib/rubyhop.rb', line 371 def draw @background.draw 0, 0, 0 @level.draw end |
#fail! ⇒ Object
351 352 353 354 355 356 |
# File 'lib/rubyhop.rb', line 351 def fail! @score = @hop.score @high_score = @score if @score > @high_score @level = @fail @level.start! end |
#play! ⇒ Object
346 347 348 349 |
# File 'lib/rubyhop.rb', line 346 def play! @level = @hop @level.start! end |
#title! ⇒ Object
341 342 343 344 |
# File 'lib/rubyhop.rb', line 341 def title! @level = @title @level.start! end |
#update ⇒ Object
366 367 368 369 |
# File 'lib/rubyhop.rb', line 366 def update @time = Time.now.to_f @level.update end |