├── assets ├── 9_1.scr.ron ├── X.png ├── Y.png ├── Z.png ├── bevy.png ├── arrow.png ├── Raleway-Bold.ttf ├── 9_2.scr.ron ├── 9_0.scr.ron ├── 9_3.scr.ron ├── 8.scr.ron ├── gltf.gltf ├── part_scene.scn.ron └── scene.scn.ron ├── examples ├── transform.rs ├── visibility.rs └── rotation.rs ├── Cargo.toml ├── src ├── user_input │ ├── touch.rs │ ├── mouse.rs │ ├── keyboard.rs │ └── gamepad.rs ├── lib.rs ├── common.rs ├── local.rs ├── ecs.rs ├── events.rs ├── visibility.rs ├── main.rs ├── user_input.rs ├── systems.rs ├── components.rs ├── query.rs ├── transform.rs ├── resources.rs ├── reflect.rs ├── scenes.rs └── entitys.rs ├── test_scene.scn.ron └── scene.scn.ron /assets/9_1.scr.ron: -------------------------------------------------------------------------------- 1 | ( 2 | entities: { 3 | 4 | } 5 | ) -------------------------------------------------------------------------------- /assets/X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhaestusFox/BevyBasics/HEAD/assets/X.png -------------------------------------------------------------------------------- /assets/Y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhaestusFox/BevyBasics/HEAD/assets/Y.png -------------------------------------------------------------------------------- /assets/Z.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhaestusFox/BevyBasics/HEAD/assets/Z.png -------------------------------------------------------------------------------- /assets/bevy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhaestusFox/BevyBasics/HEAD/assets/bevy.png -------------------------------------------------------------------------------- /assets/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhaestusFox/BevyBasics/HEAD/assets/arrow.png -------------------------------------------------------------------------------- /assets/Raleway-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhaestusFox/BevyBasics/HEAD/assets/Raleway-Bold.ttf -------------------------------------------------------------------------------- /examples/transform.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use bevy_basics::prelude::*; 3 | 4 | fn main() { 5 | App::new() 6 | .add_plugins(DefaultPlugins) 7 | .add_plugin(CommonPlugin) 8 | .add_plugin(TransformExample) 9 | .add_startup_system(spawn_cam) 10 | .run() 11 | } 12 | -------------------------------------------------------------------------------- /assets/9_2.scr.ron: -------------------------------------------------------------------------------- 1 | ( 2 | entities: { 3 | 0: ( 4 | components: { 5 | "type_name": ( 6 | translation: ( 7 | x: 0.0, 8 | y: 0.0, 9 | z: 0.0 10 | ), 11 | ), 12 | }, 13 | ), 14 | } 15 | ) -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bevy_basics" 3 | version = "0.1.0" 4 | edition = "2021" 5 | resolver = "2" 6 | 7 | 8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 | 10 | [dependencies] 11 | bevy = {version = "0.9.1"} 12 | bevy-inspector-egui = "0.14.0" 13 | bevy_editor_pls = {git = "https://github.com/PhaestusFox/bevy_editor_pls"} 14 | ron = "0.8.0" 15 | rand = "0.8.5" 16 | serde = "1.0.144" -------------------------------------------------------------------------------- /assets/9_0.scr.ron: -------------------------------------------------------------------------------- 1 | ( 2 | entities: { 3 | 0: ( 4 | components: { 5 | "bevy_transform::components::transform::Transform": ( 6 | translation: ( 7 | x: 0.0, 8 | y: 0.0, 9 | z: 0.0 10 | ), 11 | rotation: (0.0, 0.0, 0.0, 1.0), 12 | scale: ( 13 | x: 1.0, 14 | y: 1.0, 15 | z: 1.0 16 | ), 17 | ), 18 | "scene::ComponentB": ( 19 | value: "hello", 20 | ), 21 | "scene::ComponentA": ( 22 | x: 1.0, 23 | y: 2.0, 24 | ), 25 | }, 26 | ), 27 | 1: ( 28 | components: { 29 | "scene::ComponentA": ( 30 | x: 3.0, 31 | y: 4.0, 32 | ), 33 | }, 34 | ), 35 | } 36 | ) -------------------------------------------------------------------------------- /src/user_input/touch.rs: -------------------------------------------------------------------------------- 1 | use super::InputExample; 2 | use bevy::prelude::*; 3 | 4 | pub struct TouchExample; 5 | impl Plugin for TouchExample { 6 | fn build(&self, app: &mut App) { 7 | app.add_system_set(SystemSet::on_update(InputExample::TouchEvent).with_system(touch_event)) 8 | .add_system_set( 9 | SystemSet::on_update(InputExample::TouchInput).with_system(touch_input), 10 | ); 11 | } 12 | } 13 | 14 | fn touch_event(mut touchs: EventReader) { 15 | for touch in touchs.iter() { 16 | if touch.phase == bevy::input::touch::TouchPhase::Started { 17 | println!("touch: {:?}", touch); 18 | } 19 | } 20 | } 21 | 22 | fn touch_input(touchs: Res) { 23 | for touch in touchs.iter() { 24 | println!("touch: {:?}", touch); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | mod common; 4 | pub use prelude::*; 5 | pub mod prelude { 6 | pub use super::{ 7 | common::*, components::ComponentPlugin, ecs::ECSExample, entitys::EntityPlugin, 8 | reflect::ReflectExample, resources::ResourcePlugin, scenes::ScenesExample, spawn_cam, 9 | systems::SystemPlugin, transform::TransformExample, user_input::InputExample, 10 | visibility::VisibilityExample, 11 | }; 12 | } 13 | 14 | mod components; 15 | mod ecs; 16 | mod entitys; 17 | #[allow(dead_code)] 18 | mod events; 19 | #[allow(dead_code)] 20 | mod local; 21 | #[allow(dead_code)] 22 | mod query; 23 | #[allow(dead_code)] 24 | mod reflect; 25 | mod resources; 26 | mod scenes; 27 | mod systems; 28 | mod transform; 29 | #[allow(dead_code)] 30 | mod user_input; 31 | mod visibility; 32 | pub fn spawn_cam(mut commands: Commands) { 33 | let trans = Transform::from_xyz(5., 5., 5.); 34 | commands 35 | .spawn(Camera3dBundle { 36 | transform: trans.looking_at(Vec3::ZERO, Vec3::Y), 37 | ..Default::default() 38 | }) 39 | .insert(common::MainCamera); 40 | commands.spawn(SpotLightBundle { 41 | transform: trans.looking_at(Vec3::ZERO, Vec3::Y), 42 | ..Default::default() 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /src/common.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | pub use crate::components::{BBDirection, ComponentExample as BoxBall, Speed, WorldSize}; 4 | pub use crate::resources::{ColorSet, ColorWheel, DefaultFont}; 5 | 6 | #[derive(Component)] 7 | pub struct MainCamera; 8 | 9 | #[derive(Component)] 10 | pub struct UiCamera; 11 | 12 | pub struct CommonPlugin; 13 | 14 | impl Plugin for CommonPlugin { 15 | fn build(&self, app: &mut App) { 16 | app.insert_resource(SpamTime(Timer::from_seconds(2., TimerMode::Repeating))); 17 | app.add_system_to_stage(CoreStage::First, timer_updata); 18 | app.register_type::(); 19 | app.register_type::(); 20 | app.add_event::(); 21 | app.add_system(reset_system); 22 | } 23 | } 24 | 25 | fn reset_system(mut events: EventWriter, input: Res>) { 26 | if input.just_pressed(KeyCode::Space) { 27 | println!("send reset"); 28 | events.send(Events::Reset); 29 | } 30 | } 31 | 32 | #[derive(Resource)] 33 | pub struct SpamTime(Timer); 34 | 35 | impl SpamTime { 36 | pub fn finished(&self) -> bool { 37 | self.0.finished() 38 | } 39 | } 40 | 41 | fn timer_updata(time: Res