diff --git a/turtle-example/Cargo.toml b/turtle-example/Cargo.toml index 806c1b6..6ff0e34 100644 --- a/turtle-example/Cargo.toml +++ b/turtle-example/Cargo.toml @@ -1,17 +1,14 @@ -[workspace] -resolver = "2" +[package] +name = "turtle-example" +version = "0.1.0" +edition = "2021" +license = "MIT OR Apache-2.0" -members = [ - "turtle-lib", - "turtle-example", -] - - -# Enable a small amount of optimization in debug mode -[profile.dev] -opt-level = 1 - -# Enable high optimizations for dependencies (incl. Bevy), but not for our code: -[profile.dev.package."*"] -opt-level = 3 +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies] +bevy = { workspace = true, features = ["wayland"] } +bevy_prototype_lyon = { workspace = true } +num-traits = { workspace = true } +rand = { workspace = true } +turtle-lib = { path = "../turtle-lib" } diff --git a/turtle-example/examples/interrupted_lines.rs b/turtle-example/examples/interrupted_lines.rs index a4ae165..a482720 100644 --- a/turtle-example/examples/interrupted_lines.rs +++ b/turtle-example/examples/interrupted_lines.rs @@ -9,11 +9,11 @@ struct Egon {} fn main() { App::new() - .add_plugin(TurtlePlugin) - .add_startup_system(setup) - //.add_system(plan) - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugins(TurtlePlugin) + .add_systems(Startup, setup) + //.add_systems(Update, plan) + .add_plugins(LogDiagnosticsPlugin::default()) + .add_plugins(FrameTimeDiagnosticsPlugin::default()) .run(); } @@ -21,7 +21,9 @@ fn setup(mut commands: Commands) { let mut turtle = get_a_turtle(); turtle.set_speed(1); - let mt = turtle.pen_up(); + // NOTE: pen_up() consumes self, which is why this example is incomplete + // TODO: Fix the builder API to work with the deref pattern + // let mt = turtle.pen_up(); - //commands.spawn((turtle, Egon {})); + commands.spawn((turtle, Egon {})); } diff --git a/turtle-example/examples/koch.rs b/turtle-example/examples/koch.rs index d0909f2..0f42a18 100644 --- a/turtle-example/examples/koch.rs +++ b/turtle-example/examples/koch.rs @@ -10,11 +10,11 @@ struct Egon {} fn main() { App::new() - .add_plugin(TurtlePlugin) - .add_startup_system(setup) - //.add_system(plan) - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugins(TurtlePlugin) + .add_systems(Startup, setup) + //.add_systems(Update, plan) + .add_plugins(LogDiagnosticsPlugin::default()) + .add_plugins(FrameTimeDiagnosticsPlugin::default()) .run(); } @@ -22,7 +22,7 @@ fn setup(mut commands: Commands) { let mut turtle = get_a_turtle(); turtle.set_speed(1); for _x in 0..3 { - koch(3, &mut turtle); + koch(4, &mut turtle); turtle.right(120); } commands.spawn((turtle, Egon {})); diff --git a/turtle-example/examples/nikolaus.rs b/turtle-example/examples/nikolaus.rs index 4818011..564f9a1 100644 --- a/turtle-example/examples/nikolaus.rs +++ b/turtle-example/examples/nikolaus.rs @@ -10,11 +10,11 @@ struct Egon {} fn main() { App::new() - .add_plugin(TurtlePlugin) - .add_startup_system(setup) - //.add_system(plan) - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugins(TurtlePlugin) + .add_systems(Startup, setup) + //.add_systems(Update, plan) + .add_plugins(LogDiagnosticsPlugin::default()) + .add_plugins(FrameTimeDiagnosticsPlugin::default()) .run(); } diff --git a/turtle-example/examples/stern.rs b/turtle-example/examples/stern.rs index 87dd492..9c7b0ca 100644 --- a/turtle-example/examples/stern.rs +++ b/turtle-example/examples/stern.rs @@ -10,17 +10,17 @@ struct Egon {} fn main() { App::new() - .add_plugin(TurtlePlugin) - .add_startup_system(setup) - //.add_system(plan) - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugins(TurtlePlugin) + .add_systems(Startup, setup) + //.add_systems(Update, plan) + .add_plugins(LogDiagnosticsPlugin::default()) + .add_plugins(FrameTimeDiagnosticsPlugin::default()) .run(); } fn setup(mut commands: Commands) { let mut turtle = get_a_turtle(); - turtle.set_speed(500); + turtle.set_speed(1000); stern(&mut turtle); commands.spawn((turtle, Egon {})); diff --git a/turtle-example/examples/tweening_test.rs b/turtle-example/examples/tweening_test.rs index 867454a..114db69 100644 --- a/turtle-example/examples/tweening_test.rs +++ b/turtle-example/examples/tweening_test.rs @@ -1,24 +1,25 @@ use bevy::prelude::*; -use bevy_inspector_egui::prelude::*; -use bevy_tweening::{lens::*, *}; +// Note: bevy_inspector_egui and bevy_tweening are not yet fully compatible with Bevy 0.17 +// This example is disabled until they are updated +// use bevy_inspector_egui::prelude::*; +// use bevy_tweening::{lens::*, *}; fn main() { App::default() .add_plugins(DefaultPlugins.set(WindowPlugin { - window: WindowDescriptor { + primary_window: Some(Window { title: "TransformPositionLens".to_string(), - width: 1400., - height: 600., + resolution: (1400, 600).into(), present_mode: bevy::window::PresentMode::Fifo, // vsync ..default() - }, + }), ..default() })) - .add_system(bevy::window::close_on_esc) - .add_plugin(TweeningPlugin) - .add_startup_system(setup) - .add_system(update_animation_speed) + // .add_systems(Update, bevy::window::close_on_esc) + // .add_plugins(TweeningPlugin) + .add_systems(Startup, setup) + // .add_systems(Update, update_animation_speed) .register_type::() .run(); } @@ -35,8 +36,12 @@ impl Default for Options { } fn setup(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); + // NOTE: This example is disabled because bevy_tweening is not yet compatible with Bevy 0.17 + // Once bevy_tweening is updated, uncomment the code below + + /* let size = 25.; let spacing = 1.5; @@ -98,12 +103,9 @@ fn setup(mut commands: Commands) { ); commands.spawn(( - SpriteBundle { - sprite: Sprite { - color: Color::RED, - custom_size: Some(Vec2::new(size, size)), - ..default() - }, + Sprite { + color: Color::srgb(1.0, 0.0, 0.0), + custom_size: Some(Vec2::new(size, size)), ..default() }, Animator::new(tween), @@ -111,9 +113,12 @@ fn setup(mut commands: Commands) { x += size * spacing; } + */ } -fn update_animation_speed(options: Res, mut animators: Query<&mut Animator>) { +fn update_animation_speed(_options: Res /*, mut animators: Query<&mut Animator>*/) { + // NOTE: This function is disabled because bevy_tweening is not yet compatible with Bevy 0.17 + /* if !options.is_changed() { return; } @@ -121,4 +126,5 @@ fn update_animation_speed(options: Res, mut animators: Query<&mut Anima for mut animator in animators.iter_mut() { animator.set_speed(options.speed); } + */ } diff --git a/turtle-example/src/main.rs b/turtle-example/src/main.rs index 11e8ee7..2feb013 100644 --- a/turtle-example/src/main.rs +++ b/turtle-example/src/main.rs @@ -1,26 +1,25 @@ use bevy::prelude::*; -use bevy_inspector_egui::Inspectable; use turtle_lib::builders::{CurvedMovement, DirectionalMovement, Turnable}; use turtle_lib::{get_a_turtle, TurtlePlugin}; use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}; -#[derive(Component, Inspectable)] +#[derive(Component, Reflect)] struct Egon {} fn main() { App::new() - .add_plugin(TurtlePlugin) - .add_startup_system(setup) + .add_plugins(TurtlePlugin) + .add_systems(Startup, setup) //.add_system(plan) - .add_plugin(LogDiagnosticsPlugin::default()) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) + .add_plugins(LogDiagnosticsPlugin::default()) + .add_plugins(FrameTimeDiagnosticsPlugin::default()) .run(); } fn setup(mut commands: Commands) { let mut turtle = get_a_turtle(); - turtle.set_speed(1000); + turtle.set_speed(0); turtle.circle(50, 90); turtle.circle_right(50, 180); turtle.circle(50, 90);