From 3bbc57d29fac5799a271cb25b89ed3a35d76e776 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 13 May 2024 01:42:22 +0200 Subject: [PATCH] show death poems on death --- src/data/deathpoems.in | 204 +++++++++++++++++++++++++++++++++++++++++ src/menu.rs | 20 +++- src/var.rs | 4 + 3 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 src/data/deathpoems.in diff --git a/src/data/deathpoems.in b/src/data/deathpoems.in new file mode 100644 index 0000000..8b3ec11 --- /dev/null +++ b/src/data/deathpoems.in @@ -0,0 +1,204 @@ +Though I heard +Everyone goes this road +Eventually +I didn't expect that +I'd be on it yesterday or today +- Ariwara no Narihira, 880 + +A flower of Sponge cucumber blooms +Phlegm gets caught +In the dead's throat +- Masaoka Shiki, 1902 + +There is no death; +there is no life. +Indeed, the skies are cloudless +And the river waters clear. +- Toshimoto, Taiheiki + +I wish to die +in spring, beneath +the cherry blossoms, +while the springtime moon +is full. +- Saigyo, 1190 + +Illusion appears, illusion ceases +The biggest illusion among all is our body +Once a pacified heart finds its place +There's no such body to look for +- Zheng Ting, 621 + +Empty-handed I entered the world +Barefoot I leave it. +My coming, my going — +Two simple happenings +That got entangled. +- Kozan Ichikyo, 1360 + +Bury me when I die +beneath a wine barrel +in a tavern. +With luck +the cask will leak. +- Moriya Sen'an 1838 + +I wish I could enjoy, +the rest of Spring, +as the cherry blossoms are yet in bloom, +in spite of the spring breeze +which is attempting to blow off all their petals. +– Asano Naganori, 1701 + +To be saved from the chasm +why cling to the cliff? +Clouds floating low never know where the breezes will blow them. +- Sengai Gibon, 1837 + +Flash of steel stills me; +calmness mirrors the ocean; +I await the waves. +* +The death of blossoms; +is not something to grieve on; +but the way of things. +- Asakura Sōteki, 1555 + +The glory and prosperity of my life was as good as a single cup of sake. +My life of forty-nine years is passed like a dream. +I know not what life is; nor death. +Both Heaven and Hell are left behind. +I stand in the moonlit dawn; free from clouds of attachment. +- Uesugi Kenshin, 1578 + +My whole life long I’ve sharpened my sword +And now, face to face with death +I unsheathe it, and lo- +The blade is broken- +Alas! +– Dairin Soto, 1568 + +I borrow moonlight +for this journey of a +million miles +- Saikaku, 1730 + +Not knowing +that my body lies +upon Mount Kamo's rocks, +my love +awaits me. +- Kakinomoto no Hitomaro, 707 + +Overtaken by darkness +I will lodge under +the boughs of a tree. +Flowers alone +host me tonight. +- Taira no Tadanori, 1184 + +Like a rotten log +half-buried in the ground- +my life, which +has not flowered, comes +to this sad end. +- Minamoto no Yorimasa, 1180 + +Had I not known +that I was dead +already +I would have mourned +my loss of life. +- Ota Dokan, 1486 + +Since I was born +I have to die, +and so ... +- Kisei, 1764 + +Till now I thought +that death befell +the untalented alone. +If those with talent, too, must die +surely they make a better manure? +- Morikawa Kyoriku, 1715 + +One leaf lets go, and +then another takes +the wind. +- Ransetsu, 1707 + +I cleansed the mirror +of my heart - now it reflects +the moon. +- Renseki, 1789 + +Let them bloom or +let them die-it's all the same: +cherry trees on Mount Yoshino. +- Rekisen, 1834 + +Depths of cold +unfathomable +ocean roar. +- Kasenjo, 1776 + +A tune of non-being +Filling the void: +Spring sun +Snow whiteness +Bright clouds +Clear wind. +- Daido Ichi'i, 1370 + +I raise the mirror of my life +Up to my face: sixty years. +With a swing I smash the reflection- +The world as usual +All in its place. +- Taigen Sofu, 1555 + +I cast the brush aside- +from here on I'll speak to the moon +face to face. +- Koha, 1897 + +The joy of dewdrops +in the grass as they +tum back to vapor. +- Koraku, 1837 + +The foam on the last water +has dissolved +my mind is clear. +- Mitoku, 1669 + +Still tied to the world, +I cool off and lose +my form. +- Ozui, 1783 + +Festival of Souls: +yesterday I hosted them +today I am a guest ... +- Sofu, 1891 + +Spitting blood +clears up reality +and dream alike. +- Sunao, 1926 + +I go back +to the void where frost and snow +won't bother me. +- Tojaku, 1799 + +My life was +lunacy until +this moonlit night. +- Tokugen, 1647 + +The owner of the cherry blossoms +turns to compost +for the trees. +- Utsu, 1863 diff --git a/src/menu.rs b/src/menu.rs index 95e02db..2967733 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -12,6 +12,9 @@ use crate::prelude::*; use bevy::prelude::*; +use fastrand; + +pub const POEMS: &str = &include_str!("data/deathpoems.in"); pub struct MenuPlugin; impl Plugin for MenuPlugin { @@ -51,6 +54,12 @@ pub fn setup( color: settings.hud_color_subtitles, ..default() }; + let style_death_poem = TextStyle { + font: font_handle.clone(), + font_size: settings.font_size_deathpoem, + color: settings.hud_color_deathpoem, + ..default() + }; let style_death_subtext = TextStyle { font: font_handle.clone(), font_size: settings.font_size_deathsubtext, @@ -76,10 +85,11 @@ pub fn setup( TextBundle { text: Text { sections: vec![ + TextSection::new("", style_death_poem), TextSection::new("You are dead.\n", style_death), TextSection::new("Cause: ", style_death_subtext.clone()), TextSection::new("Unknown", style_death_subtext), - TextSection::new("\n\n\nPress E to begin anew.", style_death_subsubtext), + TextSection::new("\n\n\n\nPress E to begin anew.", style_death_subsubtext), ], justify: JustifyText::Center, ..default() @@ -108,7 +118,13 @@ pub fn show_deathscreen( if show { if let Ok(mut text) = q_text.get_single_mut() { - text.sections[2].value = settings.death_cause.clone(); + let poems: Vec<&str> = POEMS.split("\n\n").collect(); + if poems.len() > 0 { + let poem_index = fastrand::usize(..poems.len()); + let poem = poems[poem_index].to_string(); + text.sections[0].value = poem + "\n\n\n\n"; + } + text.sections[3].value = settings.death_cause.clone(); } } else { ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); diff --git a/src/var.rs b/src/var.rs index da8aa5e..e1e0116 100644 --- a/src/var.rs +++ b/src/var.rs @@ -54,6 +54,7 @@ pub struct Settings { pub font_size_speedometer: f32, pub font_size_deathtext: f32, pub font_size_deathsubtext: f32, + pub font_size_deathpoem: f32, pub hud_color: Color, pub hud_color_fps: Color, pub hud_color_console: Color, @@ -63,6 +64,7 @@ pub struct Settings { pub hud_color_subtitles: Color, pub hud_color_choices: Color, pub hud_color_speedometer: Color, + pub hud_color_deathpoem: Color, pub chat_speed: f32, pub flashlight_active: bool, pub hud_active: bool, @@ -167,6 +169,7 @@ impl Default for Settings { font_size_speedometer: 34.0, font_size_deathtext: 64.0, font_size_deathsubtext: 32.0, + font_size_deathpoem: 18.0, hud_color: Color::hex("#BE1251").unwrap(), hud_color_fps: Color::hex("#181818").unwrap(), hud_color_console: Color::hex("#BE1251").unwrap(), @@ -176,6 +179,7 @@ impl Default for Settings { hud_color_subtitles: Color::hex("#CCCCCC").unwrap(), hud_color_choices: Color::hex("#727272").unwrap(), hud_color_speedometer: Color::hex("#BE1251").unwrap(), + hud_color_deathpoem: Color::hex("#CC2200").unwrap(), chat_speed: DEFAULT_CHAT_SPEED * if dev_mode { 2.5 } else { 1.0 }, flashlight_active: false, hud_active: true,