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.
- # 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 "../lib/main.rb"
- require "../lib/text.rb"
- require "rubygame"
- include Rubygame
- TTF.setup
- class Game
- def initialize
- @text = Text.new
- @main = Main.new
- @name = Name.new
- @main.font_set("freesansbold.ttf", 16)
- @main.screen_set(800, 600)
- @main.color_set([30,70,30])
- @main.class_text(@text)
- loop
- end
- def loop
- @text.add"Type in \"no\" without the quote to do something and yes to quit"
- @text.render_text
- while (1)
- @text.update
- input = @text.input
- if input == "no"
- @text.clear
- @text.add"Please type your desired name"
- @text.render_text
- name = @text.input
- @text.add(name + " is the name!")
- @text.render_text
- @name.say(name)
- elsif input == "yes"
- exit
- end
- end
- end
- end
- class Name
- def initialize
- @main = Main.new
- @text = Text.new
- end
- def say name
- @text.add("Your name?")
- @text.add("Oh, sorry, I forgot. It is #{name} right?")
- @text.add("Type 'quit' to quit.")
- @text.render_text
- while(1)
- input = @text.input
- if input == "quit"
- exit
- end
- end
- end
- end
- Game.new
Add Comment
Please, Sign In to add comment