summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gol.scm6
-rw-r--r--scripts/keys.scm2
-rw-r--r--scripts/main.scm26
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))