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 | |
parent | 72fc0084e45314c7ebfa641f2a20e2ecff358914 (diff) | |
download | gamejam-slgj-2024-595895c0bf1565510ed23e5c95863cafae1daea7.tar.gz gamejam-slgj-2024-595895c0bf1565510ed23e5c95863cafae1daea7.tar.bz2 gamejam-slgj-2024-595895c0bf1565510ed23e5c95863cafae1daea7.zip |
basic GoL
-rw-r--r-- | scripts/gol.scm | 6 | ||||
-rw-r--r-- | scripts/keys.scm | 2 | ||||
-rw-r--r-- | scripts/main.scm | 26 | ||||
-rw-r--r-- | sources/main.c | 1 | ||||
-rw-r--r-- | sources/repl/repl.c | 0 | ||||
-rw-r--r-- | sources/repl/repl.h | 0 | ||||
-rw-r--r-- | sources/rl/shapes.h | 8 |
7 files changed, 32 insertions, 11 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)) diff --git a/sources/main.c b/sources/main.c index 3c2e1da..7196bc4 100644 --- a/sources/main.c +++ b/sources/main.c @@ -10,6 +10,7 @@ #include "rl/texture.h" #include "rl/core.h" #include "rl/shapes.h" +#include "repl/repl.h" #include <math.h> #include <stdio.h> diff --git a/sources/repl/repl.c b/sources/repl/repl.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sources/repl/repl.c diff --git a/sources/repl/repl.h b/sources/repl/repl.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sources/repl/repl.h diff --git a/sources/rl/shapes.h b/sources/rl/shapes.h index 0033a5b..10d38eb 100644 --- a/sources/rl/shapes.h +++ b/sources/rl/shapes.h @@ -6,10 +6,10 @@ static s7_pointer rl_draw_rectangle(s7_scheme *s7, s7_pointer args) { Color *c = (Color *)s7_c_object_value(s7_car(s7_cdr(s7_cdr(s7_cdr(s7_cdr(args)))))); - DrawRectangle(s7_integer(s7_car(args)), - s7_integer(s7_car(s7_cdr(args))), - s7_integer(s7_car(s7_cdr(s7_cdr(args)))), - s7_integer(s7_car(s7_cdr(s7_cdr(s7_cdr(args))))), + DrawRectangle(s7_real(s7_car(args)), + s7_real(s7_car(s7_cdr(args))), + s7_real(s7_car(s7_cdr(s7_cdr(args)))), + s7_real(s7_car(s7_cdr(s7_cdr(s7_cdr(args))))), *c); return(NULL); |