From 23876ffdbb0cf59c4cc8720edde3f9188a17f539 Mon Sep 17 00:00:00 2001 From: Cloud Hu Date: Thu, 28 Nov 2024 10:02:21 +0800 Subject: [PATCH] fix Game Assets load error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit todo:choose character page 修复了因为资源缺少导致的游戏资源加载错误,下一步要整合角色选择页面。 --- Cargo.lock | 15 +++ Cargo.toml | 2 +- README.md | 4 +- assets/texture/juggernaut_character.png | Bin 0 -> 3797 bytes .../texture/juggernaut_character_outline.png | Bin 0 -> 3597 bytes src/assets/game_assets.rs | 108 +++++++++++++++++- src/gameplay/player.rs | 69 ++++++----- src/lib.rs | 42 +------ 8 files changed, 166 insertions(+), 74 deletions(-) create mode 100644 assets/texture/juggernaut_character.png create mode 100644 assets/texture/juggernaut_character_outline.png diff --git a/Cargo.lock b/Cargo.lock index 3edd599..fb6889e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -506,7 +506,9 @@ dependencies = [ "anyhow", "bevy", "bevy_asset_loader_derive", + "bevy_common_assets", "path-slash", + "serde", ] [[package]] @@ -547,6 +549,19 @@ dependencies = [ "wgpu-types", ] +[[package]] +name = "bevy_common_assets" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f631ce2863f3b6f1af3fa24143363b9fbd21c44218caad495a17b83e6968256" +dependencies = [ + "anyhow", + "bevy", + "ron", + "serde", + "thiserror 1.0.65", +] + [[package]] name = "bevy_core" version = "0.14.2" diff --git a/Cargo.toml b/Cargo.toml index d9ebf23..21b741c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.3" edition = "2021" [dependencies] -bevy_asset_loader = "0.21.0" +bevy_asset_loader = { version = "0.21.0", features = [ "2d","standard_dynamic_assets"] } bevy_kira_audio = { version = "0.20.0", features = ["ogg"] } rand = "0.9.0-alpha.2" bevy-parallax = "0.10.0" diff --git a/README.md b/README.md index 04bba2c..1797b38 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ todo…… ______ # 2. 开发记录 ## 2.1 已实现列表 -- [x] 使用`cargo generate thebevyflock/bevy_new_2d`生成的2d游戏模板作为[游戏基础开发框架](https://github.com/TheBevyFlock/bevy_new_2d); +- [x] 使用`cargo generate thebevyflock/bevy_new_2d`生成的2d游戏模板作为[2D游戏基础开发框架bevy_new_2d](https://github.com/TheBevyFlock/bevy_new_2d); - [x] 从[ASCII Space Shooter](https://github.com/JamesHDuffield/ascii-rust)开源项目Copy核心逻辑代码,并优化结构; - [x] 暂停游戏 Pause/Resume - [x] WASM支持 support wasm @@ -67,7 +67,7 @@ ______ ## 3.1 游戏引擎 Game Engine:[Bevy](https://bevyengine.org/) ## 3.2 游戏模板 -- 使用`cargo generate thebevyflock/bevy_new_2d`生成的2d游戏模板 +- 使用`cargo generate thebevyflock/bevy_new_2d`生成的[bevy_new_2d 游戏模板](https://github.com/TheBevyFlock/bevy_new_2d) - 从[ASCII Space Shooter](https://github.com/JamesHDuffield/ascii-rust)开源项目Copy核心逻辑代码 ## 3.3 编译优化 diff --git a/assets/texture/juggernaut_character.png b/assets/texture/juggernaut_character.png new file mode 100644 index 0000000000000000000000000000000000000000..8213e978da96d20b3aa69f1c44f6d5beae501d9e GIT binary patch literal 3797 zcmV;`4l419P)0st5m64nn%SC3J!!e222bg zyb_~XI}w` z8Xg`dV?8}2Z{|$m+OUD#zki=JH#buf?O7O(M_F0f6cFTgyH&zE^YT;z&n#W4{(Eq6 zkP?_`TPq9?CGM>OLEYWmDq)y;AP~T8ynFYqN?=1n!?h#FD;OUVPOKKVrb9I?^kMhk4Kg%^RTAO>*`M713~ zsw1#)-aPel05KAOi!lU*l^2t98~)(IzW6x-q!9@{c< z6R3gHN-N2^D;?y@;INKBwtR*ew`}%%8iCvAB?!xE!0mhEq~hDFB*R%lcH|UjB-&QD zl0e11!LYeC^{TOfn|B^2FMRt5Gmer6U^cRGkhYh!Y_xw!J?HthE{#OnomzBk&&o}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FajEBnTgkdy2%eW&5&#V{(2Yqc9?-6w7k z`YM88UJ_aIwIiy0w?iZJ_|Xqkn{0f0*24`dp(vLHBk<{l#4lF;It`ont$eHo-s>QG z&454ei3sF967)3$R=@2UGj#LEpC!-@vq%6Z-E~g%fq2BfCn?ya7VOdq`aUK5t!5!S zXhOq+-$@(@GS;p0de^-DMzateE|)7dlmz0XkdNA{S^p2-C~zE6%`4LY001p?MObuG zZ)S9NVRB^vVtFoNY;SL5WO*)Qa(QrcZ!T$VVP|D7P)Z)9b1s0M%T00000 LNkvXXu0mjfUfe{X literal 0 HcmV?d00001 diff --git a/assets/texture/juggernaut_character_outline.png b/assets/texture/juggernaut_character_outline.png new file mode 100644 index 0000000000000000000000000000000000000000..82ddc806837ebd9e163b866786fde2ddb7417a28 GIT binary patch literal 3597 zcmV+o4)XDdP)bZ zCeM3!zu);DzwbNWxuMV(?5eJ=&abMf>a3}$VN{Html-lS6kMr$9X@<`stBA2VxXne zw!Uou>h$T;?DFNythu?FojiGxUA=mhMIsRnVqk@-c$Jit3@zSMBCV=5^xG&IFYP!z|0P5}SH35X> zaR6bB_!+*&-xy%$1R6^%@FoKo#5n+U@!~}bJV<9}r}=Zl#;6QGTIVUvSXkMVn6ySc4 z^XJcN0c>w?xBfQZgoAH=g_Qe2U|~7{A+S=B6C#!d8XaWrCzj9fHR7Qd6M0!J;Dm$g zKJ!HG$J<9-;7T`i~G^`5trkw z?X0RiYzlR)yuCy@VbRlbS>cpXoonwKJ~hy?PuJQhBk~OJ`qoVu%^*7;&9nhQ+efgt z=NA5vJ(T%lQ^J+CHgI9BR@G+fdbVNe7{*_>FmqHH7D}LTFTuO_n>k#;MbpNz@`op~ zmKUF~0Z7Ydu((I2&#?g9@YW`2S{WKnRV4w7q1~j~yGW*M=nquG9;+X;^?^c@ge9sr7Ze_ofX1+CGA%Eu6nN2Ed&~ zd!+3pE;T>-R*V%Q=3)T_XvA^-J@f9#Sp6KhcfUJ^l|MAW0uO??MU^j>%S7-Xu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_oQ5wgexteC&u#oKYxd9b`IP0cNof{gC1OV zEqzwHL%{3p6|!vc0if7-&TDGLI)4S5703Mw`$`;o>Ete(hO1Xl0#@6!O zH!Q#!-VL$J!VoK4)h};P8);3eLNQQ~Y(|bQ5_&qXmu^(%K1mxVUpD`b#bu6?)A`6J zZ?m57;OY>odnaT8dfu>1TBM*0WY9l^i#LB^5nV@X&EbsAStD(LaVcFHitJk%D%dpV z)*QD(|Eji@S8h~vpENGTGwizO#UTs!y%E~Be`TmoeC|EJzr~E}<CWk(9~y>3HErsr#gaI+-@kp1+1Bm%bLV0NwiY zVWv(hig%{w2Qq`;^MS-Yue?x*A$~89)u6RlT0n5~IT7)Ejs)3%;;C|Bp<5Tu%^?G` z1=ro@7xDrE{hXv^w_4Dx6ErIfKGn?U0)n3se4^O^WW9a~YLVBPYx_S&m$xZ}csMNp z001p?MObuGZ)S9NVRB^vVtFoNY;SL5WO*)Qa(QrcZ!T$VVP|D7P)Z)9b1 Ts0M%T00000NkvXXu0mjf94h4C literal 0 HcmV?d00001 diff --git a/src/assets/game_assets.rs b/src/assets/game_assets.rs index 27c9709..9b14c73 100644 --- a/src/assets/game_assets.rs +++ b/src/assets/game_assets.rs @@ -4,6 +4,9 @@ use bevy::asset::Handle; use bevy::prelude::*; use bevy_asset_loader::prelude::*; use bevy_kira_audio::AudioSource; +use bevy_asset_loader::standard_dynamic_asset::StandardDynamicAssetCollection; +use bevy_rapier2d::plugin::{RapierConfiguration, TimestepMode}; +use crate::assets::player_assets::PlayerAssets; #[derive(Resource, AssetCollection)] pub struct Fonts { @@ -72,6 +75,109 @@ pub(super) fn plugin(app: &mut App) { .continue_to_state(AppStates::MainMenu) .load_collection::() .load_collection::() - .load_collection::(), + .load_collection::() + .with_dynamic_assets_file::( + "player_assets.assets.ron", + ) + .with_dynamic_assets_file::( + "projectile_assets.assets.ron", + ) + .with_dynamic_assets_file::("mob_assets.assets.ron") + .with_dynamic_assets_file::( + "consumable_assets.assets.ron", + ) + .with_dynamic_assets_file::( + "item_assets.assets.ron", + ) + .with_dynamic_assets_file::( + "effect_assets.assets.ron", + ) + .with_dynamic_assets_file::( + "game_audio_assets.assets.ron", + ) + .with_dynamic_assets_file::("ui_assets.assets.ron") + .load_collection::() + // .load_collection::()//TODO:Assets need to be loaded + // .load_collection::() + // .load_collection::() + // .load_collection::() + // .load_collection::() + // .load_collection::() + // .load_collection::(), + ); + + app.edit_schedule(OnEnter(AppStates::InGame), |schedule| { + schedule.configure_sets( + ( + GameEnterSet::Initialize, + GameEnterSet::BuildLevel, + GameEnterSet::SpawnPlayer, + GameEnterSet::BuildUi, + ) + .chain(), + ); + }); + + app.configure_sets( + Update, + ( + //GameUpdateSet::Enter, + GameUpdateSet::Level, + GameUpdateSet::Spawn, + GameUpdateSet::NextLevel, + GameUpdateSet::UpdateUi, + GameUpdateSet::SetTargetBehavior, + GameUpdateSet::ContactCollision, + GameUpdateSet::IntersectionCollision, + GameUpdateSet::ExecuteBehavior, + GameUpdateSet::ApplyDisconnectedBehaviors, + GameUpdateSet::Movement, + GameUpdateSet::Abilities, + GameUpdateSet::ChangeState, + GameUpdateSet::Cleanup, + ) + .chain(), + ); + + app.add_systems( + OnEnter(AppStates::InGame), + setup_physics.in_set(GameEnterSet::Initialize), ); } + +#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)] +pub enum GameEnterSet { + Initialize, + BuildLevel, + SpawnPlayer, + BuildUi, +} + +#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)] +pub enum GameUpdateSet { + Enter, + Level, + Spawn, + NextLevel, + UpdateUi, + Movement, + Abilities, + SetTargetBehavior, // TODO: replace with more general set + ExecuteBehavior, + ContactCollision, + IntersectionCollision, + ApplyDisconnectedBehaviors, + ChangeState, + Cleanup, +} + +// setup rapier +fn setup_physics(mut rapier_config: ResMut) { + rapier_config.timestep_mode = TimestepMode::Fixed { + dt: 1.0 / 60.0, + substeps: 1, + }; + rapier_config.physics_pipeline_active = true; + rapier_config.query_pipeline_active = true; + rapier_config.gravity = Vec2::ZERO; +} \ No newline at end of file diff --git a/src/gameplay/player.rs b/src/gameplay/player.rs index 666558e..132a38a 100644 --- a/src/gameplay/player.rs +++ b/src/gameplay/player.rs @@ -192,6 +192,7 @@ fn spawn_player( ) { // check if more than one player is playing let is_multiplayer = players_resource.player_data.get(1).is_some(); + println!("spawning player is_multiplayer:{},player_data:{}",is_multiplayer,players_resource.player_data.get(0).is_some()); for (player_id, maybe_player_data) in players_resource .player_data .iter() @@ -207,7 +208,7 @@ fn spawn_player( character.collider_dimensions.x * game_parameters.sprite_scale / 2.0; let collider_size_hy = character.collider_dimensions.y * game_parameters.sprite_scale / 2.0; - + println!("spawning Player"); // create player component from character let player_bundle = PlayerBundle::from(character).with_id(player_id); @@ -216,35 +217,44 @@ fn spawn_player( player_entity .insert(SpriteBundle { texture: player_assets.get_asset(&character.character_type), + transform: Transform::from_translation(Vec3 { + x: 100.0, + y: 100.0, + z: RenderLayer::Player.as_z(), + }), ..Default::default() }) .insert(RigidBody::Dynamic) .insert(LockedAxes::ROTATION_LOCKED_Z) - .insert(Transform { - translation: if is_multiplayer { - Vec3::new( - if matches!(player_id, PlayerIDComponent::One) { - -game_parameters.player_spawn_distance - } else { - game_parameters.player_spawn_distance - }, - 0.0, - if matches!(player_id, PlayerIDComponent::One) { - RenderLayer::Player.as_z() - } else { - RenderLayer::Player.as_z() + 0.2 - }, - ) - } else { - Vec3::ZERO - }, - scale: Vec3::new( - game_parameters.sprite_scale, - game_parameters.sprite_scale, - 1.0, - ), - ..Default::default() - }) + // .insert(Transform { + // translation: if is_multiplayer { + // Vec3::new( + // if matches!(player_id, PlayerIDComponent::One) { + // -game_parameters.player_spawn_distance-100.0 + // } else { + // game_parameters.player_spawn_distance+100.0 + // }, + // 100.0, + // if matches!(player_id, PlayerIDComponent::One) { + // RenderLayer::Player.as_z() + // } else { + // RenderLayer::Player.as_z() + 0.2 + // }, + // ) + // } else { + // Vec3 { + // x: 100.0, + // y: 100.0, + // z: RenderLayer::Player.as_z(), + // } + // }, + // scale: Vec3::new( + // game_parameters.sprite_scale*8.0, + // game_parameters.sprite_scale*8.0, + // 1.0, + // ), + // ..Default::default() + // }) .insert(InputManagerBundle:: { action_state: ActionState::default(), input_map: match player_data.input { @@ -272,7 +282,8 @@ fn spawn_player( parent.spawn_slot_1_ability(&abilities_res, &character.slot_1_ability); parent.spawn_slot_2_ability(&abilities_res, &character.slot_2_ability); }) - .insert(ShipBundle { + .insert( + ShipBundle { physics: Physics::new(config.drag), engine: Engine::new_with_steering( config.power, @@ -310,8 +321,8 @@ fn spawn_player( ..Default::default() }) .insert(Transform::from_translation(Vec3::new( - 0.0, - 0.0, + 100.0, + 100.0, RenderLayer::Player.as_z() + 0.1, ))); }); diff --git a/src/lib.rs b/src/lib.rs index adcc136..f53ecc5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,10 +97,7 @@ impl Plugin for AppPlugin { ); // Spawn the main camera. - app.add_systems(Startup, spawn_camera).add_systems( - OnEnter(AppStates::InGame), - setup_physics.in_set(GameEnterSet::Initialize), - ); + app.add_systems(Startup, spawn_camera); // Add other plugins. app.add_plugins(( @@ -136,32 +133,6 @@ enum AppSet { Update, } -#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)] -pub enum GameEnterSet { - Initialize, - BuildLevel, - SpawnPlayer, - BuildUi, -} - -#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)] -pub enum GameUpdateSet { - Enter, - Level, - Spawn, - NextLevel, - UpdateUi, - Movement, - Abilities, - SetTargetBehavior, // TODO: replace with more general set - ExecuteBehavior, - ContactCollision, - IntersectionCollision, - ApplyDisconnectedBehaviors, - ChangeState, - Cleanup, -} - #[cfg(not(target_arch = "wasm32"))] fn get_display_config() -> DisplayConfig { use ron::de::from_str; @@ -258,14 +229,3 @@ fn spawn_camera(mut commands: Commands, mut create_parallax: EventWriter) { - rapier_config.timestep_mode = TimestepMode::Fixed { - dt: 1.0 / 60.0, - substeps: 1, - }; - rapier_config.physics_pipeline_active = true; - rapier_config.query_pipeline_active = true; - rapier_config.gravity = Vec2::ZERO; -}