Draw player dead sprite.
This commit is contained in:
parent
9b88cb19c0
commit
2dc354229d
2 changed files with 14 additions and 10 deletions
15
game.scm
15
game.scm
|
@ -252,8 +252,8 @@
|
||||||
(hashtable-set! cache x str)
|
(hashtable-set! cache x str)
|
||||||
str)))))
|
str)))))
|
||||||
|
|
||||||
(define (draw-player pos)
|
(define (draw-player pos alive?)
|
||||||
(draw-tile context tileset 0 (vec2-x pos) (vec2-y pos)))
|
(draw-tile context tileset (if alive? 0 20) (vec2-x pos) (vec2-y pos)))
|
||||||
|
|
||||||
(define (draw-exit pos)
|
(define (draw-exit pos)
|
||||||
(draw-tile context tileset 27 (vec2-x pos) (vec2-y pos)))
|
(draw-tile context tileset 27 (vec2-x pos) (vec2-y pos)))
|
||||||
|
@ -308,7 +308,7 @@
|
||||||
(define (draw-object obj)
|
(define (draw-object obj)
|
||||||
(match obj
|
(match obj
|
||||||
(#f #f)
|
(#f #f)
|
||||||
(('player pos) (draw-player pos))
|
(('player pos alive?) (draw-player pos alive?))
|
||||||
(('exit pos) #t) ; drawn via background
|
(('exit pos) #t) ; drawn via background
|
||||||
(('wall pos type) (draw-wall pos type))
|
(('wall pos type) (draw-wall pos type))
|
||||||
(('block pos type) (draw-block pos type))
|
(('block pos type) (draw-block pos type))
|
||||||
|
@ -334,7 +334,14 @@
|
||||||
|
|
||||||
(define (draw-level)
|
(define (draw-level)
|
||||||
(draw-background)
|
(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)
|
(define (draw-win)
|
||||||
(set-fill-color! context "#x000000")
|
(set-fill-color! context "#x000000")
|
||||||
|
|
|
@ -443,7 +443,7 @@
|
||||||
(('exit obj grid-info) #f)
|
(('exit obj grid-info) #f)
|
||||||
(('wire-state grid-info) #f)
|
(('wire-state grid-info) #f)
|
||||||
(('alive?) ($ alive?))
|
(('alive?) ($ alive?))
|
||||||
(('describe) `(player ,($ position)))
|
(('describe) `(player ,($ position), ($ alive?)))
|
||||||
(('collide other offset grid-info)
|
(('collide other offset grid-info)
|
||||||
(define (reverse-move)
|
(define (reverse-move)
|
||||||
(match ($ position)
|
(match ($ position)
|
||||||
|
@ -641,11 +641,8 @@
|
||||||
(match-lambda*
|
(match-lambda*
|
||||||
(('tick) (tick))
|
(('tick) (tick))
|
||||||
(('describe)
|
(('describe)
|
||||||
(let ((player ($ player))
|
(cons ($ ($ player) 'describe)
|
||||||
(obj-descs (map (lambda (obj) ($ obj 'describe)) ($ objects))))
|
(map (lambda (obj) ($ obj 'describe)) ($ objects))))
|
||||||
(if ($ player 'alive?)
|
|
||||||
(cons ($ player 'describe) obj-descs)
|
|
||||||
obj-descs)))
|
|
||||||
(('add-object obj)
|
(('add-object obj)
|
||||||
(if (eq? ($ obj 'type) 'player)
|
(if (eq? ($ obj 'type) 'player)
|
||||||
($ player obj)
|
($ player obj)
|
||||||
|
|
Loading…
Add table
Reference in a new issue