/examples/example24_enter_name.rb

http://github.com/ippa/chingu · Ruby · 21 lines · 17 code · 3 blank · 1 comment · 0 complexity · 8125d7a3273276772eba7d366d64fba9 MD5 · raw file

  1. #!/usr/bin/env ruby
  2. require 'rubygems'
  3. require File.join(File.dirname($0), "..", "lib", "chingu")
  4. include Gosu
  5. include Chingu
  6. class Game < Chingu::Window
  7. def initialize
  8. super(800,400,false) # leave it blank and it will be 800,600,non fullscreen
  9. self.input = { :escape => :exit } # exits example on Escape
  10. self.caption = "Demonstration of GameStates::EnterName"
  11. push_game_state(GameStates::EnterName.new(:callback => method(:got_name)))
  12. end
  13. def got_name(name)
  14. puts "Got name: #{name}"
  15. exit
  16. end
  17. end
  18. Game.new.show