diff --git a/assets/proxima.ttf b/assets/proxima.ttf new file mode 100644 index 0000000..9befcb1 Binary files /dev/null and b/assets/proxima.ttf differ diff --git a/assets/proxima_thin.ttf b/assets/proxima_thin.ttf new file mode 100644 index 0000000..5ed3b68 Binary files /dev/null and b/assets/proxima_thin.ttf differ diff --git a/src/main.rs b/src/main.rs index 5a72398..29a0de3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,8 @@ impl Plugin for SqPlugin { } -fn spawn_square_at (commands: &mut Commands, level: u32, position: usize) { +fn spawn_square_at (commands: &mut Commands, level: u32, position: usize, asset_server: AssetServer) { + let font = asset_server.load("proxima_thin.ttf"); let Some(&(x, y)) = sq_origins.get(position) else { return; }; @@ -32,18 +33,16 @@ fn spawn_square_at (commands: &mut Commands, level: u32, position: usize) { let text = 2i32.pow(level); let label = Text2dBundle { text: Text::from_section(text.to_string(), TextStyle { - font_size: 48., + font, + font_size: 44., color: Color::WHITE, - ..Default::default() }), transform: Transform { translation: Vec3::new(x, y, 0.0), ..Default::default() }, ..Default::default() - } - ; - + }; commands.spawn(SpriteBundle { sprite: Sprite { @@ -73,7 +72,7 @@ fn render_field ( ) { for (idx, &val) in field.iter().enumerate() { if val > 0 { - spawn_square_at(&mut commands, val, idx); + spawn_square_at(&mut commands, val, idx, asset_server.clone()); } } } diff --git a/src/prelude.rs b/src/prelude.rs index 5d65f66..4eb491c 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -15,7 +15,7 @@ pub struct Field (pub Vec); pub const BG_COLOR: Color = Color::srgb(0.949, 0.937, 0.769); pub const SCOREBOARD_FONT_SIZE: f32 = 44.0; pub const TEXT_COLOR: Color = Color::BLACK; -pub const SCORE_COLOR: Color = Color::srgb(0.4, 0.05, 0.04); +pub const SCORE_COLOR: Color = Color::srgb(0.0, 0.05, 0.66); pub const SCOREBOARD_TEXT_PADDING: Val = Val::Px(22.0); pub struct SqPlugin; diff --git a/src/setup.rs b/src/setup.rs index 036f503..3eeca52 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -4,25 +4,27 @@ pub fn setup ( mut commands: Commands, mut _meshes: ResMut>, mut _materials: ResMut>, - _asset_server: Res, + asset_server: Res, ) { + let font = asset_server.load("proxima.ttf"); + commands.spawn(Camera2dBundle::default()); commands.spawn(( ScoreboardUi, TextBundle::from_sections([ TextSection::new( - "Score: ", + "score: ", TextStyle { + font: font.clone(), font_size: SCOREBOARD_FONT_SIZE, color: TEXT_COLOR, - ..default() }, ), TextSection::from_style(TextStyle { + font, font_size: SCOREBOARD_FONT_SIZE, color: SCORE_COLOR, - ..default() }), ]) .with_style(Style { @@ -38,7 +40,6 @@ pub fn setup ( fn draw_board (commands: &mut Commands) { - let borders = [-305., 305.]; let lines = [-150., 0., 150.];