Created
March 20, 2009 10:21
-
-
Save robc/82310 to your computer and use it in GitHub Desktop.
This file contains 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 "rubygems" | |
require "gosu" # sudo gem install gosu | |
class FontRenderingWindow < Gosu::Window | |
FRAMES_BEFORE_ADDING_NEW_STRING = 90 | |
def initialize | |
super(1280, 720, false) | |
self.caption = "Memory Fail?" | |
@font = Gosu::Font.new(self, "Helvetica", 72) | |
@strings = Array.new | |
@frames_before_next_string = FRAMES_BEFORE_ADDING_NEW_STRING | |
end | |
def button_down(id) | |
if id == Gosu::Button::KbEscape then | |
close | |
end | |
end | |
def update | |
@frames_before_next_string -= 1 | |
if @frames_before_next_string == 0 | |
next_string = { | |
:x => rand(1280), | |
:y => rand(720) | |
} | |
@strings << next_string | |
@frames_before_next_string = FRAMES_BEFORE_ADDING_NEW_STRING | |
end | |
end | |
def draw | |
@strings.each do |str| | |
@font.draw("Memory Fail?", str[:x], str[:y], 3, 1.0, 1.0, 0xffffffff) | |
end | |
end | |
end | |
FontRenderingWindow.new.show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment