Avoid updating position assertions if it hasn't changed
This commit is contained in:
parent
ba7170e7a4
commit
6fe1ac6e24
|
@ -385,14 +385,15 @@
|
||||||
impulse-vec)])
|
impulse-vec)])
|
||||||
'()))
|
'()))
|
||||||
|
|
||||||
(define ((update-piece g new-pos new-vel) s)
|
(define ((update-piece g old-pos new-pos new-vel) s)
|
||||||
(define id (game-piece-configuration-id g))
|
(define id (game-piece-configuration-id g))
|
||||||
(transition
|
(transition
|
||||||
(struct-copy physics-state s
|
(struct-copy physics-state s
|
||||||
[positions (hash-set (physics-state-positions s) id new-pos)]
|
[positions (hash-set (physics-state-positions s) id new-pos)]
|
||||||
[velocities (hash-set (physics-state-velocities s) id new-vel)])
|
[velocities (hash-set (physics-state-velocities s) id new-vel)])
|
||||||
(patch-seq (retract (position id ? ?))
|
(and (not (v= old-pos new-pos))
|
||||||
(assert (position id new-pos (game-piece-configuration-size g))))))
|
(patch-seq (retract (position id ? ?))
|
||||||
|
(assert (position id new-pos (game-piece-configuration-size g)))))))
|
||||||
|
|
||||||
(define (find-support p size s)
|
(define (find-support p size s)
|
||||||
(match-define (vector p-left p-top) p)
|
(match-define (vector p-left p-top) p)
|
||||||
|
@ -477,14 +478,14 @@
|
||||||
;; - which will avoid the "sticking to the wall" artifact
|
;; - which will avoid the "sticking to the wall" artifact
|
||||||
(define final-vel (if (v= pos1 final-pos) vel1 (vector 0 0))) ;; stop at collision
|
(define final-vel (if (v= pos1 final-pos) vel1 (vector 0 0))) ;; stop at collision
|
||||||
;; TODO: collision with enemies
|
;; TODO: collision with enemies
|
||||||
((update-piece g final-pos final-vel) s))
|
((update-piece g pos0 final-pos final-vel) s))
|
||||||
|
|
||||||
(define (evaluate-jump-request id s)
|
(define (evaluate-jump-request id s)
|
||||||
(define g (piece-cfg s id))
|
(define g (piece-cfg s id))
|
||||||
(define pos (piece-pos s id))
|
(define pos (piece-pos s id))
|
||||||
(define support (find-support pos (game-piece-configuration-size g) s))
|
(define support (find-support pos (game-piece-configuration-size g) s))
|
||||||
(and support
|
(and support
|
||||||
((update-piece g (v+ pos (vector 0 -1)) jump-vel) s)))
|
((update-piece g pos (v+ pos (vector 0 -1)) jump-vel) s)))
|
||||||
|
|
||||||
(spawn (lambda (e s)
|
(spawn (lambda (e s)
|
||||||
(match e
|
(match e
|
||||||
|
|
Loading…
Reference in New Issue