diff --git a/assets/font/iosevka-lyteterm-regular.subset.ttf b/assets/font/iosevka-lyteterm-regular.subset.ttf new file mode 100644 index 0000000..1ce7997 Binary files /dev/null and b/assets/font/iosevka-lyteterm-regular.subset.ttf differ diff --git a/assets/font/iosevkalyteweb-regular.subset.woff2 b/assets/font/iosevkalyteweb-regular.subset.woff2 deleted file mode 100644 index 1afa631..0000000 Binary files a/assets/font/iosevkalyteweb-regular.subset.woff2 and /dev/null differ diff --git a/readme.md b/readme.md index 621f895..6c0bc2b 100644 --- a/readme.md +++ b/readme.md @@ -24,6 +24,11 @@ the heavy-lifting for me _plus_ it's a fun excuse to write more Rust. - https://github.com/bevyengine/bevy/blob/main/examples/audio/spatial_audio_2d.rs - [X] Y-sort - Layers? + - [ ] UI stuff + - [ ] Multiplayer + - Ambient game engine? + - I _would_ like in-browser (and mobile) playability and multiplayer + - Lightyear? - [ ] Tile system - [ ] Basic map - In-game editing? @@ -36,8 +41,5 @@ the heavy-lifting for me _plus_ it's a fun excuse to write more Rust. - Navmesh may be super overkill and astar may be sufficient? - [ ] Smart pathfinding - `pathfinding` crate? -- [ ] Multiplayer - - [ ] Ambient game engine? - - I _would_ like in-browser (and mobile) playability and multiplayer - [ ] ??? - [ ] Profit diff --git a/src/assets.rs b/src/assets.rs index 76251ea..e01571e 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -4,6 +4,7 @@ use bevy::prelude::*; pub struct AssetLoader { pub images: Sprites, pub sounds: Sounds, + pub fonts: Fonts, } #[derive(Resource, Debug, Default)] @@ -17,6 +18,11 @@ pub struct Sounds { pub meow: Handle, } +#[derive(Resource, Debug, Default)] +pub struct Fonts { + pub iosevkalytemin: Handle, +} + pub struct AssetPlugin; impl Plugin for AssetPlugin { @@ -63,5 +69,9 @@ fn load_assets( sounds: Sounds { meow: asset_server.load("sfx/meow.wav"), }, + + fonts: Fonts { + iosevkalytemin: asset_server.load("font/iosevka-lyteterm-regular.subset.ttf"), + }, }; } diff --git a/src/camera.rs b/src/camera.rs index aa7d8cc..ae8ab4d 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -23,7 +23,9 @@ fn focus( player: Query<&Transform, With>, mut camera: Query<&mut Transform, (With, Without)>, ) { - camera.single_mut().translation = player.single().translation + let newpos = player.single().translation; + // println!("Cam pos: {newpos}"); + camera.single_mut().translation = newpos } fn y_sort(mut q: Query<&mut Transform>) { diff --git a/src/main.rs b/src/main.rs index b1c2d5b..b701393 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use bevy::prelude::*; mod assets; mod camera; +mod main_menu; mod movement; mod player; mod statue; @@ -32,6 +33,7 @@ fn main() { camera::Camera, assets::AssetPlugin, player::Player, + main_menu::MainMenu, movement::Movement, )) .insert_resource(ClearColor(Color::rgb(0.3, 0., 0.5))) diff --git a/src/main_menu.rs b/src/main_menu.rs new file mode 100644 index 0000000..f45810b --- /dev/null +++ b/src/main_menu.rs @@ -0,0 +1,61 @@ +use bevy::prelude::*; + +use crate::assets::AssetLoader; + +#[derive(Component, Debug)] +pub struct MainMenu; + +impl Plugin for MainMenu { + fn build(&self, app: &mut App) { + app.add_systems(PostStartup, setup_main_menu); + } +} + +fn setup_main_menu(mut commands: Commands, assets: Res) { + commands + .spawn(NodeBundle { + style: Style { + width: Val::Percent(100.0), + height: Val::Percent(100.0), + justify_content: JustifyContent::SpaceBetween, + ..default() + }, + ..default() + }) + .with_children(|parent| { + // text + parent.spawn(( + TextBundle::from_section( + "Text Example", + TextStyle { + font: assets.fonts.iosevkalytemin.clone(), + font_size: 30.0, + ..default() + }, + ) + .with_style(Style { + margin: UiRect::all(Val::Px(12.)), + ..default() + }), + // Because this is a distinct label widget and + // not button/list item text, this is necessary + // for accessibility to treat the text accordingly. + Label, + )); + + parent.spawn(NodeBundle { + style: Style { + width: Val::Px(200.0), + height: Val::Px(200.0), + position_type: PositionType::Absolute, + left: Val::Px(210.), + bottom: Val::Px(10.), + border: UiRect::all(Val::Px(20.)), + ..default() + }, + border_color: Color::GREEN.into(), + background_color: Color::rgb(0.4, 0.4, 1.).into(), + ..default() + }); + }); +}