fork download
  1. #coding : utf-8
  2.  
  3. require "dxruby"
  4.  
  5. def key_code_to_str ary
  6. key_code = [
  7. "Q", 16, "W", 17, "E", 18, "R", 19, "T", 20, "Y", 21, "U", 22, "I", 23, "O", 24, "P", 25,
  8. "A", 30, "S", 31, "D", 32, "F", 33, "G", 34, "H", 35, "J", 36, "K", 37, "L", 38,
  9. "Z", 44, "X", 45, "C", 46, "V", 47, "B", 48, "N", 49, "M", 50,
  10. "1", 2, "2", 3, "3", 4, "4", 5, "5", 6, "6", 7, "7", 8, "8", 9, "9", 10, "0", 11,
  11. ].each_slice(2)
  12. str = ""
  13. ary.each do |key|
  14. key_code.each do |a,b|
  15. if b == key
  16. str << a
  17. break
  18. end
  19. end
  20. end
  21. return str
  22. end
  23.  
  24. name_ary = []
  25. name = ""
  26. phase = 0
  27. font = Font.new 25 , "メイリオ"
  28. Input.set_repeat(40 , 20)
  29. Window.loop do
  30. exit if Input.keyDown? K_ESCAPE
  31.  
  32. case phase
  33. when 0
  34. if Input.keyDown? K_RETURN
  35. phase = 1
  36. end
  37.  
  38. x = Input.keys
  39. if not x.empty?
  40. a = x.shift
  41. if Input.keyPush? a
  42. name_ary << a
  43. end
  44. end
  45. name = key_code_to_str name_ary
  46. Window.drawFont 50 , 50 , name , Font.default
  47. when 1
  48. Window.drawFont 50 , 50 , name , font , { :color => [100,200,200] }
  49.  
  50. end
  51.  
  52. end
  53.  
Runtime error #stdin #stdout #stderr 0.05s 9904KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- dxruby (LoadError)
	from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from prog.rb:3:in `<main>'