moving files
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user