Skip to content

Commit

Permalink
feat: guide home text 🌻
Browse files Browse the repository at this point in the history
  • Loading branch information
eerii committed Dec 11, 2023
1 parent 231bc43 commit 03e204e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ source code at: <https://github.com/eerii/charon>
- [x] tutorial text
- [x] fullscreen
- [x] let the player know no tiles left
- [x] initial text when less than 30 entities
- [ ] sounds (ui, entities)
- [ ] initial text when less than 30 entities

- [ ] playtesting and bugfixing (lun)
- [x] review settings menu
Expand Down
41 changes: 40 additions & 1 deletion src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ use crate::{
play_to_real_size, tile_to_pos, EndTile, ForegroundTile, LevelSize, PathTile, StartTile,
TilemapLayer, TilesAvailable, MAP_SIZE,
},
ui::*,
GameState, INITIAL_RESOLUTION,
};

//0, 1, 2, 3, 4, 5, 130, 160, 250, 300, 400, 500, 700, 900, 1200, 1500, 2000, 2500, 3500,
const START_SCORES: [u32; 20] = [
0, 5, 30, 50, 100, 130, 160, 220, 260, 300, 400, 500, 700, 900, 1200, 1500, 2000, 2500, 3500,
0, 5, 25, 50, 100, 130, 160, 220, 260, 300, 400, 500, 700, 900, 1200, 1500, 2000, 2500, 3500,
5000,
];

Expand Down Expand Up @@ -67,6 +68,9 @@ pub struct GameCam {
#[derive(Component)]
pub struct TutorialText;

#[derive(Component)]
pub struct InitialText;

// ·······
// Systems
// ·······
Expand Down Expand Up @@ -136,6 +140,8 @@ fn spawn_start_end(
mut visible: Query<&mut TileVisible>,
mut cam: Query<&mut GameCam>,
tutorial: Query<Entity, With<TutorialText>>,
story_text: Query<Entity, With<InitialText>>,
style: Res<UIStyle>,
) {
// If score is bigger than 1, remove tutorial text
if score.score >= 1 {
Expand Down Expand Up @@ -207,6 +213,39 @@ fn spawn_start_end(
};

if let Some(pos) = spawn_pos {
// Add the story text (between 10 and 30 entities)
if count.start == 2 {
cmd.spawn((
NodeBundle {
style: Style {
position_type: PositionType::Absolute,
width: Val::Percent(100.),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
top: Val::Percent(if pos.y - offset.y < size.y / 2 {
28.
} else {
72.
}),
..default()
},
..default()
},
InitialText,
))
.with_children(|node| {
UIText::simple(&style, "Guide home as many entities as you can")
.with_title()
.add(node);
});
}

if count.start == 3 {
for story_text in story_text.iter() {
cmd.entity(story_text).despawn_recursive();
}
}

for (layer, grid_size, map_type, storage, trans) in tilemap.iter() {
match layer {
// Insert the logical tile in the river
Expand Down
14 changes: 7 additions & 7 deletions src/tilemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ fn highlight_tile(
continue;
}

if start.is_some() {
*tex = TileTextureIndex(9);
continue;
}

*color = TileColor::default();

if let Some(fg) = foreground {
match fg {
ForegroundTile::Start => {
Expand All @@ -337,13 +344,6 @@ fn highlight_tile(
continue;
}

if start.is_some() {
*tex = TileTextureIndex(9);
continue;
}

*color = TileColor::default();

if path.is_some() {
*tex = match path.unwrap().shape {
PathShape::None => TileTextureIndex(0),
Expand Down

0 comments on commit 03e204e

Please sign in to comment.