Guest User

Untitled

a guest
Feb 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #Copyright (C) 2006 by Han Dao
  2. #This is an example program that demostrate the input system.
  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 "../lib/main.rb"
  19. require "../lib/text.rb"
  20. require "rubygame"
  21. include Rubygame
  22. TTF.setup
  23. class Game
  24. def initialize
  25. @text = Text.new
  26. @main = Main.new
  27. @name = Name.new
  28. @main.font_set("freesansbold.ttf", 16)
  29. @main.screen_set(800, 600)
  30. @main.color_set([30,70,30])
  31. @main.class_text(@text)
  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.render_text
  37. while (1)
  38. @text.update
  39. input = @text.input
  40. if input == "no"
  41. @text.clear
  42. @text.add"Please type your desired name"
  43. @text.render_text
  44. name = @text.input
  45. @text.add(name + " is the name!")
  46. @text.render_text
  47. @name.say(name)
  48. elsif input == "yes"
  49. exit
  50. end
  51. end
  52. end
  53. end
  54.  
  55. class Name
  56. def initialize
  57. @main = Main.new
  58. @text = Text.new
  59. end
  60. def say name
  61. @text.add("Your name?")
  62. @text.add("Oh, sorry, I forgot. It is #{name} right?")
  63. @text.add("Type 'quit' to quit.")
  64. @text.render_text
  65. while(1)
  66. input = @text.input
  67. if input == "quit"
  68. exit
  69. end
  70. end
  71. end
  72. end
  73. Game.new
Add Comment
Please, Sign In to add comment