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 @@ + + + + + +110,169,151,170,91,189,89,110,190,190,191,191,130,169,190,189,129,189,209,91, +211,190,112,131,190,91,129,191,170,150,171,129,111,90,170,150,211,211,191,130, +151,91,89,150,189,210,110,170,89,131,151,90,109,151,151,189,190,110,169,190, +111,189,130,129,110,129,90,209,191,170,191,209,151,109,210,189,170,209,90,169, +189,89,111,151,111,129,210,129,151,151,169,129,149,189,211,131,129,89,90,131, +89,211,129,209,109,130,171,109,91,170,111,170,89,210,211,89,191,151,111,210, +110,110,129,111,91,90,170,171,110,170,170,110,111,190,210,209,189,111,211,189, +129,189,129,169,109,189,171,211,89,109,90,190,151,150,149,210,149,111,150,190, +130,131,81,82,82,83,82,82,82,82,83,82,83,82,82,82,82,84,211,170, +189,149,105,24,24,24,24,24,24,24,24,24,24,24,24,24,24,86,150,89, +91,169,85,24,24,24,24,24,24,24,24,24,24,28,24,24,24,86,150,190, +131,110,105,24,24,24,24,24,24,24,24,24,24,24,24,24,24,86,110,130, +129,171,101,102,102,102,102,102,102,102,102,102,102,102,102,102,102,104,91,211, +211,171,190,89,171,110,209,171,110,210,191,131,91,150,150,151,92,149,129,190, +90,170,111,170,209,111,169,190,151,209,111,91,190,211,171,170,130,171,111,211 + + + + + + + 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 @@ + + + + + +109,209,90,210,169,150,105,24,24,24,24,24,24,86,211,211,90,151,89,189, +209,191,131,170,129,189,85,24,24,24,24,24,24,106,91,150,110,149,109,149, +91,111,211,191,149,189,85,24,24,24,24,24,24,106,210,190,210,89,150,91, +211,130,111,90,209,189,85,24,28,24,24,24,24,106,191,191,170,130,112,109, +110,151,109,150,111,111,105,24,24,24,24,24,24,106,129,210,210,150,89,150, +149,210,89,111,189,91,101,102,103,103,103,102,103,104,91,131,91,130,171,189, +211,171,209,90,170,150,189,150,189,210,129,91,130,131,170,90,211,129,151,131, +209,130,91,169,130,129,89,169,190,91,89,211,90,191,149,210,210,211,110,210, +91,189,169,170,110,89,130,210,89,191,89,91,131,110,170,191,111,211,110,91, +131,191,210,91,171,171,81,82,83,82,83,83,82,84,131,189,151,170,110,190, +111,90,92,129,210,89,85,24,24,24,24,24,24,86,131,90,209,210,189,89, +169,131,151,91,110,170,85,24,24,24,24,24,24,106,209,130,91,209,131,191, +109,209,191,110,189,151,85,24,24,24,24,24,24,86,210,151,109,151,211,170, +191,131,110,129,131,90,85,24,24,24,24,24,24,106,111,169,209,90,130,90, +90,210,151,89,111,90,105,24,24,24,24,24,24,86,209,189,109,210,151,110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + +169,150,211,190,211,131,129,149,150,190,191,190,109,189,210,211,149,210,111,89, +111,171,91,90,109,110,171,129,129,170,189,210,191,169,109,129,109,151,210,109, +191,90,190,171,209,151,170,81,82,82,83,83,84,91,169,112,189,150,130,150, +149,150,170,150,169,130,129,105,24,24,28,24,86,190,191,209,170,89,91,169, +210,209,110,150,150,131,109,85,24,24,24,24,86,111,191,111,110,189,150,130, +82,83,83,82,83,82,82,108,31,31,31,24,107,82,82,84,169,81,82,83, +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,86,109,105,24,24, +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,86,150,105,24,24, +24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,86,149,31,24,24, +102,102,102,103,102,102,102,88,31,31,31,24,87,102,103,104,209,101,103,102, +210,209,190,89,89,169,131,105,24,24,24,24,86,89,109,171,189,189,111,151, +211,191,110,130,91,211,171,105,24,24,24,24,106,111,170,149,189,130,90,171, +130,92,150,109,169,129,150,85,24,24,24,24,86,171,209,189,189,151,170,150, +211,209,169,209,131,89,169,85,24,24,24,24,86,131,131,171,151,91,91,151, +170,149,190,131,171,169,150,101,103,102,103,102,104,191,211,170,150,110,150,130 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + +171,110,91,89,90,111,91,150,189,171,129,210,110,91,169,89,89,151,149,189, +130,170,210,169,211,209,191,210,131,130,131,112,151,211,150,91,150,171,191,110, +189,189,131,109,131,210,149,209,91,189,110,191,170,209,109,169,190,89,131,149, +150,210,111,169,210,90,190,131,170,209,90,131,89,151,110,131,209,149,111,109, +109,189,150,81,82,82,82,83,83,82,82,83,82,84,171,90,191,169,170,90, +150,131,129,85,24,24,24,24,24,24,24,31,24,86,149,209,91,111,151,149, +209,190,169,85,24,24,24,24,31,24,24,24,24,107,82,82,82,84,90,151, +90,131,210,105,24,24,3,3,3,3,3,3,24,31,24,24,24,106,151,190, +129,110,150,85,24,24,24,24,24,24,24,24,24,24,24,24,28,86,129,91, +89,171,171,85,24,24,24,24,24,24,24,24,24,31,24,24,24,106,169,210, +190,131,169,85,24,24,24,24,24,24,24,24,24,87,102,103,102,104,129,129, +130,110,149,101,102,103,103,102,103,103,103,102,102,104,91,211,151,189,110,89, +90,209,131,189,169,90,190,149,131,211,109,151,130,89,150,171,91,210,130,129, +91,191,211,169,209,92,150,190,131,190,169,150,150,170,91,149,149,130,171,209, +171,151,210,91,209,189,189,150,111,149,149,189,90,129,109,169,91,131,129,210 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + +151,209,210,171,209,211,209,129,111,90,211,210,169,150,191,190,171,189,149,129, +191,190,210,170,190,210,190,149,89,151,191,110,211,91,169,210,209,89,130,129, +171,151,149,110,91,190,150,170,109,191,131,90,209,129,89,209,209,209,90,109, +189,171,189,81,82,83,82,82,82,83,82,82,82,82,84,89,150,112,90,211, +149,210,151,85,24,24,3,3,3,24,24,24,24,24,86,111,189,151,111,151, +130,150,191,105,24,24,24,24,24,24,24,24,24,24,106,90,91,151,169,150, +131,209,111,105,24,24,24,24,24,24,3,3,3,24,86,169,151,210,111,151, +110,150,91,105,24,24,24,24,24,24,24,24,24,24,106,171,91,111,170,109, +189,150,190,105,24,24,24,24,24,24,24,31,31,24,86,110,109,170,129,190, +209,92,209,105,24,24,24,24,24,24,24,31,24,24,106,191,190,110,129,130, +189,189,170,105,24,24,24,24,24,24,24,31,24,28,106,150,111,209,130,209, +129,91,210,101,103,103,103,102,102,102,103,102,102,103,104,189,109,151,210,170, +211,191,210,191,211,150,151,89,129,130,129,130,209,89,150,91,190,91,170,150, +190,170,210,210,109,191,169,150,89,171,149,130,130,150,111,90,89,191,90,170, +150,91,129,171,149,109,150,89,169,210,111,190,129,91,190,169,169,171,109,90 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + +151,110,111,90,210,129,211,111,211,190,169,130,209,90,189,191,191,89,110,131, +210,210,91,149,131,170,171,190,91,131,209,109,110,91,131,209,171,209,171,90, +91,129,91,190,91,149,129,209,89,91,130,91,209,89,211,150,150,211,169,90, +191,91,81,82,82,82,82,82,82,83,82,82,82,84,90,191,131,90,130,109, +131,189,105,24,24,24,24,24,24,31,24,24,24,86,110,90,209,110,91,191, +151,191,85,24,24,24,24,24,24,31,24,24,24,86,191,90,190,130,169,211, +211,191,85,24,24,24,24,24,24,24,24,24,24,107,83,83,82,84,149,149, +191,150,85,24,3,3,3,3,24,3,3,3,24,31,31,31,28,86,109,171, +170,211,85,24,24,24,24,24,24,24,24,24,24,31,31,31,24,106,190,131, +189,130,85,24,24,24,24,24,24,24,24,24,24,24,24,24,24,106,171,110, +189,189,85,24,24,24,24,24,24,24,24,24,24,87,103,103,103,104,150,110, +91,210,85,24,24,24,24,24,24,24,24,24,24,106,110,210,90,190,109,170, +130,190,101,102,102,102,103,103,103,102,103,102,103,104,171,171,111,191,189,209, +109,131,151,111,209,150,211,130,210,91,130,90,151,110,151,110,130,171,131,210, +210,150,209,209,169,191,169,209,171,169,90,151,89,209,91,129,111,151,149,130 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + +129,109,110,191,189,169,169,191,110,169,150,91,110,171,210,111,110,170,151,169, +211,170,150,110,90,209,171,209,170,149,110,190,149,90,111,191,191,150,209,151, +210,210,170,169,149,191,189,169,169,151,149,169,169,190,130,110,209,169,109,209, +90,190,130,170,189,91,129,209,109,169,171,211,151,169,89,131,89,191,211,211, +111,130,111,191,91,210,169,89,190,109,171,130,211,91,191,149,149,209,191,169, +191,171,150,89,169,190,171,109,129,110,169,190,190,130,170,151,131,170,109,151, +211,109,190,109,189,130,191,130,149,190,149,191,151,111,109,171,210,191,209,209, +151,90,91,110,209,170,211,151,129,109,191,189,189,191,129,89,171,151,130,209, +170,91,191,209,191,89,151,90,190,209,170,171,169,110,169,131,129,129,90,150, +211,130,171,150,151,131,91,129,189,89,109,189,169,130,111,150,110,211,170,151, +129,110,189,151,189,91,170,151,89,131,209,130,129,170,191,91,209,90,189,110, +209,130,110,189,89,129,90,191,130,171,131,110,110,131,130,110,110,110,111,151, +129,211,129,91,129,91,210,129,109,89,131,89,169,191,211,110,170,209,91,111, +109,210,109,191,189,171,111,209,89,90,130,91,191,90,191,151,109,190,191,90, +169,191,90,211,109,90,150,170,109,109,109,130,90,189,111,169,131,109,169,209 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +