<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -27,60 +27,77 @@ require 'observer'
 class Key
   include Singleton, Observable
   
-  # Initialize class variables
-  @@wnd = @@keys = nil
-  
-  def self.setup(wnd)
-    @@wnd = wnd
-    @@keys = Array.new(256, :released)
+  # Sets up a shorthand and Maps each object method to a class method, 
+  # e.g. write Key::state(id) instead of Key.instance.state(id)
+  MapMethodsToClassMethods = proc do
+    meth = self.public_instance_methods \
+      - self.superclass.public_instance_methods \
+      - (self.included_modules.map {|m| m.instance_methods}).flatten
+
+    # TODO migrate to Ruby 1.9 soon!!
+    meth.map!{|m|m.to_sym} if RUBY_VERSION =~ /^1\.8/
+
+    meth.each do |m|
+      module_eval &lt;&lt;-END_EVAL
+        def self.#{m.id2name}(*args, &amp;block)
+          instance.#{m.id2name}(*args, &amp;block)
+        end
+      END_EVAL
+    end
   end
   
-  def self.update
-    raise &quot;Call Key::setup first&quot; unless defined? @@wnd
+  def initialize
+    raise &quot;Setup $wnd which must be instance_of? Gosu::Window&quot; unless defined? $wnd
     
+    @keys = Array.new(256, :released) 
+  end
+  
+  def update
     (0..255).each do |id|
-      old_state = Key::state id
+      old_state = state(id)
       
-      if @@wnd.button_down? id
-        Key::button_down(id)
+      if $wnd.button_down?(id)
+        button_down(id)
       else
-        Key::button_up(id)
+        button_up(id)
       end
       
       # Notify listeners on state changes
-      if old_state != Key::state(id)
-        Key::instance.notify_observers(:key_event, id, Key::state(id))
+      if state(id) != old_state
+        notify_observers(:key_event, id, state(id))
       end
     end
   end
   
-  def self.button_down(id)
-    @@keys[id] = :down  if Key::hit? id
-    @@keys[id] = :hit   if Key::released? id
+  def button_down(id)
+    @keys[id] = :down  if hit? id
+    @keys[id] = :hit   if released? id
   end 
   
-  def self.button_up(id)
-    @@keys[id] = :released  if Key::up? id
-    @@keys[id] = :up        if Key::down? id
+  def button_up(id)
+    @keys[id] = :released  if up? id
+    @keys[id] = :up        if down? id
   end
 
-  def self.hit?(id)
-    @@keys[id] == :hit
+  def hit?(id)
+    @keys[id] == :hit
   end
   
-  def self.down?(id)
-    @@keys[id] == :down or Key::hit? id
+  def down?(id)
+    @keys[id] == :down or hit? id
   end
   
-  def self.up?(id)
-    @@keys[id] == :up
+  def up?(id)
+    @keys[id] == :up
   end
   
-  def self.released?(id)
-    @@keys[id] == :released or Key::up? id
+  def released?(id)
+    @keys[id] == :released or up? id
   end
   
-  def self.state(id)
-    @@keys[id]
+  def state(id)
+    @keys[id]
   end
+  
+  MapMethodsToClassMethods.call
 end
\ No newline at end of file</diff>
      <filename>key.rb</filename>
    </modified>
    <modified>
      <diff>@@ -54,10 +54,9 @@ class Game &lt; Gosu::Window
     super(SCREEN_WIDTH, SCREEN_HEIGHT, false, 20)
     self.caption = 'QuickRPG Ruby Clone'
     
-    Key::setup self
+    $wnd = self
     
     @debug_font = Font.new(self, 'Monaco', 12)
-    @bgcol = Color.new(255, 128, 128, 128)
     
     # Set up an FPS counter
     @fps_counter = 0
@@ -207,7 +206,8 @@ protected
   end
   
   def draw_background
-    draw_quad 0, 0, @bgcol, 320, 0, @bgcol, 0, 240, @bgcol, 320, 240, @bgcol
+    c = 0xFF808080
+    draw_quad 0, 0, c, SCREEN_WIDTH, 0, c, 0, SCREEN_HEIGHT, c, SCREEN_WIDTH, SCREEN_HEIGHT, c
   end  
   
   def draw_map</diff>
      <filename>main.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>parse_npcsc.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>bbaffc161d47276d634ac476074a45280f1ea807</id>
    </parent>
  </parents>
  <author>
    <name>Christian Tietze</name>
    <email>christian.tietze@googlemail.com</email>
  </author>
  <url>http://github.com/DivineDominion/quickrpg-clone/commit/cf801627641403425667b8f99f52a0a23da3868f</url>
  <id>cf801627641403425667b8f99f52a0a23da3868f</id>
  <committed-date>2009-03-27T17:25:37-07:00</committed-date>
  <authored-date>2009-03-27T17:25:37-07:00</authored-date>
  <message>slightly modified the Key class to be even cooler than before</message>
  <tree>fe50631543bcfabf1db01d478184d48b279c0036</tree>
  <committer>
    <name>Christian Tietze</name>
    <email>christian.tietze@googlemail.com</email>
  </committer>
</commit>
