Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix entity drawing bounds.

  • Loading branch information...
commit c6abbcb4ec6ffccf1973b90a3bab6376ce4c65a8 1 parent bdd67fd
@sjl authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/caves/ui/drawing.clj
12 src/caves/ui/drawing.clj
@@ -89,9 +89,13 @@
(s/put-string screen 0 hud-row info)))
-(defn draw-entity [screen origin {:keys [location glyph color]}]
- (let [[x y] (get-viewport-coords-of origin location)]
- (s/put-string screen x y glyph {:fg color})))
+(defn draw-entity [screen origin vrows vcols {:keys [location glyph color]}]
+ (let [[x y] (get-viewport-coords-of origin location)
+ max-x (dec vcols)
+ max-y (dec vrows)]
+ (when (and (<= 0 x max-x)
+ (<= 0 y max-y))
+ (s/put-string screen x y glyph {:fg color}))))
(defn draw-world [screen vrows vcols [ox oy] tiles]
@@ -122,7 +126,7 @@
origin (get-viewport-coords game (:location player) vcols vrows)]
(draw-world screen vrows vcols origin tiles)
(doseq [entity (vals entities)]
- (draw-entity screen origin entity))
+ (draw-entity screen origin vrows vcols entity))
(draw-hud screen game)
(draw-messages screen (:messages player))
(highlight-player screen origin player)))
Please sign in to comment.
Something went wrong with that request. Please try again.