Skip to content

Commit

Permalink
Add NEXT label for game ui and adjust font size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramirisu committed Sep 25, 2024
1 parent 7575c53 commit 592e328
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
44 changes: 30 additions & 14 deletions src/game/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn setup_screen(
text: Text::from_section(
"PRESS START\nTO CONTINUE",
TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_medium(),
color: WHITE.into(),
..default()
},
Expand All @@ -224,14 +224,14 @@ fn setup_screen(
TextSection {
value: "LINES\n".into(),
style: TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_large(),
color: WHITE.into(),
..default()
},
..default()
},
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 72.0,
font_size: game_transform.fs_xlarge(),
color: WHITE.into(),
..default()
}),
Expand All @@ -249,14 +249,14 @@ fn setup_screen(
TextSection {
value: "SCORE\n".into(),
style: TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_large(),
color: WHITE.into(),
..default()
},
..default()
},
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 72.0,
font_size: game_transform.fs_xlarge(),
color: WHITE.into(),
..default()
}),
Expand All @@ -274,19 +274,19 @@ fn setup_screen(
TextSection {
value: "LEVEL ".into(),
style: TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_large(),
color: WHITE.into(),
..default()
},
..default()
},
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 72.0,
font_size: game_transform.fs_xlarge(),
color: WHITE.into(),
..default()
}),
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_medium(),
color: WHITE.into(),
..default()
}),
Expand All @@ -301,7 +301,7 @@ fn setup_screen(
Text2dBundle {
text: Text::from_sections(vec![
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_medium(),
color: WHITE.into(),
..default()
});
Expand All @@ -319,14 +319,14 @@ fn setup_screen(
TextSection {
value: "DAS ".into(),
style: TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_medium(),
color: WHITE.into(),
..default()
},
..default()
},
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 48.0,
font_size: game_transform.fs_large(),
color: WHITE.into(),
..default()
}),
Expand All @@ -343,14 +343,14 @@ fn setup_screen(
TextSection {
value: "TIME ".into(),
style: TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_medium(),
color: WHITE.into(),
..default()
},
..default()
},
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_medium(),
color: WHITE.into(),
..default()
}),
Expand Down Expand Up @@ -391,7 +391,7 @@ fn setup_screen(
commands.spawn((
Text2dBundle {
text: Text::from_sections([TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 36.0,
font_size: game_transform.fs_medium(),
color: WHITE.into(),
..default()
})]),
Expand Down Expand Up @@ -430,6 +430,22 @@ fn setup_screen(
));
});

commands.spawn((
Text2dBundle {
text: Text::from_section(
"NEXT",
TextStyle {
font_size: game_transform.fs_large(),
color: WHITE.into(),
..default()
},
),
transform: Transform::from_translation(game_transform.next_piece_label_translation()),
..default()
},
GameEntityMarker,
));

player_data
.board
.get_next_pieces()
Expand Down
17 changes: 17 additions & 0 deletions src/game/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ impl GameTransform {
self.scale
}

pub fn fs_medium(&self) -> f32 {
self.scale * 36.0
}

pub fn fs_large(&self) -> f32 {
self.scale * 48.0
}

pub fn fs_xlarge(&self) -> f32 {
self.scale * 72.0
}

fn square_width(&self) -> f32 {
self.scale * 36.0
}
Expand Down Expand Up @@ -161,6 +173,11 @@ impl GameTransform {
.extend(BOARD_LAYER)
}

pub fn next_piece_label_translation(&self) -> Vec3 {
(self.next_piece_translation_offset() + Vec2::new(0.0, self.square_height() * 3.5))
.extend(BOARD_LAYER)
}

pub fn next_piece_slot_size(&self, index: usize) -> Vec2 {
self.next_piece_square_size(index) * 5.0
}
Expand Down

0 comments on commit 592e328

Please sign in to comment.