moving files
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
|
||||
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
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,2 @@
|
||||
# turtle
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
use bevy::prelude::*;
|
||||
use turtle_lib::builders::{DirectionalMovement, StopLine, Turnable};
|
||||
use turtle_lib::{get_a_turtle, TurtlePlugin};
|
||||
|
||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||
|
||||
#[derive(Component, Reflect)]
|
||||
struct Egon {}
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugin(TurtlePlugin)
|
||||
.add_startup_system(setup)
|
||||
//.add_system(plan)
|
||||
.add_plugin(LogDiagnosticsPlugin::default())
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands) {
|
||||
let mut turtle = get_a_turtle();
|
||||
turtle.set_speed(1);
|
||||
|
||||
let mt = turtle.pen_up();
|
||||
|
||||
//commands.spawn((turtle, Egon {}));
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
use bevy::prelude::*;
|
||||
use turtle_lib::builders::{DirectionalMovement, Turnable};
|
||||
use turtle_lib::turtle_bundle::AnimatedTurtle;
|
||||
use turtle_lib::{get_a_turtle, TurtlePlugin};
|
||||
|
||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||
|
||||
#[derive(Component, Reflect)]
|
||||
struct Egon {}
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugin(TurtlePlugin)
|
||||
.add_startup_system(setup)
|
||||
//.add_system(plan)
|
||||
.add_plugin(LogDiagnosticsPlugin::default())
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands) {
|
||||
let mut turtle = get_a_turtle();
|
||||
turtle.set_speed(1);
|
||||
for _x in 0..3 {
|
||||
koch(3, &mut turtle);
|
||||
turtle.right(120);
|
||||
}
|
||||
commands.spawn((turtle, Egon {}));
|
||||
}
|
||||
|
||||
fn koch(depth: u32, turtle: &mut AnimatedTurtle) {
|
||||
if depth == 0 {
|
||||
turtle.forward(10);
|
||||
} else {
|
||||
koch(depth - 1, turtle);
|
||||
turtle.left(60);
|
||||
koch(depth - 1, turtle);
|
||||
turtle.right(120);
|
||||
koch(depth - 1, turtle);
|
||||
turtle.left(60);
|
||||
koch(depth - 1, turtle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
use bevy::prelude::*;
|
||||
use turtle_lib::builders::{DirectionalMovement, Turnable};
|
||||
use turtle_lib::turtle_bundle::AnimatedTurtle;
|
||||
use turtle_lib::{get_a_turtle, TurtlePlugin};
|
||||
|
||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||
|
||||
#[derive(Component, Reflect)]
|
||||
struct Egon {}
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugin(TurtlePlugin)
|
||||
.add_startup_system(setup)
|
||||
//.add_system(plan)
|
||||
.add_plugin(LogDiagnosticsPlugin::default())
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands) {
|
||||
let mut turtle = get_a_turtle();
|
||||
turtle.set_speed(500);
|
||||
stern(&mut turtle);
|
||||
commands.spawn((turtle, Egon {}));
|
||||
}
|
||||
|
||||
fn stern(turtle: &mut AnimatedTurtle) {
|
||||
// Draw the roof of the house
|
||||
turtle.left(45);
|
||||
turtle.forward(70);
|
||||
turtle.right(90);
|
||||
turtle.forward(70);
|
||||
turtle.left(45);
|
||||
|
||||
// Draw the sides of the house
|
||||
turtle.left(90);
|
||||
turtle.forward(100);
|
||||
turtle.left(90);
|
||||
turtle.forward(50);
|
||||
turtle.left(90);
|
||||
turtle.forward(100);
|
||||
turtle.left(90);
|
||||
turtle.forward(50);
|
||||
|
||||
// Draw the door of the house
|
||||
turtle.left(90);
|
||||
turtle.forward(25);
|
||||
turtle.right(90);
|
||||
turtle.forward(20);
|
||||
turtle.right(90);
|
||||
turtle.forward(25);
|
||||
turtle.left(90);
|
||||
turtle.forward(50);
|
||||
|
||||
// Draw the chimney of the house
|
||||
turtle.left(90);
|
||||
turtle.forward(25);
|
||||
turtle.right(90);
|
||||
turtle.forward(10);
|
||||
turtle.right(90);
|
||||
turtle.forward(25);
|
||||
turtle.left(90);
|
||||
turtle.forward(10);
|
||||
turtle.left(90);
|
||||
turtle.forward(10);
|
||||
turtle.right(90);
|
||||
turtle.forward(25);
|
||||
turtle.left(90);
|
||||
turtle.forward(10);
|
||||
turtle.left(90);
|
||||
turtle.forward(10);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
use bevy::prelude::*;
|
||||
use turtle_lib::builders::{CurvedMovement, DirectionalMovement};
|
||||
use turtle_lib::turtle_bundle::AnimatedTurtle;
|
||||
use turtle_lib::{get_a_turtle, TurtlePlugin};
|
||||
|
||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||
|
||||
#[derive(Component, Reflect)]
|
||||
struct Egon {}
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugin(TurtlePlugin)
|
||||
.add_startup_system(setup)
|
||||
//.add_system(plan)
|
||||
.add_plugin(LogDiagnosticsPlugin::default())
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands) {
|
||||
let mut turtle = get_a_turtle();
|
||||
turtle.set_speed(500);
|
||||
stern(&mut turtle);
|
||||
|
||||
commands.spawn((turtle, Egon {}));
|
||||
}
|
||||
|
||||
fn stern(turtle: &mut AnimatedTurtle) {
|
||||
for _ in 0..5 {
|
||||
turtle.forward(200);
|
||||
turtle.circle(10, 72);
|
||||
turtle.circle_right(5, 360);
|
||||
turtle.circle(10, 72);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use bevy_inspector_egui::prelude::*;
|
||||
use bevy_tweening::{lens::*, *};
|
||||
|
||||
fn main() {
|
||||
App::default()
|
||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
window: WindowDescriptor {
|
||||
title: "TransformPositionLens".to_string(),
|
||||
width: 1400.,
|
||||
height: 600.,
|
||||
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)
|
||||
.register_type::<Options>()
|
||||
.run();
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Reflect, Resource)]
|
||||
struct Options {
|
||||
speed: f32,
|
||||
}
|
||||
|
||||
impl Default for Options {
|
||||
fn default() -> Self {
|
||||
Self { speed: 1. }
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands) {
|
||||
commands.spawn(Camera2dBundle::default());
|
||||
|
||||
let size = 25.;
|
||||
|
||||
let spacing = 1.5;
|
||||
let screen_x = 570.;
|
||||
let screen_y = 150.;
|
||||
let mut x = -screen_x;
|
||||
|
||||
for ease_function in &[
|
||||
EaseFunction::QuadraticIn,
|
||||
EaseFunction::QuadraticOut,
|
||||
EaseFunction::QuadraticInOut,
|
||||
EaseFunction::CubicIn,
|
||||
EaseFunction::CubicOut,
|
||||
EaseFunction::CubicInOut,
|
||||
EaseFunction::QuarticIn,
|
||||
EaseFunction::QuarticOut,
|
||||
EaseFunction::QuarticInOut,
|
||||
EaseFunction::QuinticIn,
|
||||
EaseFunction::QuinticOut,
|
||||
EaseFunction::QuinticInOut,
|
||||
EaseFunction::SineIn,
|
||||
EaseFunction::SineOut,
|
||||
EaseFunction::SineInOut,
|
||||
EaseFunction::CircularIn,
|
||||
EaseFunction::CircularOut,
|
||||
EaseFunction::CircularInOut,
|
||||
EaseFunction::ExponentialIn,
|
||||
EaseFunction::ExponentialOut,
|
||||
EaseFunction::ExponentialInOut,
|
||||
EaseFunction::ElasticIn,
|
||||
EaseFunction::ElasticOut,
|
||||
EaseFunction::ElasticInOut,
|
||||
EaseFunction::BackIn,
|
||||
EaseFunction::BackOut,
|
||||
EaseFunction::BackInOut,
|
||||
EaseFunction::BounceIn,
|
||||
EaseFunction::BounceOut,
|
||||
EaseFunction::BounceInOut,
|
||||
] {
|
||||
let tween = Tween::new(
|
||||
*ease_function,
|
||||
std::time::Duration::from_secs(1),
|
||||
TransformPositionLens {
|
||||
start: Vec3::new(x, screen_y, 0.),
|
||||
end: Vec3::new(x, -screen_y, 0.),
|
||||
},
|
||||
)
|
||||
.then(
|
||||
Tween::new(
|
||||
EaseFunction::QuadraticInOut,
|
||||
std::time::Duration::from_millis(200),
|
||||
TransformRotateZLens {
|
||||
start: 0.05,
|
||||
end: -0.05,
|
||||
},
|
||||
)
|
||||
.with_repeat_strategy(bevy_tweening::RepeatStrategy::MirroredRepeat)
|
||||
.with_repeat_count(RepeatCount::Infinite),
|
||||
);
|
||||
|
||||
commands.spawn((
|
||||
SpriteBundle {
|
||||
sprite: Sprite {
|
||||
color: Color::RED,
|
||||
custom_size: Some(Vec2::new(size, size)),
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
},
|
||||
Animator::new(tween),
|
||||
));
|
||||
|
||||
x += size * spacing;
|
||||
}
|
||||
}
|
||||
|
||||
fn update_animation_speed(options: Res<Options>, mut animators: Query<&mut Animator<Transform>>) {
|
||||
if !options.is_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
for mut animator in animators.iter_mut() {
|
||||
animator.set_speed(options.speed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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)]
|
||||
struct Egon {}
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugin(TurtlePlugin)
|
||||
.add_startup_system(setup)
|
||||
//.add_system(plan)
|
||||
.add_plugin(LogDiagnosticsPlugin::default())
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands) {
|
||||
let mut turtle = get_a_turtle();
|
||||
turtle.set_speed(1000);
|
||||
turtle.circle(50, 90);
|
||||
turtle.circle_right(50, 180);
|
||||
turtle.circle(50, 90);
|
||||
for x in 0..1999 {
|
||||
turtle.forward(x);
|
||||
turtle.right(45);
|
||||
turtle.forward(30);
|
||||
turtle.left(90 + x);
|
||||
turtle.forward(30);
|
||||
turtle.right(45);
|
||||
turtle.forward(x);
|
||||
turtle.left(91);
|
||||
}
|
||||
commands.spawn((turtle, Egon {}));
|
||||
}
|
||||
Reference in New Issue
Block a user