initial commit
This commit is contained in:
48
src/ui/crosshair.rs
Normal file
48
src/ui/crosshair.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub struct CrosshairPlugin;
|
||||
|
||||
impl Plugin for CrosshairPlugin
|
||||
{
|
||||
fn build(&self, app: &mut App)
|
||||
{
|
||||
app.add_systems(Startup, setup_crosshair);
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_crosshair(
|
||||
mut commands: Commands,
|
||||
) {
|
||||
const CROSSHAIR_THICKNESS: f32 = 2.0;
|
||||
const CROSSHAIR_LENGTH: f32 = 10.0;
|
||||
|
||||
commands
|
||||
.spawn(Node {
|
||||
width: Val::Percent(100.0),
|
||||
height: Val::Percent(100.0),
|
||||
position_type: PositionType::Absolute,
|
||||
justify_content: JustifyContent::Center,
|
||||
align_items: AlignItems::Center,
|
||||
..default()
|
||||
})
|
||||
.with_child((
|
||||
Node {
|
||||
width: Val::Px(CROSSHAIR_THICKNESS),
|
||||
height: Val::Px(CROSSHAIR_LENGTH),
|
||||
position_type: PositionType::Absolute,
|
||||
..default()
|
||||
},
|
||||
BackgroundColor(Color::WHITE),
|
||||
))
|
||||
.with_child((
|
||||
Node {
|
||||
width: Val::Px(CROSSHAIR_LENGTH),
|
||||
height: Val::Px(CROSSHAIR_THICKNESS),
|
||||
position_type: PositionType::Absolute,
|
||||
..default()
|
||||
},
|
||||
BackgroundColor(Color::WHITE),
|
||||
))
|
||||
;
|
||||
}
|
||||
14
src/ui/mod.rs
Normal file
14
src/ui/mod.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
mod crosshair;
|
||||
|
||||
pub struct UiPlugin;
|
||||
|
||||
impl Plugin for UiPlugin
|
||||
{
|
||||
fn build(&self, app: &mut App)
|
||||
{
|
||||
app.add_plugins(crosshair::CrosshairPlugin);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user