Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.59 KB | None | 0 0
  1. require 'gosu'
  2.  
  3. class Window < Gosu::Window
  4.   def initialize
  5.     super(500, 32, false)
  6.     self.caption = "test gosu/ruby (Echap pour quitter)"
  7.     @score = 0
  8.   end
  9.  
  10.   def reset
  11.     @score = 0
  12.   end
  13.  
  14.   def button_down(id)
  15.     close if id == Gosu::KbEscape
  16.     reset if id == Gosu::KbF12
  17.   end
  18.  
  19.   def update
  20.     @text = Gosu::Image.from_text(self, "#{@score}", "Georgia", 24)
  21.       @score -= 1 if button_down?(Gosu::KbDown) if @score >= 0
  22.       @score += 1 if button_down?(Gosu::KbUp) if @score <= 200
  23.   end
  24.  
  25.   def draw
  26.     @text.draw(10,0,1)
  27.   end
  28. end
  29.  
  30. Window.new.show
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement