Guest User

Untitled

a guest
Feb 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #Copyright (C) 2006 by Han Dao
  2. #This is an example program that demostrate the input system of the rbGooey library.
  3.  
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8.  
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. #
  18. require "rubygame"
  19. require "rbGooey"
  20. include Rubygame
  21. TTF.setup
  22. class Game
  23. def initialize
  24. @main = Main.new
  25. @main.font_set("freesansbold.ttf", 16)
  26. @main.screen_set(800, 600)
  27. @main.bgcolor = [20,70,20]
  28. @main.fgcolor = [200,200,200]
  29. @text = TextMode.new(@main)
  30. @input = TextInput.new(@text.textrender)
  31. @name = Name.new(@main)
  32. loop
  33. end
  34. def loop
  35. @text.add"Type in \"no\" without the quote to do something and yes to quit"
  36. @text.set_size(18)
  37. @text.set_pos(222,330)
  38. @text.length(5)
  39. @text.add"."
  40. @text.add"."
  41. @text.add"."
  42. @text.add"Type"
  43. @text.textrender.render_text
  44. while (1)
  45. @text.textrender.update
  46. input = @input.input
  47. if input == "no"
  48. @text.clear
  49. @text.add"Please type your desired name"
  50. @text.textrender.render_text
  51. name = @input.input
  52. @text.add(name + " is the name!")
  53. @text.textrender.render_text
  54. @name.say(name)
  55. elsif input == "yes"
  56. exit
  57. end
  58. end
  59. end
  60. end
  61.  
  62. class Name
  63. def initialize(main)
  64. @text = TextMode.new(main)
  65. @input = TextInput.new(@text.textrender)
  66. end
  67. def say name
  68. @text.clear
  69. @text.add("Your name?")
  70. @text.add("Oh, sorry, I forgot. It is #{name} right?")
  71. @text.add("Type 'quit' to quit.")
  72. @text.textrender.render_text
  73. while(1)
  74. input = @input.input
  75. if input == "quit"
  76. exit
  77. end
  78. end
  79. end
  80. end
  81. Game.new
Add Comment
Please, Sign In to add comment