cozette font
This commit is contained in:
+3
-3
@@ -6,8 +6,8 @@ pub const SCREEN_HEIGHT: f32 = 1080.0;
|
||||
pub const SCREEN_ASPECT: f32 = SCREEN_WIDTH / SCREEN_HEIGHT; // 2:3
|
||||
|
||||
// Grid
|
||||
pub const CELL_SIZE: f32 = 32.0;
|
||||
pub const TERRAIN_COLS: i32 = 21;
|
||||
pub const CELL_SIZE: f32 = 24.0;
|
||||
pub const TERRAIN_COLS: i32 = 30;
|
||||
pub const CHUNK_ROWS: i32 = 32;
|
||||
|
||||
pub const TERRAIN_WIDTH: f32 = CELL_SIZE * TERRAIN_COLS as f32;
|
||||
@@ -19,7 +19,7 @@ pub const MARGIN_ABOVE: f32 = 400.0;
|
||||
pub const MARGIN_BELLOW: f32 = 400.0;
|
||||
|
||||
// Player
|
||||
pub const PLAYER_HITBOX: Vec2 = Vec2::new(20.0, 40.0);
|
||||
pub const PLAYER_HITBOX: Vec2 = Vec2::new(16.0, 32.0);
|
||||
pub const FALL_SPEED: f32 = 500.0;
|
||||
pub const DIVE_SPEED: f32 = 2000.0;
|
||||
pub const HORIZONTAL_SPEED: f32 = 400.0;
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
use bevy::{asset::AssetApp, prelude::*, text::Font};
|
||||
|
||||
const COZETTE_BYTES: &[u8] = include_bytes!("../assets/fonts/CozetteVector.ttf");
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct GameFont(pub Handle<Font>);
|
||||
|
||||
pub struct FontPlugin;
|
||||
|
||||
impl Plugin for FontPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_asset::<Font>();
|
||||
|
||||
let handle = {
|
||||
let mut fonts = app.world_mut().resource_mut::<Assets<Font>>();
|
||||
fonts.add(Font::from_bytes(COZETTE_BYTES.to_vec()))
|
||||
};
|
||||
|
||||
app.insert_resource(GameFont(handle));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
config::START_POSITION,
|
||||
font::GameFont,
|
||||
gameplay::player::{Player, move_player},
|
||||
states::GameState,
|
||||
};
|
||||
@@ -18,11 +19,12 @@ fn update_depth(mut depth: ResMut<Depth>, player: Single<&Transform, With<Player
|
||||
pub struct DepthText;
|
||||
|
||||
// Display the initial text of the depth (Score)
|
||||
fn spawn_depth_text(mut commands: Commands) {
|
||||
fn spawn_depth_text(mut commands: Commands, game_font: Res<GameFont>) {
|
||||
commands.spawn((
|
||||
Text::new("0"),
|
||||
Text::new(""),
|
||||
TextFont {
|
||||
font_size: FontSize::Px(50.0),
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(60.0),
|
||||
..default()
|
||||
},
|
||||
TextColor(Color::WHITE),
|
||||
@@ -39,7 +41,7 @@ fn spawn_depth_text(mut commands: Commands) {
|
||||
// Update depth score texts
|
||||
fn update_depth_text(depth: Res<Depth>, texts: Query<&mut Text, With<DepthText>>) {
|
||||
for mut text in texts {
|
||||
text.0 = format!("Score: {}", (depth.0 / 100.0).floor());
|
||||
text.0 = format!("{}", (depth.0 / 100.0).floor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
use bevy::{prelude::*, window::PresentMode};
|
||||
|
||||
use bevy_egui::{EguiGlobalSettings, EguiPlugin};
|
||||
|
||||
use crate::config::{SCREEN_HEIGHT, SCREEN_WIDTH};
|
||||
use crate::debug::DebugPlugin;
|
||||
use crate::font::FontPlugin;
|
||||
use crate::gameplay::bounds::BoundsPlugin;
|
||||
use crate::gameplay::camera::CameraPlugin;
|
||||
use crate::gameplay::collision::CollisionPlugin;
|
||||
@@ -17,6 +20,7 @@ use crate::world::WorldPlugin;
|
||||
|
||||
mod config;
|
||||
mod debug;
|
||||
mod font;
|
||||
mod gameplay;
|
||||
mod screen;
|
||||
mod states;
|
||||
@@ -38,6 +42,7 @@ fn main() {
|
||||
}),
|
||||
..default()
|
||||
}))
|
||||
.add_plugins(FontPlugin) // Font
|
||||
.add_plugins(PlayerPlugin) // Player
|
||||
.add_plugins(ScreenPlugin) // Virtual screen
|
||||
.add_plugins(CameraPlugin) // Camera
|
||||
@@ -48,6 +53,7 @@ fn main() {
|
||||
.add_plugins(GameStatePlugin) // Game states
|
||||
.add_plugins(MainMenuPlugin) // Main Menu
|
||||
.add_plugins(GameOverPlugin) // GameOver
|
||||
// Debug UI
|
||||
.insert_resource(EguiGlobalSettings {
|
||||
auto_create_primary_context: false,
|
||||
..default()
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{gameplay::camera::MainCamera, states::GameState, world::RunSeed};
|
||||
use crate::{font::GameFont, gameplay::camera::MainCamera, states::GameState, world::RunSeed};
|
||||
|
||||
// To delete game over's components
|
||||
#[derive(Component)]
|
||||
pub struct GameOver;
|
||||
|
||||
fn game_over(mut commands: Commands, mut main_camera: Single<&mut Camera, With<MainCamera>>) {
|
||||
fn game_over(
|
||||
mut commands: Commands,
|
||||
mut main_camera: Single<&mut Camera, With<MainCamera>>,
|
||||
game_font: Res<GameFont>,
|
||||
) {
|
||||
main_camera.is_active = true;
|
||||
|
||||
commands.spawn((
|
||||
@@ -27,6 +31,7 @@ fn game_over(mut commands: Commands, mut main_camera: Single<&mut Camera, With<M
|
||||
(
|
||||
Text::new("GAME OVER"),
|
||||
TextFont {
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(120.0),
|
||||
..default()
|
||||
},
|
||||
@@ -34,6 +39,7 @@ fn game_over(mut commands: Commands, mut main_camera: Single<&mut Camera, With<M
|
||||
(
|
||||
Text::new("N new map | R restart | T main menu"),
|
||||
TextFont {
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(40.0),
|
||||
..default()
|
||||
}
|
||||
|
||||
+51
-8
@@ -1,12 +1,12 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{gameplay::camera::MainCamera, states::GameState};
|
||||
use crate::{font::GameFont, gameplay::camera::MainCamera, states::GameState};
|
||||
|
||||
// To delete menu's components
|
||||
#[derive(Component)]
|
||||
pub struct MainMenu;
|
||||
|
||||
fn main_menu(mut commands: Commands) {
|
||||
fn main_menu(mut commands: Commands, game_font: Res<GameFont>) {
|
||||
commands.spawn((
|
||||
MainMenu,
|
||||
Node {
|
||||
@@ -23,19 +23,62 @@ fn main_menu(mut commands: Commands) {
|
||||
// Texts
|
||||
children![
|
||||
(
|
||||
Text::new("DOWN INTO THE VOID"),
|
||||
Text::new("DOWN INTO"),
|
||||
TextFont {
|
||||
font_size: FontSize::Px(120.0),
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(100.0),
|
||||
..default()
|
||||
},
|
||||
Node {
|
||||
margin: UiRect::bottom(Val::Px(-30.0)),
|
||||
..default()
|
||||
},
|
||||
),
|
||||
(
|
||||
Text::new("Press Enter to fall into the void"),
|
||||
Text::new("THE VOID"),
|
||||
TextFont {
|
||||
font_size: FontSize::Px(40.0),
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(100.0),
|
||||
..default()
|
||||
}
|
||||
)
|
||||
},
|
||||
Node {
|
||||
margin: UiRect::bottom(Val::Px(40.0)),
|
||||
..default()
|
||||
},
|
||||
),
|
||||
(
|
||||
Node {
|
||||
flex_direction: FlexDirection::Row,
|
||||
..default()
|
||||
},
|
||||
children![
|
||||
(
|
||||
Text::new("Press "),
|
||||
TextFont {
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(40.0),
|
||||
..default()
|
||||
},
|
||||
),
|
||||
(
|
||||
Text::new("Enter"),
|
||||
TextFont {
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(40.0),
|
||||
..default()
|
||||
},
|
||||
TextColor(Color::srgb(1.0, 1.0, 0.0)),
|
||||
),
|
||||
(
|
||||
Text::new(" to fall"),
|
||||
TextFont {
|
||||
font: FontSource::Handle(game_font.0.clone()),
|
||||
font_size: FontSize::Px(40.0),
|
||||
..default()
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user