refactor: huge refactor into node/graph-based movement system

This commit is contained in:
2025-07-28 12:23:57 -05:00
parent 413f9f156f
commit 464d6f9ca6
24 changed files with 868 additions and 2067 deletions

View File

@@ -1,7 +1,11 @@
//! This module contains all the constants used in the game.
use std::time::Duration;
use glam::UVec2;
pub const LOOP_TIME: Duration = Duration::from_nanos((1_000_000_000.0 / 60.0) as u64);
/// The size of each cell, in pixels.
pub const CELL_SIZE: u32 = 8;
/// The size of the game board, in cells.
@@ -39,58 +43,6 @@ pub enum MapTile {
Tunnel,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum FruitType {
Cherry,
Strawberry,
Orange,
Apple,
Melon,
Galaxian,
Bell,
Key,
}
impl FruitType {
pub const ALL: [FruitType; 8] = [
FruitType::Cherry,
FruitType::Strawberry,
FruitType::Orange,
FruitType::Apple,
FruitType::Melon,
FruitType::Galaxian,
FruitType::Bell,
FruitType::Key,
];
pub fn score(self) -> u32 {
match self {
FruitType::Cherry => 100,
FruitType::Strawberry => 300,
FruitType::Orange => 500,
FruitType::Apple => 700,
FruitType::Melon => 1000,
FruitType::Galaxian => 2000,
FruitType::Bell => 3000,
FruitType::Key => 5000,
}
}
pub fn index(self) -> usize {
match self {
FruitType::Cherry => 0,
FruitType::Strawberry => 1,
FruitType::Orange => 2,
FruitType::Apple => 3,
FruitType::Melon => 4,
FruitType::Galaxian => 5,
FruitType::Bell => 6,
FruitType::Key => 7,
}
}
}
/// The raw layout of the game board, as a 2D array of characters.
pub const RAW_BOARD: [&str; BOARD_CELL_SIZE.y as usize] = [
"############################",
@@ -106,9 +58,9 @@ pub const RAW_BOARD: [&str; BOARD_CELL_SIZE.y as usize] = [
" #.##### ## #####.# ",
" #.## 1 ##.# ",
" #.## ###==### ##.# ",
"######.## # # ##.######",
"T . #2 3 4 # . T",
"######.## # # ##.######",
"######.## ######## ##.######",
"T . ######## . T",
"######.## ######## ##.######",
" #.## ######## ##.# ",
" #.## ##.# ",
" #.## ######## ##.# ",