Fix bug where gem could be marked as collected even if move was undone.
This commit is contained in:
parent
3503aeb00b
commit
502b8262e5
2 changed files with 15 additions and 5 deletions
9
game.scm
9
game.scm
|
@ -196,6 +196,10 @@
|
|||
(define (next-level!)
|
||||
(let ((idx (+ *level-idx* 1)))
|
||||
(pk 'next-level idx)
|
||||
;; TODO: Maybe show a little achievement popup when all gems
|
||||
;; are collected?
|
||||
(when (with-goblins ($ (level-actor *level*) 'gem-collected?))
|
||||
(set! *gems* (cons *level-idx* *gems*)))
|
||||
(set! *level-idx* idx)
|
||||
(if (< idx (vector-length levels))
|
||||
(begin
|
||||
|
@ -272,10 +276,7 @@
|
|||
(('player-death x y)
|
||||
(play-sound-effect audio:die))
|
||||
(('pickup x y)
|
||||
(play-sound-effect audio:pickup)
|
||||
;; TODO: Maybe show a little achievement popup when all gems
|
||||
;; are collected?
|
||||
(set! *gems* (cons *level-idx* *gems*)))
|
||||
(play-sound-effect audio:pickup))
|
||||
(('emit x y)
|
||||
(play-sound-effect audio:emit))
|
||||
(('emitter-on x y)
|
||||
|
|
|
@ -396,6 +396,7 @@
|
|||
(('wire-state grid-info from from-x from-y) #f)
|
||||
(('update-wire-state grid-info neighbor-grid) #f)
|
||||
(('alive?) (not ($ picked-up?)))
|
||||
(('previously-collected?) previously-collected?)
|
||||
(('describe)
|
||||
(if previously-collected?
|
||||
`(ghost-gem ,position)
|
||||
|
@ -758,6 +759,7 @@
|
|||
(define player (spawn ^cell))
|
||||
(define objects (spawn ^cell '()))
|
||||
(define event-log (spawn ^event-log))
|
||||
(define gem-collected? (spawn ^cell))
|
||||
|
||||
;; Spatial partition
|
||||
(define (for-each-coord proc)
|
||||
|
@ -874,8 +876,14 @@
|
|||
(cons obj (lp rest))
|
||||
(match ($ obj 'position)
|
||||
(#(x y z)
|
||||
;; Remove from spatial partition.
|
||||
(let ((cell (grid-ref grid x y)))
|
||||
($ cell (delq obj ($ cell))))
|
||||
;; If this is a gem, then set a flag that the
|
||||
;; player has collected it.
|
||||
(when (and (eq? ($ obj 'type) 'gem)
|
||||
(not ($ obj 'previously-collected?)))
|
||||
($ gem-collected? #t))
|
||||
(lp rest)))))))))
|
||||
(define (tick-object obj)
|
||||
(let ((prev-pos ($ obj 'position)))
|
||||
|
@ -914,4 +922,5 @@
|
|||
(let ((cell (grid-ref grid x y)))
|
||||
($ cell (cons obj ($ cell)))))))
|
||||
(('flush-events)
|
||||
($ event-log 'flush))))
|
||||
($ event-log 'flush))
|
||||
(('gem-collected?) ($ gem-collected?))))
|
||||
|
|
Loading…
Add table
Reference in a new issue