<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -31,6 +31,7 @@ TILE_SIZE = 16
 SCREEN_WIDTH_TILE = 320 / TILE_SIZE
 SCREEN_HEIGHT_TILE = 240 / TILE_SIZE
 
+require './fps'
 require './key'
 require './char'
 require './player'
@@ -39,6 +40,9 @@ require './map'
 require './script'
 require './file'
 
+$show_fps = true
+$show_debug = true
+
 #
 # The Game-class serves as a window for the Gosu game library
 # and controls basic game mechanics.
@@ -55,24 +59,14 @@ class Game &lt; Gosu::Window
     self.caption = 'QuickRPG Ruby Clone'
     
     $wnd = self
-    
-    @debug_font = Font.new(self, 'Monaco', 12)
-    
-    # Set up an FPS counter
-    @fps_counter = 0
-    @fps = 0
-    @milliseconds = milliseconds()
-    @show_fps = true
-    @show_debug = true
-    
-    cutter_bmp = Gosu::Image::load_tiles(self, File.join(&quot;gfx&quot;, &quot;sprites&quot;, &quot;cutter.png&quot;), 16, 16, true)
+    $font = Font.new(self, 'Monaco', 12)
     
     @show_textbox = false
     @textbox_text = Array.new
     @textbox_img = Gosu::Image.new(self, File.join(&quot;gfx&quot;, &quot;menu.png&quot;), true)
     @font_img = Gosu::Image::load_tiles(self, File.join(&quot;gfx&quot;, &quot;font.png&quot;), 6, 6, true)
     
-    @player = Player.new(cutter_bmp)
+    @player = Player.new(Gosu::Image::load_tiles(self, File.join(&quot;gfx&quot;, &quot;sprites&quot;, &quot;cutter.png&quot;), 16, 16, true))
     
     @map = nil
     @script = load_script &quot;start&quot;
@@ -80,7 +74,7 @@ class Game &lt; Gosu::Window
   end
   
   def update
-    update_fps
+    FPS::tick milliseconds()
     Key::update
     
     update_controls
@@ -89,14 +83,14 @@ class Game &lt; Gosu::Window
   end
   
   def draw
-    draw_background if @show_debug
+    draw_background if $show_debug
     
     draw_map
     
     draw_textbox if @show_textbox
     
-    draw_fps if @show_fps
-    draw_rules if @show_debug
+    draw_rules if $show_debug
+    FPS::draw if $show_fps
   end
   
   def use_map(map)
@@ -130,11 +124,11 @@ protected
     end
     
     if Key::hit?(KbF)
-      @show_fps = !@show_fps
+      $show_fps = !$show_fps
     end
     
     if Key::hit?(KbD)
-      @show_debug = !@show_debug
+      $show_debug = !$show_debug
     end
   
     if @show_textbox
@@ -193,17 +187,6 @@ protected
   def update_map
     @map.update unless @map.nil?
   end
-
-  def update_fps
-    @fps_counter += 1
-
-    if milliseconds() - @milliseconds &gt;= 1000
-      @fps = @fps_counter
-  
-      @fps_counter = 0
-      @milliseconds = milliseconds
-    end
-  end
   
   def draw_background
     c = 0xFF808080
@@ -233,10 +216,6 @@ protected
     end
   end
   
-  def draw_fps(x = 0.0, y = 0.0, color = 0xff000000)
-    @debug_font.draw(&quot;FPS: &quot; + @fps.to_s, x, y, 100.0, 1, 1, color)
-  end
-  
   def draw_rules
     (1..15).each { |y| draw_line 0, y*16, 0x40000000, 320, y*16, 0x50000000, 10000}
     (1..19).each { |x| draw_line x*16+1, 0, 0x50000000, x*16, 240, 0x50000000, 10000}</diff>
      <filename>main.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cf801627641403425667b8f99f52a0a23da3868f</id>
    </parent>
  </parents>
  <author>
    <name>Christian Tietze</name>
    <email>christian.tietze@googlemail.com</email>
  </author>
  <url>http://github.com/DivineDominion/quickrpg-clone/commit/2df2e68d8268238cef5213e7200a2e4a0daba078</url>
  <id>2df2e68d8268238cef5213e7200a2e4a0daba078</id>
  <committed-date>2009-03-27T18:16:27-07:00</committed-date>
  <authored-date>2009-03-27T18:16:27-07:00</authored-date>
  <message>cleaned up Main.rb and creates an FPS class</message>
  <tree>0f88e15c587819c513d91443d9afe9edb2747ca1</tree>
  <committer>
    <name>Christian Tietze</name>
    <email>christian.tietze@googlemail.com</email>
  </committer>
</commit>
