Skip to content

Commit 03e204e

Browse files
committed
feat: guide home text 🌻
1 parent 231bc43 commit 03e204e

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ source code at: <https://github.com/eerii/charon>
8181
- [x] tutorial text
8282
- [x] fullscreen
8383
- [x] let the player know no tiles left
84+
- [x] initial text when less than 30 entities
8485
- [ ] sounds (ui, entities)
85-
- [ ] initial text when less than 30 entities
8686

8787
- [ ] playtesting and bugfixing (lun)
8888
- [x] review settings menu

‎src/game.rs‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ use crate::{
1212
play_to_real_size, tile_to_pos, EndTile, ForegroundTile, LevelSize, PathTile, StartTile,
1313
TilemapLayer, TilesAvailable, MAP_SIZE,
1414
},
15+
ui::*,
1516
GameState, INITIAL_RESOLUTION,
1617
};
1718

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

@@ -67,6 +68,9 @@ pub struct GameCam {
6768
#[derive(Component)]
6869
pub struct TutorialText;
6970

71+
#[derive(Component)]
72+
pub struct InitialText;
73+
7074
// ·······
7175
// Systems
7276
// ·······
@@ -136,6 +140,8 @@ fn spawn_start_end(
136140
mut visible: Query<&mut TileVisible>,
137141
mut cam: Query<&mut GameCam>,
138142
tutorial: Query<Entity, With<TutorialText>>,
143+
story_text: Query<Entity, With<InitialText>>,
144+
style: Res<UIStyle>,
139145
) {
140146
// If score is bigger than 1, remove tutorial text
141147
if score.score >= 1 {
@@ -207,6 +213,39 @@ fn spawn_start_end(
207213
};
208214

209215
if let Some(pos) = spawn_pos {
216+
// Add the story text (between 10 and 30 entities)
217+
if count.start == 2 {
218+
cmd.spawn((
219+
NodeBundle {
220+
style: Style {
221+
position_type: PositionType::Absolute,
222+
width: Val::Percent(100.),
223+
align_items: AlignItems::Center,
224+
justify_content: JustifyContent::Center,
225+
top: Val::Percent(if pos.y - offset.y < size.y / 2 {
226+
28.
227+
} else {
228+
72.
229+
}),
230+
..default()
231+
},
232+
..default()
233+
},
234+
InitialText,
235+
))
236+
.with_children(|node| {
237+
UIText::simple(&style, "Guide home as many entities as you can")
238+
.with_title()
239+
.add(node);
240+
});
241+
}
242+
243+
if count.start == 3 {
244+
for story_text in story_text.iter() {
245+
cmd.entity(story_text).despawn_recursive();
246+
}
247+
}
248+
210249
for (layer, grid_size, map_type, storage, trans) in tilemap.iter() {
211250
match layer {
212251
// Insert the logical tile in the river

‎src/tilemap.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,13 @@ fn highlight_tile(
325325
continue;
326326
}
327327

328+
if start.is_some() {
329+
*tex = TileTextureIndex(9);
330+
continue;
331+
}
332+
333+
*color = TileColor::default();
334+
328335
if let Some(fg) = foreground {
329336
match fg {
330337
ForegroundTile::Start => {
@@ -337,13 +344,6 @@ fn highlight_tile(
337344
continue;
338345
}
339346

340-
if start.is_some() {
341-
*tex = TileTextureIndex(9);
342-
continue;
343-
}
344-
345-
*color = TileColor::default();
346-
347347
if path.is_some() {
348348
*tex = match path.unwrap().shape {
349349
PathShape::None => TileTextureIndex(0),

0 commit comments

Comments
 (0)