diff options
author | Henrique Alves <henrique.alves@itsjungle.xyz> | 2024-05-05 01:13:04 +0300 |
---|---|---|
committer | Henrique Alves <henrique.alves@itsjungle.xyz> | 2024-05-05 01:13:04 +0300 |
commit | 595895c0bf1565510ed23e5c95863cafae1daea7 (patch) | |
tree | 33fd5db8bff6a94476a84a72b2b2073960e05114 /scripts | |
parent | 72fc0084e45314c7ebfa641f2a20e2ecff358914 (diff) | |
download | gamejam-slgj-2024-595895c0bf1565510ed23e5c95863cafae1daea7.tar.gz gamejam-slgj-2024-595895c0bf1565510ed23e5c95863cafae1daea7.tar.bz2 gamejam-slgj-2024-595895c0bf1565510ed23e5c95863cafae1daea7.zip |
basic GoL
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/gol.scm | 6 | ||||
-rw-r--r-- | scripts/keys.scm | 2 | ||||
-rw-r--r-- | scripts/main.scm | 26 |
3 files changed, 27 insertions, 7 deletions
diff --git a/scripts/gol.scm b/scripts/gol.scm index f95dc91..7e10d2d 100644 --- a/scripts/gol.scm +++ b/scripts/gol.scm @@ -4,8 +4,10 @@ '((-1 . -1) (0 . -1) (1 . -1) (-1 . 0) (1 . 0) (-1 . 1) (0 . 1) (1 . 1))) (set! (current-cells '(1 . 1)) #t) -(set! (current-cells '(1 . 2)) #t) -(set! (current-cells '(1 . 3)) #t) +(set! (current-cells '(2 . 1)) #t) +(set! (current-cells '(3 . 1)) #t) +(set! (current-cells '(3 . 0)) #t) +(set! (current-cells '(2 . -1)) #t) (define sum-cells (lambda (c1 c2) diff --git a/scripts/keys.scm b/scripts/keys.scm index 1ed31bf..83a683c 100644 --- a/scripts/keys.scm +++ b/scripts/keys.scm @@ -1,5 +1,7 @@ (define KEY_ENTER 257) (define KEY_BACKSPACE 259) +(define KEY_SPACE 32) (define KEY_RIGHT 262) (define KEY_LEFT 263) (define KEY_DOWN 264) +(define KEY_UP 265) 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)) |