summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-07-21 16:00:55 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-07-27 17:15:46 +0200
commit77a65835d236b12984594243cba4bf2110977710 (patch)
tree3ef39a81f64be0ad8bc6620534163babee0c51c8
parent9c43f7a9472a4fe0c50250f25c9605a898c568ef (diff)
Add death and credits scene.
-rw-r--r--scenes/credits.scm47
-rw-r--r--scenes/death.scm105
2 files changed, 152 insertions, 0 deletions
diff --git a/scenes/credits.scm b/scenes/credits.scm
new file mode 100644
index 0000000..c6159df
--- /dev/null
+++ b/scenes/credits.scm
@@ -0,0 +1,47 @@
+;;; The Inevitable Game
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; This program is free software: you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation, either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (scenes credits)
+ #:use-module (chickadee)
+ #:use-module (chickadee math vector)
+ #:use-module (chickadee render font)
+ #:use-module (engine assets)
+ #:use-module (engine node)
+ #:use-module (engine node-2d)
+ #:use-module (engine scene)
+ #:use-module (scenes game)
+ #:use-module (oop goops)
+ #:export (credits))
+
+(define-class <credits> (<scene>))
+
+(define-asset credits-font
+ (load-tile-font "assets/fonts/bubblemad_8x8.png" 8 8
+ " !\"©_%❤'()*+,-./0123456789:←<=>?@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"))
+
+(define-method (populate (credits <credits>))
+ (list
+ (make <label>
+ #:name 'press-enter
+ #:font credits-font
+ #:text "Press any key to quit."
+ #:position (vec2 72.0 50.0))))
+
+(define-method (on-key-press (credits <credits>) key mods repeat?)
+ (abort-game))
+
+(define (credits) (make <credits>))
diff --git a/scenes/death.scm b/scenes/death.scm
new file mode 100644
index 0000000..4682217
--- /dev/null
+++ b/scenes/death.scm
@@ -0,0 +1,105 @@
+;;; The Inevitable Game
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; This program is free software: you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation, either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (scenes death)
+ #:use-module (chickadee audio)
+ #:use-module (chickadee math vector)
+ #:use-module (chickadee render font)
+ #:use-module (engine assets)
+ #:use-module (engine node)
+ #:use-module (engine node-2d)
+ #:use-module (engine scene)
+ #:use-module (engine shell)
+ #:use-module (scenes credits)
+ #:use-module (oop goops)
+ #:export (death))
+
+(define-class <death> (<scene>))
+
+(define-asset death-font
+ (load-tile-font "assets/fonts/bubblemad_8x8.png" 8 8
+ " !\"©_%❤'()*+,-./0123456789:←<=>?@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"))
+
+(define-asset music-death (load-music "assets/music/death.ogg"))
+
+(define texts
+ '("\
+Life waits for no one, but
+death is patient."
+
+ "\
+You have died. Your points
+don't matter."
+
+ "\
+Death is inevitable."
+
+ "\
+The void resumes."
+
+ "\
+It did not last."
+
+ "\
+You were busy, but none of that
+matters any more."
+
+ "\
+You were mortal after all."
+
+ "\
+Nobody outruns the clock."
+
+ "\
+Life goes on, but you end here."
+
+ "\
+This is no longer your battle
+to fight. Let go."
+
+ "\
+Life is hard, but thankfully
+quite short."))
+
+(set! *random-state* (random-state-from-platform))
+
+(define-method (populate (death <death>))
+ (cons
+ (make <label>
+ #:name 'press-enter
+ #:font death-font
+ #:text "Press any key to quit."
+ #:position (vec2 72.0 50.0))
+ (let* ((text (list-ref texts (random (length texts))))
+ (parts (string-split text #\newline)))
+ (map (lambda (part i)
+ (make <label>
+ #:name 'death
+ #:font death-font
+ #:text part
+ #:position (vec2 16.0 (- 150.0 (* 12 i)))))
+ parts (iota (length parts))))))
+
+(define-method (on-key-press (death <death>) key mods repeat?)
+ (switch-scene (root-node)
+ (credits)))
+
+(define (death)
+ (set-music-volume! 1.0)
+ (stop-music)
+ (play-music (load-music "assets/music/death.ogg") #:loop? #t)
+ (make <death>))