<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -8,6 +8,7 @@ module Sprite
   attr_accessor :y
   attr_accessor :window
   attr_accessor :slices
+  attr_accessor :z_order
 end
 
 class SpritePool</diff>
      <filename>sprite.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,10 @@
 module Damageable
   attr_accessor :health
   
+  def dead?
+    @health &lt;= 0
+  end
+  
   def take_damage_from(player)
     @health -= 5
     #@health -= player.weapon.damage</diff>
      <filename>weapon.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,8 +14,8 @@ module ZOrder
   BACKGROUND = 0
   LEVEL      = 1
   SPRITES    = 2
-  WEAPON     = 3
-  HUD        = 10
+  WEAPON     = 9999
+  HUD        = 10000
 end
 
 class GameWindow &lt; Gosu::Window
@@ -145,7 +145,7 @@ class GameWindow &lt; Gosu::Window
       perp_distance = ( distance * Math.cos( sprite_angle * Math::PI / 180 ))#.abs
       next if perp_distance &lt;= 0 # Behind us... no point in drawing this.
 
-      z_order_distance = 1 / (perp_distance / Map::GRID_WIDTH_HEIGHT)
+      sprite.z_order = ZOrder::SPRITES + ( 1 / (perp_distance / Map::GRID_WIDTH_HEIGHT))
       sprite_pixel_factor = ( Player::DISTANCE_TO_PROJECTION / perp_distance )
       sprite_size = sprite_pixel_factor * Sprite::TEX_WIDTH
       
@@ -162,11 +162,13 @@ class GameWindow &lt; Gosu::Window
         slice_idx = slice.to_i
         
         if slice &gt;= 0 &amp;&amp; slice &lt; Config::WINDOW_WIDTH &amp;&amp; perp_distance &lt; @wall_perp_distances[slice_idx]
-          slices[i].draw(slice, y, ZOrder::SPRITES + z_order_distance, sprite_pixel_factor, sprite_pixel_factor, 0xffffffff)
+          slices[i].draw(slice, y, sprite.z_order, sprite_pixel_factor, sprite_pixel_factor, 0xffffffff)
           drawn_slice_idx = slice_idx
           
           while((drawn_slice_idx - x) &lt;= ((i+1) * sprite_pixel_factor))
-            @drawn_sprite_x[drawn_slice_idx] = sprite
+            if not (@drawn_sprite_x[drawn_slice_idx] &amp;&amp; sprite.z_order &gt; @drawn_sprite_x[drawn_slice_idx].z_order &amp;&amp; sprite.respond_to?(:dead?) &amp;&amp; sprite.dead?)
+              @drawn_sprite_x[drawn_slice_idx] = sprite 
+            end
             drawn_slice_idx += 1
           end
         end</diff>
      <filename>wolf3d.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e59725447b9736d4dfd1815824e158082ea6095a</id>
    </parent>
  </parents>
  <author>
    <name>Ninh Bui (Phusion)</name>
    <email>ninh@phusion.nl</email>
  </author>
  <url>http://github.com/FooBarWidget/rubystein/commit/ff1766615db61c3156361e0078ff09dc6336e233</url>
  <id>ff1766615db61c3156361e0078ff09dc6336e233</id>
  <committed-date>2009-04-19T11:32:15-07:00</committed-date>
  <authored-date>2009-04-19T11:32:15-07:00</authored-date>
  <message>Implemented z_order attribute for sprites. Still a bit hackish, but we're running out of time for Railsconf :(</message>
  <tree>c8997795cf491b8484191b3fd3922a094d9ddaff</tree>
  <committer>
    <name>Ninh Bui (Phusion)</name>
    <email>ninh@phusion.nl</email>
  </committer>
</commit>
