Text Size
Text Size
Exit Full Screen
Python Mini
Show
Source Code
View Source Code in Full Screen
Open in New Tab
from turtle import Turtle t = Turtle() border = "#0D5656" inner_border = "#3AFEFF" inner = "#28B9BB" ban = "#187F80" handle1 = "#7D3400" handle2 = "#9E5614" handle3 = "#3E2109" size = 15 length = 8 init_x = 100 init_y = 150 t.width(1) t.speed(-1) t.setposition(init_x, init_y) def move(step_x, step_y): x, y = t.position() x += step_x * size y += step_y * size t.setposition(x, y) def square(color): t.color(color) t.begin_fill() for i in range(4): t.forward(size) t.right(90) t.end_fill() def sword_line(): for c in [border, inner_border, inner, inner_border, border]: move(1, 0) square(c) for i in range(3): move(1, 0) square(border) move(-3, -1) square(border) move(1, 0) square(inner_border) move(1, 0) square(inner) move(1, 0) square(border) move(-5, -1) for i in range(length): sword_line() move(-6, -1) move(4, 0) square(inner_border) move(1, 0) square(border) move(-5, 3) for c in [border, border, border, inner, border, border, border]: square(c) move(1, -1) move(-8, 7) for c in [border, ban, ban, border, border, ban, ban, border]: square(c) move(1, -1) move(-2, 1) for c in [border, border, ban, ban, ban, border, border]: square(c) move(-1, 1) move(2, -3) for c in [border]*4: square(c) move(1, -1) move(-4, 2) square(handle1) move(1, 0) square(handle2) move(0, -1) square(handle3) move(-1, 0) square(handle2) move(-1, 0) square(handle1) move(-2, -1) for c in (border, border, handle2, handle3): square(c) move(1, 0) move(-2, -1) for c in [border, inner, border]: square(c) move(-1, 0) move(1, -1) for c in [border]*3: square(c) move(1, 0)
mc_sword.py
( around 89 lines python code )
Published By:
Bo Tinker
Published on
2015-06-27T17:22:56Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here