adding extend_plan and set_speed
This commit is contained in:
parent
f5aae7efe1
commit
7bdc83c760
@ -10,7 +10,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
TurtleGraphElement,
|
TurtleGraphElement,
|
||||||
},
|
},
|
||||||
general::{angle::Angle, length::Length, Coordinate, Precision},
|
general::{angle::Angle, length::Length, Coordinate, Precision, Speed},
|
||||||
state::TurtleState,
|
state::TurtleState,
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -146,6 +146,12 @@ impl TurtleCommands {
|
|||||||
pub fn push(&mut self, segment: TurtleSegment) {
|
pub fn push(&mut self, segment: TurtleSegment) {
|
||||||
self.commands.push(segment)
|
self.commands.push(segment)
|
||||||
}
|
}
|
||||||
|
pub fn extend(&mut self, segments: Vec<TurtleSegment>) {
|
||||||
|
self.commands.extend(segments.into_iter())
|
||||||
|
}
|
||||||
|
pub fn set_speed(&mut self, speed: Speed) {
|
||||||
|
self.state.set_speed(speed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for TurtleCommands {
|
impl Iterator for TurtleCommands {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ pub mod events;
|
|||||||
mod general;
|
mod general;
|
||||||
pub mod shapes;
|
pub mod shapes;
|
||||||
mod state;
|
mod state;
|
||||||
mod turtle_bundle;
|
pub mod turtle_bundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The turtle plugin is the core of this turtle module.
|
The turtle plugin is the core of this turtle module.
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use bevy_prototype_lyon::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
builders::{TurtlePlan, WithCommands},
|
builders::{TurtlePlan, WithCommands},
|
||||||
commands::{DrawElement, MoveCommand, TurtleCommands, TurtleSegment},
|
commands::{DrawElement, MoveCommand, TurtleCommands, TurtleSegment},
|
||||||
general::length::Length,
|
general::{length::Length, Speed},
|
||||||
shapes::{self, TurtleColors},
|
shapes::{self, TurtleColors},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,6 +43,9 @@ impl TurtleBundle {
|
|||||||
pub fn apply_plan(&mut self, plan: TurtlePlan) {
|
pub fn apply_plan(&mut self, plan: TurtlePlan) {
|
||||||
self.commands = TurtleCommands::new(plan.get_commands());
|
self.commands = TurtleCommands::new(plan.get_commands());
|
||||||
}
|
}
|
||||||
|
pub fn extend_plan(&mut self, plan: TurtlePlan) {
|
||||||
|
self.commands.extend(plan.get_commands())
|
||||||
|
}
|
||||||
pub fn create_plan(&self) -> TurtlePlan {
|
pub fn create_plan(&self) -> TurtlePlan {
|
||||||
TurtlePlan::new()
|
TurtlePlan::new()
|
||||||
}
|
}
|
||||||
@ -55,6 +58,9 @@ impl TurtleBundle {
|
|||||||
)));
|
)));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
pub fn set_speed(&mut self, speed: Speed) {
|
||||||
|
self.commands.set_speed(speed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user