Skip to content

Commit d098dfb

Browse files
authored
feat: new game font (#16)
* feat: add new font and use everywhere * docs: add credits for new fonts * fix: correct collider
1 parent d47decc commit d098dfb

File tree

14 files changed

+218
-37
lines changed

14 files changed

+218
-37
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
- Fedora: `sudo dnf install mold clang`
88
- Arch: `sudo pacman -S mold clang`
99
2. This repository uses Git LFS. Follow the installation instructions [here](https://packagecloud.io/github/git-lfs/install). Afterwards, run `git lfs pull` to get all assets
10-
3. Please note that shipping the binary requires disabling dynamic linking. This can be achieved by removing the `dynamic_linking` feature from the dependency `bevy` in `Cargo.toml`
11-
4. Bevy itself also needs a couple of dependency. You can find installation instructions for Linux, Windows and MacOS [here](https://bevy.org/learn/quick-start/getting-started/setup/#installing-os-dependencies)
12-
5. Install alternative codegen backend: `rustup component add rustc-codegen-cranelift-preview --toolchain-nightly`
10+
3. Bevy itself also needs a couple of dependency. You can find installation instructions for Linux, Windows and MacOS [here](https://bevy.org/learn/quick-start/getting-started/setup/#installing-os-dependencies)
11+
4. Install alternative codegen backend: `rustup component add rustc-codegen-cranelift-preview --toolchain-nightly`
1312
5. Run the app
1413
- `cargo run`
1514

@@ -64,5 +63,9 @@ uses:
6463
- SWAT by Quaternius (https://poly.pizza/m/Btfn3G5Xv4)
6564
- "LOWPOLY | FPS | TDM | GAME | MAP by ResoForge" (https://skfb.ly/pxM87) by ResoForge (old profile) is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
6665

66+
### Fonts
67+
- Ignotum Designed by GGBotNet https://www.ggbot.net/fonts/
68+
- AVA Designed by GGBotNet https://www.ggbot.net/fonts/
69+
6770
### Music & SFX
6871
- Main Menu Theme by [juanjo_sound](https://juanjosound.itch.io/)

assets/fonts/AVA.ttf

35.4 KB
Binary file not shown.
66.6 KB
Binary file not shown.
72.4 KB
Binary file not shown.
71.4 KB
Binary file not shown.
63.4 KB
Binary file not shown.

src/user_interface/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use bevy::{
33
prelude::*,
44
};
55

6+
use crate::game_flow::states::{AppState, MainMenuState};
7+
68
pub struct CommonUiPlugin;
79

810
impl Plugin for CommonUiPlugin {
@@ -18,12 +20,15 @@ impl Plugin for CommonUiPlugin {
1820
pub struct CommonUiButton(pub CommonUiButtonType);
1921

2022
pub enum CommonUiButtonType {
23+
BackToMainMenu,
2124
Quit,
2225
}
2326

2427
fn handle_common_ui_button_interaction(
2528
query: Query<(&Interaction, &CommonUiButton), Changed<Interaction>>,
2629
mut app_exit_message_writer: MessageWriter<AppExit>,
30+
mut next_app_state: ResMut<NextState<AppState>>,
31+
mut main_menu_state: ResMut<NextState<MainMenuState>>,
2732
) {
2833
for (interaction, common_ui_button) in query {
2934
let Interaction::Pressed = interaction else {
@@ -33,6 +38,10 @@ fn handle_common_ui_button_interaction(
3338
CommonUiButtonType::Quit => {
3439
app_exit_message_writer.write(AppExit::Success);
3540
}
41+
CommonUiButtonType::BackToMainMenu => {
42+
next_app_state.set(AppState::MainMenu);
43+
main_menu_state.set(MainMenuState::Root);
44+
}
3645
}
3746
}
3847
}

src/user_interface/death_screen.rs

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use bevy::prelude::*;
33
use crate::{
44
game_flow::{states::InGameState, systems::free_mouse},
55
player::Player,
6-
user_interface::common::{CommonUiButton, CommonUiButtonType},
6+
user_interface::{
7+
DEFAULT_GAME_FONT_PATH,
8+
common::{CommonUiButton, CommonUiButtonType},
9+
},
710
};
811

912
pub struct DeathScreenPlugin;
@@ -53,16 +56,44 @@ fn spawn_death_screen(asset_server: Res<AssetServer>, mut commands: Commands) {
5356
),
5457
..default()
5558
})
56-
.with_child(Text::new("You are dead"));
57-
parent.spawn(Text::new("Tip:"));
58-
parent.spawn(Text::new("Take cover when under heavy shooting!"));
59+
.with_child((
60+
Text::new("You are dead"),
61+
TextFont {
62+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
63+
font_size: 32.0,
64+
..default()
65+
},
66+
));
67+
parent.spawn((
68+
Text::new("Tip:"),
69+
TextFont {
70+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
71+
font_size: 32.0,
72+
..default()
73+
},
74+
));
75+
parent.spawn((
76+
Text::new("Take cover when under heavy shooting!"),
77+
TextFont {
78+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
79+
font_size: 32.0,
80+
..default()
81+
},
82+
));
5983
parent
6084
.spawn((
6185
Node { ..default() },
6286
Button,
6387
DeathScreenButton(DeathScreenButtonType::Respawn),
6488
))
65-
.with_child(Text::new("Respawn"));
89+
.with_child((
90+
Text::new("Respawn"),
91+
TextFont {
92+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
93+
font_size: 32.0,
94+
..default()
95+
},
96+
));
6697
parent
6798
.spawn((
6899
Node {
@@ -73,9 +104,16 @@ fn spawn_death_screen(asset_server: Res<AssetServer>, mut commands: Commands) {
73104
..default()
74105
},
75106
Button,
76-
CommonUiButton(CommonUiButtonType::Quit),
107+
CommonUiButton(CommonUiButtonType::BackToMainMenu),
77108
))
78-
.with_child(Text::new("Rage Quit"));
109+
.with_child((
110+
Text::new("Exit to Main Menu"),
111+
TextFont {
112+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
113+
font_size: 32.0,
114+
..default()
115+
},
116+
));
79117
});
80118
}
81119

src/user_interface/game_mode_selection.rs

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use bevy::prelude::*;
22

3-
use crate::game_flow::{
4-
game_mode::{GameMode, StartGameModeMessage},
5-
states::{AppState, MainMenuState},
3+
use crate::{
4+
game_flow::{
5+
game_mode::{GameMode, StartGameModeMessage},
6+
states::{AppState, MainMenuState},
7+
},
8+
user_interface::DEFAULT_GAME_FONT_PATH,
69
};
710

811
pub struct GameModeSelectionUIPlugin;
@@ -36,7 +39,10 @@ enum GameModeSelectionActionButtonType {
3639
GoBack,
3740
}
3841

39-
fn spawn_game_mode_selection_screen(mut commands: Commands) {
42+
fn spawn_game_mode_selection_screen(
43+
asset_server: Res<AssetServer>,
44+
mut commands: Commands,
45+
) {
4046
info!("Spawning GameModeSelectionScreen");
4147
commands
4248
.spawn((
@@ -62,23 +68,44 @@ fn spawn_game_mode_selection_screen(mut commands: Commands) {
6268
),
6369
..default()
6470
})
65-
.with_child(Text::new("Select a game mode"));
71+
.with_child((
72+
Text::new("Select a game mode"),
73+
TextFont {
74+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
75+
font_size: 24.0,
76+
..default()
77+
},
78+
));
6679
parent
6780
.spawn((
6881
Node { ..default() },
6982
Button,
7083
GameModeSelectionButton(GameMode::Waves),
7184
TextColor::WHITE,
7285
))
73-
.with_child(Text::new("Waves"));
86+
.with_child((
87+
Text::new("Waves"),
88+
TextFont {
89+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
90+
font_size: 24.0,
91+
..default()
92+
},
93+
));
7494
parent
7595
.spawn((
7696
Node { ..default() },
7797
Button,
7898
GameModeSelectionButton(GameMode::FreePlay),
7999
TextColor::WHITE,
80100
))
81-
.with_child(Text::new("Free Play"));
101+
.with_child((
102+
Text::new("Free Play"),
103+
TextFont {
104+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
105+
font_size: 24.0,
106+
..default()
107+
},
108+
));
82109
parent
83110
.spawn((
84111
Node {
@@ -94,7 +121,14 @@ fn spawn_game_mode_selection_screen(mut commands: Commands) {
94121
),
95122
TextColor::WHITE,
96123
))
97-
.with_child(Text::new("Go back"));
124+
.with_child((
125+
Text::new("Go back"),
126+
TextFont {
127+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
128+
font_size: 24.0,
129+
..default()
130+
},
131+
));
98132
});
99133
}
100134

src/user_interface/main_menu.rs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
use bevy::prelude::*;
1+
use bevy::prelude::*;
22

3-
use crate::game_flow::states::MainMenuState;
3+
use crate::{
4+
game_flow::states::MainMenuState,
5+
user_interface::{AVA_FONT_PATH, DEFAULT_GAME_FONT_PATH},
6+
};
47

58
pub struct MainMenuPlugin;
69

@@ -23,7 +26,7 @@ enum MainMenuButtonType {
2326
Quit,
2427
}
2528

26-
fn spawn_main_menu(mut commands: Commands) {
29+
fn spawn_main_menu(asset_server: Res<AssetServer>, mut commands: Commands) {
2730
info!("Spawning Main Menu");
2831
commands
2932
.spawn((
@@ -44,26 +47,47 @@ fn spawn_main_menu(mut commands: Commands) {
4447
Val::ZERO,
4548
Val::ZERO,
4649
Val::ZERO,
47-
Val::Px(16.0),
50+
Val::Px(32.0),
4851
),
4952
..default()
5053
})
51-
.with_child(Text::new("Main Menu"));
54+
.with_child((
55+
Text::new("Fun Shooter"),
56+
TextFont {
57+
font: asset_server.load(AVA_FONT_PATH),
58+
font_size: 64.,
59+
..default()
60+
},
61+
));
5262
parent
5363
.spawn((
5464
Node { ..default() },
5565
Button,
5666
MainMenuButton(MainMenuButtonType::Singleplayer),
5767
TextColor::WHITE,
5868
))
59-
.with_child(Text::new("Singleplayer"));
69+
.with_child((
70+
Text::new("Singleplayer"),
71+
TextFont {
72+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
73+
font_size: 32.0,
74+
..default()
75+
},
76+
));
6077
parent
6178
.spawn((
6279
Node { ..default() },
6380
Button,
6481
MainMenuButton(MainMenuButtonType::SettingsMainMenu),
6582
))
66-
.with_child(Text::new("Settings"));
83+
.with_child((
84+
Text::new("Settings"),
85+
TextFont {
86+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
87+
font_size: 32.0,
88+
..default()
89+
},
90+
));
6791
parent
6892
.spawn((
6993
Node {
@@ -77,7 +101,14 @@ fn spawn_main_menu(mut commands: Commands) {
77101
MainMenuButton(MainMenuButtonType::Quit),
78102
TextColor::WHITE,
79103
))
80-
.with_child(Text::new("Quit"));
104+
.with_child((
105+
Text::new("Quit"),
106+
TextFont {
107+
font: asset_server.load(DEFAULT_GAME_FONT_PATH),
108+
font_size: 32.0,
109+
..default()
110+
},
111+
));
81112
});
82113
}
83114

0 commit comments

Comments
 (0)