keys 2
This commit is contained in:
+32
-10
@@ -11,6 +11,28 @@ use std::time::Duration;
|
||||
/// How long a `say()` speech bubble stays on screen, in seconds.
|
||||
pub const SAY_DURATION: f64 = 3.0;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum KeyType {
|
||||
Red, Orange, Yellow, Green, Blue, Cyan, Purple, White
|
||||
}
|
||||
|
||||
impl KeyType {
|
||||
pub fn glyph(self) -> Glyph {
|
||||
let fg = match self {
|
||||
KeyType::Red => Rgba8 { r: 0xFF, g: 0x50, b: 0x50, a: 255 },
|
||||
KeyType::Orange => Rgba8 { r: 0xFF, g: 0x88, b: 0x00, a: 255 },
|
||||
KeyType::Yellow => Rgba8 { r: 0xFF, g: 0xFF, b: 0x50, a: 255 },
|
||||
KeyType::Green => Rgba8 { r: 0x50, g: 0xFF, b: 0x50, a: 255 },
|
||||
KeyType::Blue => Rgba8 { r: 0x50, g: 0x50, b: 0xFF, a: 255 },
|
||||
KeyType::Cyan => Rgba8 { r: 0x00, g: 0xAA, b: 0xAA, a: 255 },
|
||||
KeyType::Purple => Rgba8 { r: 0xAA, g: 0x00, b: 0xAA, a: 255 },
|
||||
KeyType::White => Rgba8 { r: 0xFF, g: 0xFF, b: 0xFF, a: 255 }
|
||||
};
|
||||
|
||||
Glyph { tile: 12, fg, bg: Rgba8 { r: 0, g: 0, b: 0, a: 255 } }
|
||||
}
|
||||
}
|
||||
|
||||
/// The player's key inventory: one boolean per key color.
|
||||
///
|
||||
/// Each field is `true` when the player holds a key of that color. Use
|
||||
@@ -60,14 +82,14 @@ impl Keyring {
|
||||
/// Order: blue, green, cyan, red, purple, orange, yellow, white.
|
||||
pub fn colors(&self) -> [(bool, Rgba8); 8] {
|
||||
[
|
||||
(self.blue, Rgba8 { r: 0x00, g: 0x00, b: 0xAA, a: 255 }),
|
||||
(self.green, Rgba8 { r: 0x00, g: 0xAA, b: 0x00, a: 255 }),
|
||||
(self.cyan, Rgba8 { r: 0x00, g: 0xAA, b: 0xAA, a: 255 }),
|
||||
(self.red, Rgba8 { r: 0xAA, g: 0x00, b: 0x00, a: 255 }),
|
||||
(self.purple, Rgba8 { r: 0xAA, g: 0x00, b: 0xAA, a: 255 }),
|
||||
(self.orange, Rgba8 { r: 0xFF, g: 0x88, b: 0x00, a: 255 }),
|
||||
(self.yellow, Rgba8 { r: 0xFF, g: 0xFF, b: 0x55, a: 255 }),
|
||||
(self.white, Rgba8 { r: 0xFF, g: 0xFF, b: 0xFF, a: 255 }),
|
||||
(self.blue, KeyType::Blue.glyph().fg),
|
||||
(self.green, KeyType::Green.glyph().fg),
|
||||
(self.cyan, KeyType::Cyan.glyph().fg),
|
||||
(self.red, KeyType::Red.glyph().fg),
|
||||
(self.purple, KeyType::Purple.glyph().fg),
|
||||
(self.orange, KeyType::Orange.glyph().fg),
|
||||
(self.yellow, KeyType::Yellow.glyph().fg),
|
||||
(self.white, KeyType::White.glyph().fg),
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -75,6 +97,7 @@ impl Keyring {
|
||||
// Re-export ScrollLine so kiln-tui can pattern-match scroll content without
|
||||
// accessing the private `action` module directly.
|
||||
pub use crate::action::ScrollLine;
|
||||
use crate::glyph::Glyph;
|
||||
|
||||
/// An active scroll overlay opened by a scripted object via `scroll()`.
|
||||
///
|
||||
@@ -166,8 +189,7 @@ impl GameState {
|
||||
board_transition: None,
|
||||
player_health: 5,
|
||||
player_gems: 0,
|
||||
// Test starting keys: red, green, orange, white.
|
||||
player_keys: Keyring { red: true, green: true, orange: true, white: true, ..Default::default() },
|
||||
player_keys: Keyring::default(),
|
||||
};
|
||||
state.drain_errors();
|
||||
state
|
||||
|
||||
Reference in New Issue
Block a user