From 595895c0bf1565510ed23e5c95863cafae1daea7 Mon Sep 17 00:00:00 2001 From: Henrique Alves Date: Sun, 5 May 2024 01:13:04 +0300 Subject: basic GoL --- scripts/main.scm | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'scripts/main.scm') diff --git a/scripts/main.scm b/scripts/main.scm index f480053..7480777 100644 --- a/scripts/main.scm +++ b/scripts/main.scm @@ -6,12 +6,28 @@ (define camera-offset (make-point)) -(define (update) - (prompt-update) - +(define (update) + ;; (prompt-update) ;; it's eating the input! (if (rl-is-key-down KEY_DOWN) + (set! (point-y camera-offset) (+ (point-y camera-offset) 2)) + ) + + (if (rl-is-key-down KEY_UP) + (set! (point-y camera-offset) (+ (point-y camera-offset) -2)) + ) + + (if (rl-is-key-down KEY_LEFT) + (set! (point-x camera-offset) (+ (point-x camera-offset) -2)) + ) + + (if (rl-is-key-down KEY_RIGHT) + (set! (point-x camera-offset) (+ (point-x camera-offset) 2)) + ) + + (if (eq? (rl-get-key-pressed) KEY_SPACE) (run-step) ) + ) (define (draw) @@ -19,8 +35,8 @@ (for-each (lambda (cell) (rl-draw-rectangle - (* (car cell) 30) - (* (cdr cell) 30) + (+ (* (car cell) 30) (point-x camera-offset)) + (+ (* (cdr cell) 30) (point-y camera-offset)) 30 30 (make-color 190 100 255)) -- cgit v1.2.3