Skip to content

Commit

Permalink
Add time label to game UI and adjust the position of DAS and LEVEL ic…
Browse files Browse the repository at this point in the history
…ons.
  • Loading branch information
Ramirisu committed Sep 23, 2024
1 parent e86584b commit bcca211
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
24 changes: 16 additions & 8 deletions src/game/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn setup_screen(
..default()
}),
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 24.0,
font_size: game_transform.scale() * 36.0,
color: WHITE.into(),
..default()
}),
Expand Down Expand Up @@ -334,14 +334,22 @@ fn setup_screen(
));
commands.spawn((
Text2dBundle {
text: Text::from_section(
"",
TextStyle {
text: Text::from_sections([
TextSection {
value: "TIME ".into(),
style: TextStyle {
font_size: game_transform.scale() * 36.0,
color: WHITE.into(),
..default()
},
..default()
},
TextSection::from_style(TextStyle {
font_size: game_transform.scale() * 36.0,
color: WHITE.into(),
..default()
},
),
}),
]),
transform: Transform::from_translation(game_transform.game_stopwatch_translation()),
..default()
},
Expand Down Expand Up @@ -493,7 +501,7 @@ fn update_statistics_system(
}
if let Ok(mut text) = query.p2().get_single_mut() {
text.sections[1].value = format!("{:02}", player_data.board.level());
text.sections[2].value = format!(" {:02}", player_data.board.start_level());
text.sections[2].value = format!(" ({:02})", player_data.board.start_level());
}
if let Ok(mut text) = query.p3().get_single_mut() {
text.sections[0].value = format!("BRN {:4}\n", player_data.board.burned_lines());
Expand Down Expand Up @@ -529,7 +537,7 @@ fn update_statistics_system(
}
}
if let Ok(mut text) = query.p5().get_single_mut() {
text.sections[0].value = format_hhmmss(player_data.game_stopwatch.elapsed());
text.sections[1].value = format_hhmmss(player_data.game_stopwatch.elapsed());
}
for (mut text, piece) in query.p6().iter_mut() {
text.sections[0].value = format!("{:03}", player_data.board.get_piece_count(piece.0));
Expand Down
30 changes: 17 additions & 13 deletions src/game/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,24 @@ impl GameTransform {
Vec3::new(self.board_width(), self.square_height() * 9.0, BOARD_LAYER)
}

pub fn das_translation(&self) -> Vec3 {
Vec3::new(
self.board_width() * 0.8,
-self.square_height() * 6.0,
BOARD_LAYER,
)
}

pub fn level_translation(&self) -> Vec3 {
Vec3::new(self.board_width(), -self.square_height() * 6.0, BOARD_LAYER)
Vec3::new(self.board_width(), -self.square_height() * 8.0, BOARD_LAYER)
}

pub fn game_stopwatch_translation(&self) -> Vec3 {
Vec3::new(
self.board_width(),
-self.square_height() * 10.0,
BOARD_LAYER,
)
}

fn next_piece_translation_offset(&self) -> Vec2 {
Expand Down Expand Up @@ -127,18 +143,6 @@ impl GameTransform {
Vec3::new(-self.board_width(), self.square_height() * 3.0, BOARD_LAYER)
}

pub fn das_translation(&self) -> Vec3 {
Vec3::new(self.board_width(), -self.square_height() * 8.0, BOARD_LAYER)
}

pub fn game_stopwatch_translation(&self) -> Vec3 {
Vec3::new(
self.board_width(),
-self.square_height() * 10.0,
BOARD_LAYER,
)
}

pub fn piece_count_square_size(&self) -> Vec2 {
Vec2::new(self.square_width() * 0.5, self.square_height() * 0.5)
}
Expand Down

0 comments on commit bcca211

Please sign in to comment.