public
Description: RubyStein 3d SUPER MEGA ULTRA MEGAZORD UBER UBER ENTERPRISE EDITION
Homepage:
Clone URL: git://github.com/FooBarWidget/rubystein.git
Hongli Lai (Phusion) (author)
Thu May 14 05:33:25 -0700 2009
rubystein / image_pool.rb
100644 24 lines (21 sloc) 0.544 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'rubygems'
require 'gosu'
 
class ImagePool
  @@image_files = {}
  @@image_texts = {}
  
  def self.get_file(window, filename)
    if !@@image_files.has_key?(filename)
      @@image_files[filename] = Gosu::Image.new(window, filename)
    end
    @@image_files[filename]
  end
  
  def self.get_text(window, text)
    if !@@image_texts.has_key?(text)
      lines = text.split("\n")
      @@image_texts[text] = lines.map do |line|
        Gosu::Image.from_text(window, line, "Arial", 26)
      end
    end
    @@image_texts[text]
  end
end