diff --git a/Makefile b/Makefile
index ca421b3..d048267 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,12 @@ modules = \
modules/srfi/srfi-11.scm
levels = \
+ modules/game/levels/tutorial-1.scm \
+ modules/game/levels/tutorial-2.scm \
+ modules/game/levels/tutorial-3.scm \
+ modules/game/levels/tutorial-4.scm \
+ modules/game/levels/tutorial-5.scm \
+ modules/game/levels/tutorial-6.scm \
modules/game/levels/level-1.scm \
modules/game/levels/level-2.scm \
modules/game/levels/level-3.scm \
diff --git a/game.scm b/game.scm
index 7491bd2..6031204 100644
--- a/game.scm
+++ b/game.scm
@@ -29,6 +29,12 @@
(game audio)
(game effects)
(game level)
+ (game levels tutorial-1)
+ (game levels tutorial-2)
+ (game levels tutorial-3)
+ (game levels tutorial-4)
+ (game levels tutorial-5)
+ (game levels tutorial-6)
(game levels level-1)
(game levels level-2)
(game levels level-3)
@@ -90,8 +96,14 @@
(define levels
(vector
- load-level-1
- load-level-2
+ load-tutorial-1
+ load-tutorial-2
+ load-tutorial-3
+ load-tutorial-4
+ load-tutorial-5
+ load-tutorial-6
+ ;; load-level-1
+ ;; load-level-2
load-level-3
load-level-4))
(define *level-idx* #f)
@@ -425,8 +437,11 @@
(for-each draw-object *objects*)
(let ((alive? (with-goblins ($ (level-player *level*) 'alive?))))
(unless alive?
- (set-fill-color! context "rgba(0,0,0,0.65)")
+ (set-global-alpha! context 0.7)
+ (set-fill-color! context "#222034")
(fill-rect context 0.0 0.0 game-width game-height)
+ (set-global-alpha! context 1.0)
+ (set-font! context "normal 32px monogram")
(set-fill-color! context "#ffffff")
(set-text-align! context "center")
(fill-text context "OUCH... x_x" (/ game-width 2.0) (/ game-height 2.0)))))
@@ -527,8 +542,16 @@
;; REMOVE BEFORE RELEASE!!!!
((string=? key key:confirm)
(next-level!))))
- ;; Pressing any key resets the game.
- ('win (reset-game!)))))
+ ;; Pressing any bound key resets the game.
+ ('win
+ (when (or
+ (string=? key key:left)
+ (string=? key key:right)
+ (string=? key key:up)
+ (string=? key key:down)
+ (string=? key key:undo)
+ (string=? key key:confirm))
+ (reset-game!))))))
;; Canvas and event loop setup
(define canvas (get-element-by-id "canvas"))
diff --git a/modules/game/actors.scm b/modules/game/actors.scm
index 141584e..a566c44 100644
--- a/modules/game/actors.scm
+++ b/modules/game/actors.scm
@@ -125,16 +125,18 @@
(#(x y z)
(match offset
(#(dx dy)
- (let ((x (+ x dx))
- (y (+ y dy)))
- (let ((occupant-types
- (map (lambda (obj) ($ obj 'type))
- ($ grid-info 'occupants x y))))
- (match occupant-types
- ((or () ('switch))
- ($ pushed? #t)
- ($ position (vector x y z)))
- (_ #f))))))))))
+ (match ($ grid-info 'dimensions)
+ (#(w h)
+ (let ((x (modulo (+ x dx) w))
+ (y (modulo (+ y dy) h)))
+ (let ((occupant-types
+ (map (lambda (obj) ($ obj 'type))
+ ($ grid-info 'occupants x y))))
+ (match occupant-types
+ ((or () ('switch))
+ ($ pushed? #t)
+ ($ position (vector x y z)))
+ (_ #f))))))))))))
(('pushed?) ($ pushed?))))
(define (^clock-emitter bcom x y interval)
@@ -325,7 +327,7 @@
(('exit obj grid-info) #f)
(('wire-state grid-info from from-x from-y) #f)
(('update-wire-state grid-info neighbor-grid) #f)
- (('alive?) (not ($ picked-up?)))
+ (('alive?) (pk 'gem-alive? (not ($ picked-up?))))
(('describe) `(gem ,position))
(('collide other offset grid-info)
(when (eq? ($ other 'type) 'player)
@@ -634,9 +636,12 @@
(match ($ position)
(#(x y z)
(match ($ velocity)
+ (#(0 0) (values))
(#(dx dy)
- ($ position (vector (+ x dx) (+ y dy) z))
- ($ velocity #(0 0)))))))
+ (match ($ grid-info 'dimensions)
+ (#(w h)
+ ($ position (vector (modulo (+ x dx) w) (modulo (+ y dy) h) z))
+ ($ velocity #(0 0)))))))))
(('post-tick grid-info)
;; Search for objects that were fine to step onto last turn, but
;; have become deadly this turn.
@@ -746,12 +751,10 @@
;; Read-only access to query the grid, but can write events.
(define (^grid-info bcom)
(match-lambda*
- (('occupied? x y)
- (not (null? ($ (grid-ref grid x y)))))
- (('occupants x y)
- ($ (grid-ref grid x y)))
- (('append-event event)
- ($ event-log 'append event))))
+ (('dimensions) (vector width height))
+ (('occupied? x y) (not (null? ($ (grid-ref/wrap grid x y)))))
+ (('occupants x y) ($ (grid-ref/wrap grid x y)))
+ (('append-event event) ($ event-log 'append event))))
(define grid-info (spawn ^grid-info))
(define (delq item lst)
diff --git a/modules/game/levels/tutorial-1.tmx b/modules/game/levels/tutorial-1.tmx
new file mode 100644
index 0000000..daef562
--- /dev/null
+++ b/modules/game/levels/tutorial-1.tmx
@@ -0,0 +1,27 @@
+
+
diff --git a/modules/game/levels/tutorial-2.tmx b/modules/game/levels/tutorial-2.tmx
new file mode 100644
index 0000000..096b415
--- /dev/null
+++ b/modules/game/levels/tutorial-2.tmx
@@ -0,0 +1,57 @@
+
+
diff --git a/modules/game/levels/tutorial-3.tmx b/modules/game/levels/tutorial-3.tmx
new file mode 100644
index 0000000..dd7f2f6
--- /dev/null
+++ b/modules/game/levels/tutorial-3.tmx
@@ -0,0 +1,99 @@
+
+
diff --git a/modules/game/levels/tutorial-4.tmx b/modules/game/levels/tutorial-4.tmx
new file mode 100644
index 0000000..c17704e
--- /dev/null
+++ b/modules/game/levels/tutorial-4.tmx
@@ -0,0 +1,59 @@
+
+
diff --git a/modules/game/levels/tutorial-5.tmx b/modules/game/levels/tutorial-5.tmx
new file mode 100644
index 0000000..cb2a6e7
--- /dev/null
+++ b/modules/game/levels/tutorial-5.tmx
@@ -0,0 +1,64 @@
+
+
diff --git a/modules/game/levels/tutorial-6.tmx b/modules/game/levels/tutorial-6.tmx
new file mode 100644
index 0000000..857d7c4
--- /dev/null
+++ b/modules/game/levels/tutorial-6.tmx
@@ -0,0 +1,88 @@
+
+
diff --git a/modules/game/levels/tutorial-7.tmx b/modules/game/levels/tutorial-7.tmx
new file mode 100644
index 0000000..c935eb5
--- /dev/null
+++ b/modules/game/levels/tutorial-7.tmx
@@ -0,0 +1,64 @@
+
+