Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygame'
- include Rubygame
- TTF.setup
- class Display
- def initialize
- @queue = Queue.instance()
- @font = TTF.new("data/fonts/freesansbold.ttf",15)
- @width = 800
- @height = 600
- @screen = Rubygame::Screen.set_mode([@width,@height],0, [Rubygame::HWSURFACE, Rubygame::DOUBLEBUF])
- @text = []
- end
- def render_text
- y = 0
- skip = @font.line_skip()
- @screen.fill([30,70,30])
- @text.each do |string|
- render = @font.render("#{[string]}",true,[200,200,200])
- render.blit(@screen,[0,y])
- y += skip
- end
- end
- def add text
- @text << text
- end
- def update
- @screen.flip()
- @queue.get.each do |event|
- case event
- when Rubygame::QuitEvent
- exit
- when Rubygame::KeyDownEvent
- if event.key == Rubygame::K_ESCAPE
- exit
- end
- end
- end
- end
- end
- class Main
- #The menu method is the main menu of the game.
- def initialize
- @file = Game_File.new
- @option = Game_Option.new
- @stage = Game_Stage.new
- @display = Display.new
- menu
- end
- def menu
- @display.add("Hello user, welcome to the program. What could you like to do?")
- @display.add("Creation: Press \"c\" to start creation.")
- @display.add("Load: Press \"l\" to load a game.")
- @display.add("Credit: Press \"c\" to see credit.")
- @display.render_text
- q = Queue.instance()
- while (1)
- @display.update
- q.get.each do |event|
- case event
- when Rubygame::KeyDownEvent
- if event.key == Rubygame::K_C
- end
- end
- end
- Main.new
Add Comment
Please, Sign In to add comment