Skip to content

Instantly share code, notes, and snippets.

@spajus
Created June 20, 2014 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spajus/5e677f1a0199141c49c0 to your computer and use it in GitHub Desktop.
Save spajus/5e677f1a0199141c49c0 to your computer and use it in GitHub Desktop.
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