mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
feat(player): spawn player pill
This commit is contained in:
parent
c694281e88
commit
6f0f8471c5
@ -5,7 +5,7 @@ mod dev_tools;
|
|||||||
mod maze;
|
mod maze;
|
||||||
mod player;
|
mod player;
|
||||||
mod screens;
|
mod screens;
|
||||||
mod theme;
|
pub mod theme;
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
asset::AssetMetaCheck,
|
asset::AssetMetaCheck,
|
||||||
|
|||||||
17
src/player/assets.rs
Normal file
17
src/player/assets.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use crate::theme::palette::rose_pine::PINE;
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
pub(super) fn generate_pill_mesh(radius: f32, half_length: f32) -> Mesh {
|
||||||
|
Mesh::from(Capsule3d {
|
||||||
|
radius,
|
||||||
|
half_length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn blue_material() -> StandardMaterial {
|
||||||
|
StandardMaterial {
|
||||||
|
base_color: PINE,
|
||||||
|
emissive: PINE.to_linear() * 3.,
|
||||||
|
..default()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,9 +1,12 @@
|
|||||||
|
mod assets;
|
||||||
mod components;
|
mod components;
|
||||||
mod systems;
|
mod systems;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use components::Player;
|
use components::Player;
|
||||||
|
use systems::spawn_player;
|
||||||
|
|
||||||
pub(super) fn plugin(app: &mut App) {
|
pub(super) fn plugin(app: &mut App) {
|
||||||
app.register_type::<Player>().add_plugins(());
|
app.register_type::<Player>()
|
||||||
|
.add_systems(Startup, spawn_player);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
use super::components::Player;
|
use super::{
|
||||||
|
assets::{blue_material, generate_pill_mesh},
|
||||||
|
components::Player,
|
||||||
|
};
|
||||||
use crate::maze::{events::RecreateMazeEvent, MazeConfig};
|
use crate::maze::{events::RecreateMazeEvent, MazeConfig};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
@ -8,14 +11,17 @@ pub fn spawn_player(
|
|||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
maze_config: Res<MazeConfig>,
|
maze_config: Res<MazeConfig>,
|
||||||
) {
|
) {
|
||||||
}
|
let player_height = maze_config.height * 0.5;
|
||||||
|
let player_radius = maze_config.hex_size * 0.5;
|
||||||
|
|
||||||
pub fn respawn_player(
|
commands.spawn((
|
||||||
mut commands: Commands,
|
Name::new("Player"),
|
||||||
player_query: Query<Entity, With<Player>>,
|
Player,
|
||||||
mut recreation_events: EventReader<RecreateMazeEvent>,
|
PbrBundle {
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mesh: meshes.add(generate_pill_mesh(player_radius, player_height / 2.)),
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
material: materials.add(blue_material()),
|
||||||
maze_config: Res<MazeConfig>,
|
transform: Transform::from_xyz(0., player_height * 2., 0.),
|
||||||
) {
|
..default()
|
||||||
|
},
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
//! Reusable UI widgets & theming.
|
//! Reusable UI widgets & theming.
|
||||||
|
|
||||||
// Unused utilities may trigger this lints undesirably.
|
// Unused utilities may trigger this lints undesirably.
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
pub mod interaction;
|
pub mod interaction;
|
||||||
pub mod palette;
|
pub mod palette;
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
pub mod rose_pine;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
pub const BUTTON_HOVERED_BACKGROUND: Color = Color::srgb(0.186, 0.328, 0.573);
|
pub const BUTTON_HOVERED_BACKGROUND: Color = Color::srgb(0.186, 0.328, 0.573);
|
||||||
@ -8,3 +10,11 @@ pub const LABEL_TEXT: Color = Color::srgb(0.867, 0.827, 0.412);
|
|||||||
pub const HEADER_TEXT: Color = Color::srgb(0.867, 0.827, 0.412);
|
pub const HEADER_TEXT: Color = Color::srgb(0.867, 0.827, 0.412);
|
||||||
|
|
||||||
pub const NODE_BACKGROUND: Color = Color::srgb(0.286, 0.478, 0.773);
|
pub const NODE_BACKGROUND: Color = Color::srgb(0.286, 0.478, 0.773);
|
||||||
|
|
||||||
|
pub(super) const fn rgb_u8(red: u8, green: u8, blue: u8) -> Color {
|
||||||
|
Color::srgb(scale(red), scale(green), scale(blue))
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn scale(value: u8) -> f32 {
|
||||||
|
value as f32 / 255.
|
||||||
|
}
|
||||||
18
src/theme/palette/rose_pine.rs
Normal file
18
src/theme/palette/rose_pine.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use super::rgb_u8;
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
pub const BASE: Color = rgb_u8(25, 23, 36);
|
||||||
|
pub const SURFACE: Color = rgb_u8(31, 29, 46);
|
||||||
|
pub const OVERLAY: Color = rgb_u8(38, 35, 58);
|
||||||
|
pub const MUTED: Color = rgb_u8(110, 106, 134);
|
||||||
|
pub const SUBTLE: Color = rgb_u8(144, 140, 170);
|
||||||
|
pub const TEXT: Color = rgb_u8(224, 222, 244);
|
||||||
|
pub const LOVE: Color = rgb_u8(235, 111, 146);
|
||||||
|
pub const GOLD: Color = rgb_u8(246, 193, 119);
|
||||||
|
pub const ROSE: Color = rgb_u8(235, 188, 186);
|
||||||
|
pub const PINE: Color = rgb_u8(49, 116, 143);
|
||||||
|
pub const FOAM: Color = rgb_u8(156, 207, 216);
|
||||||
|
pub const IRIS: Color = rgb_u8(196, 167, 231);
|
||||||
|
pub const HIGHLIGHT_LOW: Color = rgb_u8(33, 32, 46);
|
||||||
|
pub const HIGHLIGHT_MED: Color = rgb_u8(64, 61, 82);
|
||||||
|
pub const HIGHLIGHT_HIGH: Color = rgb_u8(82, 79, 103);
|
||||||
Loading…
Reference in New Issue
Block a user