Draw player dead sprite.

This commit is contained in:
David Thompson 2024-05-22 18:21:45 -04:00
parent 9b88cb19c0
commit 2dc354229d
2 changed files with 14 additions and 10 deletions

View file

@ -252,8 +252,8 @@
(hashtable-set! cache x str)
str)))))
(define (draw-player pos)
(draw-tile context tileset 0 (vec2-x pos) (vec2-y pos)))
(define (draw-player pos alive?)
(draw-tile context tileset (if alive? 0 20) (vec2-x pos) (vec2-y pos)))
(define (draw-exit pos)
(draw-tile context tileset 27 (vec2-x pos) (vec2-y pos)))
@ -308,7 +308,7 @@
(define (draw-object obj)
(match obj
(#f #f)
(('player pos) (draw-player pos))
(('player pos alive?) (draw-player pos alive?))
(('exit pos) #t) ; drawn via background
(('wall pos type) (draw-wall pos type))
(('block pos type) (draw-block pos type))
@ -334,7 +334,14 @@
(define (draw-level)
(draw-background)
(for-each draw-object *objects*))
(for-each draw-object *objects*)
(let ((alive? (with-goblins ($ (level-player *level*) 'alive?))))
(unless alive?
(set-fill-color! context "rgba(0,0,0,0.65)")
(fill-rect context 0.0 0.0 game-width game-height)
(set-fill-color! context "#ffffff")
(set-text-align! context "center")
(fill-text context "OUCH... x_x" (/ game-width 2.0) (/ game-height 2.0)))))
(define (draw-win)
(set-fill-color! context "#x000000")