From 729f0b687b975e60f338831bcb0d59fad776f3e1 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 12 Apr 2020 09:03:41 -0400 Subject: Day 2 progress. --- assets/images/background.xcf | Bin 8943 -> 6681 bytes assets/images/clouds.png | Bin 42047 -> 608 bytes assets/images/clouds.xcf | Bin 0 -> 1404 bytes assets/images/enemies.png | Bin 0 -> 1649 bytes assets/images/enemies.xcf | Bin 0 -> 6836 bytes assets/images/enemy-bullets.png | Bin 0 -> 313 bytes assets/images/enemy-bullets.xcf | Bin 0 -> 1050 bytes assets/images/player-bullets.png | Bin 417 -> 620 bytes assets/images/player-bullets.xcf | Bin 1415 -> 2645 bytes guix.scm | 4 +- lisparuga.scm | 78 +++++++++++++++----- lisparuga/actor.scm | 35 ++++++--- lisparuga/bullets.scm | 60 ++++++++++------ lisparuga/enemy.scm | 75 ++++++++++++++++++- lisparuga/game.scm | 96 +++++++++++++++++++++++-- lisparuga/kernel.scm | 6 +- lisparuga/node-2d.scm | 1 + lisparuga/player.scm | 152 ++++++++++++++++++++++++++++++++++----- 18 files changed, 427 insertions(+), 80 deletions(-) create mode 100644 assets/images/clouds.xcf create mode 100644 assets/images/enemies.png create mode 100644 assets/images/enemies.xcf create mode 100644 assets/images/enemy-bullets.png create mode 100644 assets/images/enemy-bullets.xcf diff --git a/assets/images/background.xcf b/assets/images/background.xcf index 895d445..5ed24cf 100644 Binary files a/assets/images/background.xcf and b/assets/images/background.xcf differ diff --git a/assets/images/clouds.png b/assets/images/clouds.png index ef20e9c..c498ab3 100644 Binary files a/assets/images/clouds.png and b/assets/images/clouds.png differ diff --git a/assets/images/clouds.xcf b/assets/images/clouds.xcf new file mode 100644 index 0000000..141fc68 Binary files /dev/null and b/assets/images/clouds.xcf differ diff --git a/assets/images/enemies.png b/assets/images/enemies.png new file mode 100644 index 0000000..574e6af Binary files /dev/null and b/assets/images/enemies.png differ diff --git a/assets/images/enemies.xcf b/assets/images/enemies.xcf new file mode 100644 index 0000000..3cf608a Binary files /dev/null and b/assets/images/enemies.xcf differ diff --git a/assets/images/enemy-bullets.png b/assets/images/enemy-bullets.png new file mode 100644 index 0000000..ce7c73a Binary files /dev/null and b/assets/images/enemy-bullets.png differ diff --git a/assets/images/enemy-bullets.xcf b/assets/images/enemy-bullets.xcf new file mode 100644 index 0000000..5bd7ceb Binary files /dev/null and b/assets/images/enemy-bullets.xcf differ diff --git a/assets/images/player-bullets.png b/assets/images/player-bullets.png index 8a3a990..eb9c4cb 100644 Binary files a/assets/images/player-bullets.png and b/assets/images/player-bullets.png differ diff --git a/assets/images/player-bullets.xcf b/assets/images/player-bullets.xcf index 402a9bc..1977d7a 100644 Binary files a/assets/images/player-bullets.xcf and b/assets/images/player-bullets.xcf differ diff --git a/guix.scm b/guix.scm index 159842b..215e71e 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 "94823dc194ac805939f91a68ca01d9c778f56b2b")) + (let ((commit "f2721b20704a0e5a4960d490d0ba465feccdf192")) (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 - "1qp1x5zmhg1z36hg7h3pkbv3rd2rz3kssgm2hr4cib2qh834vywz")))) + "0cs838mr7r92kyihvvya2nbywd0g6rfb7qgcxaqivyh3qyss4zi8")))) (build-system gnu-build-system) (arguments '(#:make-flags '("GUILE_AUTO_COMPILE=0") diff --git a/lisparuga.scm b/lisparuga.scm index 828ba58..b552a7a 100644 --- a/lisparuga.scm +++ b/lisparuga.scm @@ -33,6 +33,7 @@ #:use-module (lisparuga kernel) #:use-module (lisparuga node) #:use-module (lisparuga node-2d) + #:use-module (lisparuga player) #:use-module (lisparuga scene) #:use-module (oop goops) #:export (launch-lisparuga)) @@ -42,7 +43,11 @@ (define-asset background (load-image (scope-asset "images/background.png"))) -(define-class ()) +(define-class () + (state #:accessor state #:init-value 'play)) + +(define (game-over? lisparuga) + (zero? (lives (& lisparuga actor-canvas game player)))) (define-method (on-boot (lisparuga )) ;; Scale a small framebuffer up to the window size. @@ -57,38 +62,77 @@ ;; 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 actor-canvas (make #:name 'game)) (attach-to lisparuga (make #:name 'background + #:rank 0 #:texture background) - actor-canvas))) + actor-canvas) + (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))) + (and old-game (detach old-game))) + (attach-to (& lisparuga actor-canvas) (make #:name 'game))) + +(define (game-over-transition lisparuga) + (set! (state lisparuga) 'game-over) + (let ((game-over (make + #:name 'game-over + #:rank 999))) + (attach-to game-over + (make