[feat] add guard clauses
This commit is contained in:
parent
8412883500
commit
16e5dc1cdf
1 changed files with 15 additions and 11 deletions
10
game.scm
10
game.scm
|
@ -79,17 +79,21 @@
|
|||
(define (collide-gelement! x y parenthes)
|
||||
(dprint "x" x)
|
||||
(dprint "y" y)
|
||||
(let ((e (vector-ref (vector-ref (level-grid *level*) y) x)))
|
||||
(if (and (>= x 0) (>= y 0))
|
||||
(let ((e (vector-ref (vector-ref (level-grid *level*) y) x))
|
||||
(len (vector-length (level-grid *level*))))
|
||||
(dprint "content" (parentheses-content parenthes))
|
||||
(dprint "par pos" (parentheses-pos parenthes))
|
||||
(if (and (<= x len) (<= y len))
|
||||
(if (gelement-interact? (gelement-type e))
|
||||
(begin
|
||||
(dprint "Move!")
|
||||
(set-grid! x y air)
|
||||
(set-parentheses-pos! parenthes (cons x y))
|
||||
(set-parentheses-content! parenthes (append (parentheses-content parenthes) (gelement-content e)))
|
||||
(dprint "after-content" (parentheses-content parenthes))
|
||||
(dprint "grid" (level-grid *level*)))
|
||||
(dprint "after-content" (parentheses-content parenthes)))
|
||||
(dprint "Boop!"))))
|
||||
(dprint "Boop!")))
|
||||
|
||||
(define (collide-pareneheses! level)
|
||||
(let ((left-parenthes (level-left-parenthes level))
|
||||
|
|
Loading…
Reference in a new issue