mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[python/turtle] Turtle::reset() method
This commit is contained in:
@@ -7,6 +7,7 @@ extern "C" {
|
||||
#include "turtle_icon.h"
|
||||
|
||||
static constexpr KDSize k_iconSize = KDSize(9, 9);
|
||||
constexpr KDColor Turtle::k_defaultColor;
|
||||
|
||||
template <typename T> static inline T * allocate(size_t count) {
|
||||
/* We forward dynamic allocations to the Python GC so we don't have to bother
|
||||
@@ -16,6 +17,25 @@ template <typename T> static inline T * allocate(size_t count) {
|
||||
return static_cast<T*>(m_malloc(sizeof(T) * count));
|
||||
}
|
||||
|
||||
void Turtle::reset() {
|
||||
// Erase the drawing
|
||||
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->resetSandbox();
|
||||
|
||||
// Reset turtle values
|
||||
m_x = 0;
|
||||
m_y = 0;
|
||||
m_heading = k_headingOffset;
|
||||
m_color = k_defaultColor;
|
||||
m_penDown = true;
|
||||
m_visible = true;
|
||||
m_speed = k_defaultSpeed;
|
||||
m_penSize = k_defaultPenSize;
|
||||
m_mileage = 0;
|
||||
|
||||
// Draw the turtle
|
||||
draw();
|
||||
}
|
||||
|
||||
void Turtle::forward(mp_float_t length) {
|
||||
goTo(
|
||||
m_x + length * sin(m_heading),
|
||||
|
||||
Reference in New Issue
Block a user