mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[python/turtle] Speed max and min should produce the same behavior
This commit is contained in:
@@ -39,7 +39,7 @@ void Turtle::goTo(mp_float_t x, mp_float_t y) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
mp_float_t progress = i / length;
|
||||
|
||||
if (m_speed > 0) {
|
||||
if (m_speed > 0 && m_speed < k_maxSpeed) {
|
||||
Ion::Display::waitForVBlank();
|
||||
}
|
||||
erase();
|
||||
@@ -199,14 +199,10 @@ bool Turtle::draw() {
|
||||
}
|
||||
|
||||
if (m_mileage > 1000) {
|
||||
if (m_speed > 0) {
|
||||
if (micropython_port_interruptible_msleep(k_maxSpeed * (k_maxSpeed - m_speed))) {
|
||||
return true;
|
||||
}
|
||||
m_mileage -= 1000;
|
||||
} else {
|
||||
m_mileage = 0;
|
||||
if (micropython_port_interruptible_msleep(1 + (m_speed == 0 ? 0 : k_maxSpeed * (k_maxSpeed - m_speed)))) {
|
||||
return true;
|
||||
}
|
||||
m_mileage -= 1000;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -223,9 +219,7 @@ bool Turtle::dot(mp_float_t x, mp_float_t y) {
|
||||
ctx->blendRectWithMask(rect, m_color, m_dotMask, m_dotWorkingPixelBuffer);
|
||||
}
|
||||
|
||||
if (m_speed > 0) {
|
||||
m_mileage += sqrt((x - m_x) * (x - m_x) + (y - m_y) * (y - m_y)) * 1000;
|
||||
}
|
||||
m_mileage += sqrt((x - m_x) * (x - m_x) + (y - m_y) * (y - m_y)) * 1000;
|
||||
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
bool m_penDown;
|
||||
bool m_visible;
|
||||
|
||||
uint8_t m_speed; // Speed is between 1 and 10
|
||||
uint8_t m_speed; // Speed is between 0 and 10
|
||||
KDCoordinate m_penSize;
|
||||
KDCoordinate m_mileage;
|
||||
bool m_drawn;
|
||||
|
||||
Reference in New Issue
Block a user