From 2bdb665cffff93721bbd38b3809a7c420dff2f1c Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 12 Apr 2020 21:59:35 -0400 Subject: Day 3 progress. --- assets/images/explosion.png | Bin 0 -> 410 bytes assets/images/explosion.xcf | Bin 0 -> 1199 bytes assets/images/player-bullets.png | Bin 620 -> 620 bytes assets/sounds/explosion.wav | Bin 0 -> 33510 bytes assets/sounds/player-death.wav | Bin 0 -> 66010 bytes assets/sounds/player-missile.wav | Bin 0 -> 65490 bytes assets/sounds/player-shoot.wav | Bin 0 -> 806 bytes guix.scm | 4 +- lisparuga.scm | 88 ++++++------ lisparuga/enemy.scm | 10 +- lisparuga/game.scm | 281 ++++++++++++++++++++++++++++++++------- lisparuga/node-2d.scm | 26 +++- lisparuga/player.scm | 51 +++++-- 13 files changed, 355 insertions(+), 105 deletions(-) create mode 100644 assets/images/explosion.png create mode 100644 assets/images/explosion.xcf create mode 100644 assets/sounds/explosion.wav create mode 100644 assets/sounds/player-death.wav create mode 100644 assets/sounds/player-missile.wav create mode 100644 assets/sounds/player-shoot.wav diff --git a/assets/images/explosion.png b/assets/images/explosion.png new file mode 100644 index 0000000..2146226 Binary files /dev/null and b/assets/images/explosion.png differ diff --git a/assets/images/explosion.xcf b/assets/images/explosion.xcf new file mode 100644 index 0000000..3b3f077 Binary files /dev/null and b/assets/images/explosion.xcf differ diff --git a/assets/images/player-bullets.png b/assets/images/player-bullets.png index eb9c4cb..5aecd50 100644 Binary files a/assets/images/player-bullets.png and b/assets/images/player-bullets.png differ diff --git a/assets/sounds/explosion.wav b/assets/sounds/explosion.wav new file mode 100644 index 0000000..bcc4865 Binary files /dev/null and b/assets/sounds/explosion.wav differ diff --git a/assets/sounds/player-death.wav b/assets/sounds/player-death.wav new file mode 100644 index 0000000..c0d3bd6 Binary files /dev/null and b/assets/sounds/player-death.wav differ diff --git a/assets/sounds/player-missile.wav b/assets/sounds/player-missile.wav new file mode 100644 index 0000000..50ef045 Binary files /dev/null and b/assets/sounds/player-missile.wav differ diff --git a/assets/sounds/player-shoot.wav b/assets/sounds/player-shoot.wav new file mode 100644 index 0000000..ec3bb6b Binary files /dev/null and b/assets/sounds/player-shoot.wav differ diff --git a/guix.scm b/guix.scm index 215e71e..ac35a49 100644 --- a/guix.scm +++ b/guix.scm @@ -125,7 +125,7 @@ SDL2 C shared library via the foreign function interface.") (license lgpl3+)))) (define chickadee - (let ((commit "f2721b20704a0e5a4960d490d0ba465feccdf192")) + (let ((commit "b15a8b5be99df32e86af8bfb6f5dbdaacceda776")) (package (name "chickadee") (version (string-append "0.5.0-1." (string-take commit 7))) @@ -136,7 +136,7 @@ SDL2 C shared library via the foreign function interface.") (commit commit))) (sha256 (base32 - "0cs838mr7r92kyihvvya2nbywd0g6rfb7qgcxaqivyh3qyss4zi8")))) + "17hba2mrvrdz91lgw92lf7qv4i6i2f5ypwrlr45fy4nljh52870c")))) (build-system gnu-build-system) (arguments '(#:make-flags '("GUILE_AUTO_COMPILE=0") diff --git a/lisparuga.scm b/lisparuga.scm index b552a7a..dc611cd 100644 --- a/lisparuga.scm +++ b/lisparuga.scm @@ -44,10 +44,13 @@ (define-asset background (load-image (scope-asset "images/background.png"))) (define-class () - (state #:accessor state #:init-value 'play)) + (state #:accessor state #:init-value 'init)) -(define (game-over? lisparuga) - (zero? (lives (& lisparuga actor-canvas game player)))) +(define-method (game-over? (lisparuga )) + (game-over? (& lisparuga game))) + +(define-method (complete? (lisparuga )) + (complete? (& lisparuga game))) (define-method (on-boot (lisparuga )) ;; Scale a small framebuffer up to the window size. @@ -58,34 +61,27 @@ #:height %framebuffer-height) #:area (let ((wc (window-config (current-kernel)))) (make-rect 0 0 (window-width wc) (window-height wc)))))) - ;; This 160x240 canvas is where the actual game actors will get - ;; rendered. - (let ((actor-canvas (make - #:name 'actor-canvas - #:rank 1 - #:views (list (make - #:camera (make - #:width 160 - #:height 240) - #:area (make-rect 80 0 160 240) - #:clear-color (make-color 0.0 0.0 0.0 1.0)))))) - (attach-to lisparuga - (make - #:name 'background - #:rank 0 - #:texture background) - actor-canvas) - (new-game-transition lisparuga))) + (attach-to lisparuga + (make + #:name 'background + #:rank 0 + #:texture background)) + (new-game-transition lisparuga)) (define (new-game-transition lisparuga) (set! (state lisparuga) 'play) (let ((game-over (& lisparuga game-over))) (and game-over (detach game-over))) - (let ((old-game (& lisparuga actor-canvas game))) + (let ((old-game (& lisparuga game))) (and old-game (detach old-game))) - (attach-to (& lisparuga actor-canvas) (make #:name 'game))) + (attach-to lisparuga + (make + #:name 'game + #:rank 1 + #:position (vec2 80.0 0.0))) + (set! (state lisparuga) 'play)) -(define (game-over-transition lisparuga) +(define-method (game-over-transition (lisparuga )) (set! (state lisparuga) 'game-over) (let ((game-over (make #:name 'game-over @@ -94,21 +90,33 @@ (make