spook

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 7b89075c1dcdd190171090565da6823d5340680a
parent 703231a4a38b3c51bb6ec618a9ea8f3b3c33ec50
Author: Yuval Langer <yuval.langer@gmail.com>
Date:   Sun, 29 Oct 2023 17:11:46 +0200

Clamp player into the canvas.

Diffstat:
Mmain.scm | 16++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/main.scm b/main.scm @@ -1,4 +1,4 @@ -; SPDX-License-Identifier: AGPL-3.0-or-later +;;; SPDX-License-Identifier: AGPL-3.0-or-later ;;; Utility procedures: (define (alert message) @@ -261,8 +261,6 @@ (move-elements! dt falling-bricks) (move-elements! dt clouds) - (print (unless (null? falling-bricks) (car falling-bricks))) - ;; Periodically create a new cloud: (when (< next-cloud-time time) @@ -282,9 +280,11 @@ ;; Get input: (assq-set! player 'x - (- (cursor-x cursor) - (/ player-width - 2))) + ((o (cut - <> (/ player-width 2)) + (cut max <> (/ player-width 2)) + (cut min <> (- (.width canvas) + (/ player-width 2)))) + (cursor-x cursor))) (set! falling-bricks (filter-out-of-canvas-elements falling-bricks)) (set! clouds (filter-out-of-canvas-elements clouds)) @@ -297,15 +297,11 @@ #t) (if (assq-ref brick 'is-good) (begin - (print "is-good") (set! score (+ score 1))) (begin - (print "is-bad") (set! score (- score 1))))) bricks-collided)) - (print score) - (draw) (%inline "window.requestAnimationFrame" (callback loop))))