Created
June 20, 2014 09:38
-
-
Save spajus/5e677f1a0199141c49c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'singleton' | |
require 'gosu' | |
class TestGameWindow < Gosu::Window | |
include Singleton | |
def initialize | |
super(640, 480, false) | |
self.caption = "Esc = quit" | |
end | |
def draw | |
@draw_block.call if @draw_block | |
end | |
def button_down(id) | |
close if id == Gosu::KbEscape | |
end | |
def while_showing(&block) | |
@draw_block = block | |
show | |
end | |
end | |
window = TestGameWindow.instance | |
@img = Gosu::Image.from_text(window, "test", Gosu.default_font_name, 20) | |
window.while_showing do | |
@img.draw(10, 10, 0) | |
end | |
@img2 = Gosu::Image.from_text(window, "test2", Gosu.default_font_name, 20) | |
window.while_showing do | |
@img2.draw(10, 10, 0) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment