Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Copyright (C) 2006 by Han Dao
- #This is an example program that demostrate the input system of the rbGooey library.
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- #
- require "rubygame"
- require "rbGooey"
- include Rubygame
- TTF.setup
- class Game
- def initialize
- @main = Main.new
- @main.font_set("freesansbold.ttf", 16)
- @main.screen_set(800, 600)
- @main.bgcolor = [20,70,20]
- @main.fgcolor = [200,200,200]
- @text = TextMode.new(@main)
- @input = TextInput.new(@text.textrender)
- @name = Name.new(@main)
- loop
- end
- def loop
- @text.add"Type in \"no\" without the quote to do something and yes to quit"
- @text.set_size(18)
- @text.set_pos(222,330)
- @text.length(5)
- @text.add"."
- @text.add"."
- @text.add"."
- @text.add"Type"
- @text.textrender.render_text
- while (1)
- @text.textrender.update
- input = @input.input
- if input == "no"
- @text.clear
- @text.add"Please type your desired name"
- @text.textrender.render_text
- name = @input.input
- @text.add(name + " is the name!")
- @text.textrender.render_text
- @name.say(name)
- elsif input == "yes"
- exit
- end
- end
- end
- end
- class Name
- def initialize(main)
- @text = TextMode.new(main)
- @input = TextInput.new(@text.textrender)
- end
- def say name
- @text.clear
- @text.add("Your name?")
- @text.add("Oh, sorry, I forgot. It is #{name} right?")
- @text.add("Type 'quit' to quit.")
- @text.textrender.render_text
- while(1)
- input = @input.input
- if input == "quit"
- exit
- end
- end
- end
- end
- Game.new
Add Comment
Please, Sign In to add comment