Browse Source

:sparkles::construction: started working on main menu

added font
Felix Bytow 2 years ago
parent
commit
7d598edb97

BIN
assets/fonts/videophreak/VIDEOPHREAK.ttf


+ 14 - 0
assets/fonts/videophreak/pizzadudedotdk.txt

@@ -0,0 +1,14 @@
+Thank you for downloading this font!
+
+This font is copyright (c) Jakob Fischer at www.pizzadude.dk,  all rights reserved. Do not distribute without the author's permission.
+
+Use this font for non-commercial use only! If you plan to use it for commercial purposes, contact me before doing so!
+
+
+For more original fonts take a look at www.pizzadude.dk
+
+Have fun and enjoy!
+
+Jakob Fischer
+jakob@pizzadude.dk
+www.pizzadude.dk

+ 3 - 1
src/assets.rs

@@ -1 +1,3 @@
-pub const LOGO: &'static str = "images/logo.jpg";
+pub const IMAGE_LOGO: &'static str = "images/logo.jpg";
+
+pub const FONT_VIDEOPHREAD: &'static str = "fonts/videophreak/VIDEOPHREAK.ttf";

+ 4 - 5
src/game_state/logo.rs

@@ -1,7 +1,7 @@
 use bevy::core::Stopwatch;
 use bevy::prelude::*;
 
-use crate::assets::LOGO;
+use crate::assets::IMAGE_LOGO;
 use crate::game_state::GameState;
 
 #[derive(Clone, Debug)]
@@ -28,10 +28,10 @@ pub struct LogoPlugin;
 fn setup_logo(
     mut commands: Commands,
     filename: Option<Res<LogoFilename>>,
-    assert_server: Res<AssetServer>,
+    asset_server: Res<AssetServer>,
     windows: Res<Windows>,
 ) {
-    let path = filename.map_or_else(|| LOGO.to_string(), |res| res.0.clone());
+    let path = filename.map_or_else(|| IMAGE_LOGO.to_string(), |res| res.0.clone());
     let window = windows.primary();
     let (win_w, win_h) = (window.width(), window.height());
 
@@ -40,7 +40,7 @@ fn setup_logo(
         .insert(Logo { path: path.clone() })
         .insert(LogoMarker)
         .insert_bundle(SpriteBundle {
-            texture: assert_server.load(&path),
+            texture: asset_server.load(&path),
             transform: Transform {
                 translation: Vec3::new(0.0, 0.0, 0.0),
                 ..Default::default()
@@ -136,7 +136,6 @@ fn animate_logo(
 impl Plugin for LogoPlugin {
     fn build(&self, app: &mut App) {
         let state = GameState::Logo;
-        app.add_state(state);
         app.add_system_set(SystemSet::on_enter(state).with_system(setup_logo));
         app.add_system_set(SystemSet::on_update(state)
             .with_system(resize_logo)

+ 34 - 0
src/game_state/main_menu.rs

@@ -0,0 +1,34 @@
+use bevy::prelude::*;
+use crate::assets::FONT_VIDEOPHREAD;
+use crate::game_state::GameState;
+
+pub struct MainMenuPlugin;
+
+#[derive(Component)]
+struct MainMenuOption;
+
+#[derive(Component)]
+struct Active;
+
+fn setup_main_menu(
+    mut commands: Commands,
+    asset_server: Res<AssetServer>,
+) {
+    let font = asset_server.load(FONT_VIDEOPHREAD);
+    let text_style = TextStyle {
+        font,
+        font_size: 60.0,
+        color: Color::WHITE,
+    };
+    let text_alignment = TextAlignment {
+        vertical: VerticalAlign::Center,
+        horizontal: HorizontalAlign::Center,
+    };
+}
+
+impl Plugin for MainMenuPlugin {
+    fn build(&self, app: &mut App) {
+        let state = GameState::MainMenu;
+        app.add_system_set(SystemSet::on_enter(state).with_system(setup_main_menu));
+    }
+}

+ 1 - 0
src/game_state/mod.rs

@@ -1,4 +1,5 @@
 pub mod logo;
+pub mod main_menu;
 
 #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)]
 pub enum GameState {

+ 3 - 0
src/main.rs

@@ -1,5 +1,6 @@
 use bevy::prelude::*;
 use bevy::window::PresentMode;
+use crate::game_state::GameState;
 
 pub mod game_state;
 pub mod assets;
@@ -21,5 +22,7 @@ fn main() {
         .add_plugins(DefaultPlugins)
         .add_startup_system(setup_2d_camera)
         .add_plugin(game_state::logo::LogoPlugin)
+        .add_plugin(game_state::main_menu::MainMenuPlugin)
+        .add_state(GameState::Logo)
         .run();
 }