diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2018-07-24 23:04:24 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-07-27 17:15:48 +0200 |
commit | 41445ed2a2fff494f552e18801000b3a5623fd5d (patch) | |
tree | 2f35df75590727db1ba72a1ced610cfea4178adf | |
parent | d7496041423731bc2396bdbb2e5483e5fe1e57f9 (diff) |
Finish death/credits scene.
-rw-r--r-- | assets/maps/death.tmx | 132 | ||||
-rw-r--r-- | scenes/credits.scm | 47 | ||||
-rw-r--r-- | scenes/death.scm | 276 |
3 files changed, 388 insertions, 67 deletions
diff --git a/assets/maps/death.tmx b/assets/maps/death.tmx new file mode 100644 index 0000000..94493d9 --- /dev/null +++ b/assets/maps/death.tmx @@ -0,0 +1,132 @@ +<?xml version="1.0" encoding="UTF-8"?> +<map version="1.0" tiledversion="1.1.5" orientation="orthogonal" renderorder="right-down" width="30" height="60" tilewidth="16" tileheight="16" infinite="0" nextobjectid="1"> + <tileset firstgid="1" source="cave.tsx"/> + <layer name="Tile Layer 1" width="30" height="60"> + <data encoding="csv"> +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,43,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,43,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,43,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,43,213,213,213,213,175,176,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,213,43,213,213,213,213,215,216,213,213,213,213,213,213,213,213,213,213, +213,213,213,213,213,213,213,213,213,213,213,213,43,43,213,213,175,176,213,213,213,213,213,213,213,213,213,213,175,176, +213,213,213,213,213,213,213,213,213,213,175,176,43,43,213,213,215,216,175,176,213,213,213,213,213,213,175,253,254,252, +213,213,213,213,213,213,213,213,213,213,214,252,176,175,176,213,175,253,256,216,213,175,176,175,253,253,254,128,128,128, +213,213,213,213,213,175,253,176,213,213,254,1,252,254,252,253,254,1,252,253,176,214,252,254,1,128,1,1,1,1, +213,213,213,213,213,214,1,252,253,254,1,1,1,1,1,1,1,1,1,1,252,254,128,1,1,1,281,282,283,281, +213,213,213,213,175,254,128,281,283,1,1,1,1,128,1,172,174,1,1,1,128,1,281,283,281,282,364,362,363,321, +213,213,175,253,254,128,128,321,324,283,1,1,1,1,128,252,256,174,1,1,128,281,325,324,325,322,324,283,128,321, +213,175,254,1,1,128,128,361,285,324,283,128,1,128,128,1,212,214,128,1,281,325,322,322,322,322,322,324,282,325, +213,254,128,1,128,128,128,128,361,285,324,283,1,1,128,172,255,254,128,128,321,322,322,322,322,322,322,322,322,322, +128,128,128,1,128,128,128,1,281,364,285,323,1,128,128,212,214,1,1,1,361,285,322,322,322,322,322,322,322,322, +1,1,1,1,128,1,128,128,361,365,364,363,128,128,172,255,254,1,1,128,281,325,322,322,322,322,322,322,322,322, +1,1,1,1,1,1,172,174,1,321,323,1,1,128,252,254,128,128,128,1,321,322,322,322,322,322,322,322,322,322, +128,128,1,1,128,128,212,214,128,361,363,1,128,1,1,1,128,128,128,1,361,285,284,285,322,322,322,322,322,322, +128,128,1,128,1,1,252,256,174,1,128,1,1,1,128,1,128,128,1,128,1,361,365,325,322,322,322,322,322,322, +1,128,128,1,1,128,172,255,256,174,128,1,128,1,128,128,1,1,1,1,1,1,321,322,322,322,322,322,322,322, +128,128,128,128,128,128,212,215,255,256,174,1,1,128,1,1,1,128,1,128,1,281,364,285,322,322,322,322,322,322, +128,128,1,128,128,128,252,253,254,252,254,128,128,128,128,128,128,128,1,128,1,361,363,361,285,322,322,322,322,322, +1,1,128,128,128,1,1,1,128,128,128,128,128,1,128,1,128,128,128,1,1,1,1,1,321,322,322,322,322,322, +128,128,128,1,1,128,1,1,1,128,128,128,1,128,1,128,1,128,1,128,128,1,1,281,325,322,322,322,322,322, +128,1,1,128,128,1,128,1,128,1,128,128,1,1,128,1,128,1,128,1,1,1,281,325,322,322,322,322,322,322, +1,1,1,281,283,1,128,1,1,128,128,128,128,128,128,1,1,128,128,128,128,128,361,285,322,322,322,322,322,322, +128,128,1,321,323,128,1,1,1,1,1,281,282,282,283,128,128,1,1,128,128,1,1,321,322,322,322,322,322,322, +128,128,1,361,365,283,1,281,282,283,1,321,322,322,324,282,282,283,1,128,1,281,282,325,322,322,284,362,362,285, +283,128,281,282,364,363,281,325,284,365,282,325,322,322,322,322,322,323,128,128,1,321,322,284,285,322,323,128,1,361, +324,282,364,285,324,282,325,284,363,361,362,362,362,285,284,285,322,324,282,283,281,325,284,363,361,362,363,1,1,1, +322,322,324,364,362,362,285,323,128,128,1,1,128,361,363,361,285,322,322,324,325,322,323,1,1,128,1,1,1,1, +322,322,322,324,283,281,364,363,1,1,1,128,1,128,128,1,321,322,322,322,322,284,363,1,128,128,1,1,128,128, +322,322,322,322,324,325,323,1,1,128,1,128,128,1,128,128,321,322,322,322,322,323,128,128,128,1,128,128,128,1 +</data> + </layer> + <layer name="Tile Layer 2" width="30" height="60"> + <data encoding="csv"> +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,208,209,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,0,0,0,0,0,0,248,249,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,206,0,0,241,0,0,0,0,0,206,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,126,246,127,161,0,0,0,0,0,0,126,201,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,166,0,167,0,0,0,0,0,0,0,0,241,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,126,0,0,0,0,127,0,0,0,371,0,0,0,0,0,0,0, +207,209,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,0,0,0,0,290,291,0,0,0,0,0,0, +168,169,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,241,0,0,0,0,330,331,0,0,0,0,0,0, +250,171,209,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +170,211,169,0,0,0,0,0,0,0,0,0,246,0,0,0,0,0,0,126,0,0,0,0,0,369,0,0,0,0, +210,251,249,0,0,0,0,0,0,0,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0,0,0,0, +250,209,0,0,126,246,0,0,0,0,0,201,0,0,0,201,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +248,249,0,0,206,0,0,0,0,0,0,241,0,0,0,241,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,126,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,201,0,0,0,201,246,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,208,209,0,0,241,0,0,0,241,0,0,0,0,206,0,0,0,0,0,0,290,291,0, +0,0,206,0,0,0,0,248,249,0,0,246,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,330,331,0, +167,206,0,0,0,0,0,0,0,0,0,0,0,0,0,0,166,0,0,0,0,0,0,0,0,0,0,0,0,0, +127,166,0,0,0,0,0,0,0,0,126,0,0,0,0,0,0,0,0,0,0,0,0,0,0,370,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,126,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,371,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +369,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,368,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +</data> + </layer> +</map> diff --git a/scenes/credits.scm b/scenes/credits.scm deleted file mode 100644 index c6159df..0000000 --- a/scenes/credits.scm +++ /dev/null @@ -1,47 +0,0 @@ -;;; 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 index 4682217..29d006f 100644 --- a/scenes/death.scm +++ b/scenes/death.scm @@ -16,23 +16,37 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (scenes death) + #:use-module (srfi srfi-1) + #:use-module (ice-9 match) + #:use-module (chickadee) #:use-module (chickadee audio) + #:use-module (chickadee math rect) #:use-module (chickadee math vector) + #:use-module (chickadee render color) #:use-module (chickadee render font) + #:use-module (chickadee render texture) + #:use-module (chickadee render shader) + #:use-module (chickadee render tiled) + #:use-module (chickadee scripting) #: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) + #:use-module (config) + #:use-module (characters) + #:use-module (characters lorenzo) + #:use-module (characters reaper) #:export (death)) -(define-class <death> (<scene>)) +(define-asset death-map (load-tile-map "assets/maps/death.tmx")) + +(define-class <death> (<scene>) + (tile-map #:accessor tile-map #:init-form death-map) + (pretend-walking? #:accessor pretend-walking? #:init-form #f)) (define-asset death-font - (load-tile-font "assets/fonts/bubblemad_8x8.png" 8 8 - " !\"©_%❤'()*+,-./0123456789:←<=>?@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")) + (load-font "assets/fonts/good_neighbors_starling.xml")) (define-asset music-death (load-music "assets/music/death.ogg")) @@ -75,31 +89,253 @@ to fight. Let go." Life is hard, but thankfully quite short.")) +(define credits + '(("The Inevitable Game" + "Made by Ricardo Wurmus" + "For Lorenzo") + ("Reaper character graphics" + "based on \"Lil Reaper Pet\" by Tracy") + ("Lorenzo character graphics" + "Based on \"Small 3/4 RPG character base\"" + "by Stephen Challener (Redshrike)") + ("Map tiles" + "taken from \"Zelda-like tilesets and sprites\"" + "by ArMM1998") + ("Food graphics" + "taken from \"The Humble Food Pack\"" + "by \"The Wise Hedgehog\"") + ("All music" + "composed and recorded" + "by Ricardo Wurmus") + ("Bird sounds" + "taken from the public domain") + ("Made with 100% Free Software including" + "- GNU Guile" + "- Chickadee" + "- Guile OpenGL" + "- SDL") + ("Thanks for enduring this game!"))) + (set! *random-state* (random-state-from-platform)) +;; This shader renders the texture after blending each pixel with a +;; 0.1 opacity pixel, thereby rendering everything with increased +;; transparency. +(define ghost-shader + (delay + (strings->shader + " +#version 130 + +in vec2 position; +in vec2 tex; +out vec2 frag_tex; +uniform mat4 mvp; + +void main(void) { + frag_tex = tex; + gl_Position = mvp * vec4(position.xy, 0.0, 1.0); +} +" + " +#version 130 + +in vec2 frag_tex; +uniform sampler2D color_texture; + +void main (void) { + vec4 original = texture2D(color_texture, frag_tex); + vec4 g; + + g = vec4(1, 1, 1, 0.1); + g = mix(g, original, 0.5); + gl_FragColor = vec4(original.rgb, min(g.a,original.a)); + if (gl_FragColor.a < 0.5) + { + discard; + } +} +"))) + (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)))))) + (make <node-2d> + #:name 'top-text + #:children + (map (lambda (part i) + (make <label> + #:name (symbol-append 'death-text- + (string->symbol + (number->string i))) + #:font death-font + #:text part + #:position (vec2 16.0 (- 190.0 (* 12 i))))) + parts (iota (length parts))))) + (list + (make <sprite> + #:name 'dead-lorenzo + #:texture (texture-atlas-ref + (asset-ref player-atlas) 23) + #:position (vec2 40.0 70.0)) + (make <filled-rect> + #:name 'fade-box + #:region (make-rect 0.0 0.0 %width %height) + #:color (make-color 0.125 0.09 0.161 0)) + (let ((player (lorenzo #:position (vec2 40.0 70.0) + #:shader ghost-shader))) + (set! (visible? player) #f) + (set! (walk-speed player) 0.3) + player) + (let ((reaper (reaper (vec2 140.0 70.0)))) + (set! (walk-speed reaper) 0.3) + reaper)))) (define-method (on-key-press (death <death>) key mods repeat?) - (switch-scene (root-node) - (credits))) + (abort-game)) + +(define-method (update (game <death>) dt) + ;; Keep the player (and the fade box) in the centre + (let* ((player (child-ref game 'player)) + (reaper (child-ref game 'reaper)) + (pos (position player)) + (vel (velocity player))) + ;; Update player position + (unless (pretend-walking? game) + (vec2-add! pos vel) + (vec2-add! (position reaper) (velocity reaper)) + (move-to game + (- 0 (vec2-x pos)) + (- 0 (vec2-y pos))) + ;; Adjust fade box + (move-to (child-ref game 'fade-box) + (- (vec2-x pos) (/ %width 2)) + (- (vec2-y pos) (/ %height 2))) + ;; Adjust text + (move-to (child-ref game 'top-text) + (- (vec2-x pos) (/ %width 2)) + (- (vec2-y pos) (/ %height 2)))))) + +(define-method (draw (game <death>) alpha) + (draw-tile-map (asset-ref (tile-map game)) + #:position (position game))) (define (death) (set-music-volume! 1.0) (stop-music) (play-music (load-music "assets/music/death.ogg") #:loop? #t) - (make <death>)) + (let* ((death (make <death> + #:origin (vec2 (- (/ %width 2)) + (- (/ %height 2))))) + (player (child-ref death 'player)) + (reaper (child-ref death 'reaper))) + (let* ((container + (make <node-2d> + #:children + (list death + (make <label> + #:name 'press-enter + #:font death-font + #:text "Press any key to quit." + #:position (vec2 72.0 20.0)) + (make <node-2d> + #:name 'credits-container + #:origin (vec2 (- (/ %width 2)) + (- (/ %height 2))))))) + (credits-container + (child-ref container 'credits-container))) + (with-agenda + (agenda death) + (script + (sleep 150) + (set! (visible? player) #t) + (walk player '(right)) + (sleep 250) + (walk player '(right) 'stop) + (walk player '(idle-front)) + (sleep 160) + (walk player '(up)) + (walk reaper '(up)) + (sleep 200) + ;; Slowly fade out the map and the top text. + (tween 600 0.0 1.0 (lambda (value) + (set! (color (child-ref death 'fade-box)) + ;; That's the colour of the "black" cave tile. + (make-color 0.125 0.09 0.161 value)))) + (set! (pretend-walking? death) #t) + (sleep 100) + (for-each + (match-lambda + ((first . rest) + (let ((label1 + (make <label> + #:font death-font + #:text first + #:visible? #f + #:origin (vec2 (/ %width 2) + (/ %height 2)) + #:position + (vec2 16.0 180))) + (other-labels + (map (lambda (text i) + (make <label> + #:font death-font + #:text text + #:visible? #f + #:origin (vec2 (/ %width 2) + (/ %height 2)) + #:position + (vec2 16.0 (- 180.0 (* 12 (+ i 1)))))) + rest + (iota (length rest))))) + (attach credits-container label1) + (set! (visible? label1) #t) + (for-each (lambda (label) + (attach credits-container label) + (set! (visible? label) #t)) + other-labels) + (sleep 300) + (set! (visible? label1) #f) + (for-each (lambda (label) + (set! (visible? label) #f)) + other-labels)))) + credits) + (sleep 600) + (for-each (lambda (text) + (let ((label + (make <label> + #:font death-font + #:text text + #:visible? #f + #:origin (vec2 (/ %width 2) + (/ %height 2)) + #:position + (vec2 16.0 180)))) + (attach credits-container label) + (set! (visible? label) #t) + (sleep 300) + (set! (visible? label) #f) + (sleep (+ (random 1000) 400)))) + `("There is nothing more to see here." + "I'm serious." + "What are you waiting for?" + "Don't waste your time!" + "Have you learned nothing from this game?" + "I've got all day, but how about you?" + "Look, I'm programmed to just keep going." + "Ugh... why are you even reading this?" + "Let me tell you a story..." + "Once upon a time, there was..." + ,@(let ((what '(("...a squirrel." "It had a nut allergy and died.") + ("...a dolphin." "It swam too far and never returned.") + ("...a stupid fish." "It drowned.") + ("...a long war." "Everybody died.")))) + (list-ref what (random (length what)))) + "End of story." + "Good night." + "Please just turn it off." + "I'm begging you." + "You're not listening, huh?" + "Well, I guess I'll just stop talking then.")))) + container))) |