generated from mwc/project_drawing
I have finished my project and it was a little challenging but the pride i have for completing it has been priceless. I would like to learn more on how to animate thing in more detail tho.
140 lines
2.7 KiB
Python
140 lines
2.7 KiB
Python
# drawing.py
|
|
# ----------
|
|
# By ____(you)___________
|
|
#
|
|
# (Briefly describe what this program does.)
|
|
|
|
from superturtle.animation import animate
|
|
from turtle import *
|
|
from shapes import board
|
|
from shapes import blue_coin
|
|
from shapes import red_coin
|
|
from shapes import black_tile
|
|
from shapes import game
|
|
from shapes import *
|
|
|
|
def flyto(x, y):
|
|
penup()
|
|
goto(x, y)
|
|
pendown()
|
|
|
|
def black_row(times):
|
|
sizes = [50,50,50,50]
|
|
for size in sizes:
|
|
begin_fill()
|
|
fillcolor('black')
|
|
black_tile(size)
|
|
end_fill()
|
|
penup()
|
|
forward(size * 2)
|
|
pendown()
|
|
|
|
def blue_row(times):
|
|
sizes = [50,50,50,50]
|
|
for size in sizes:
|
|
blue_coin(25)
|
|
penup()
|
|
forward(size * 2)
|
|
|
|
def red_row(times):
|
|
sizes = [50,50,50,50]
|
|
for size in sizes:
|
|
red_coin(25)
|
|
penup()
|
|
forward(size * 2)
|
|
|
|
def game(times):
|
|
penup()
|
|
goto(-300, 200)
|
|
pendown()
|
|
board(400)
|
|
|
|
"first row"
|
|
black_row(1)
|
|
flyto(-300, 150)
|
|
forward(50)
|
|
|
|
"second row - white tile first"
|
|
black_row(1)
|
|
flyto(-300, 100)
|
|
|
|
"third row - black tile first"
|
|
black_row(1)
|
|
flyto(-300, 50)
|
|
forward(50)
|
|
|
|
"fourth row - white tile first"
|
|
black_row(1)
|
|
flyto(-300, 0)
|
|
|
|
"five row - black tile first"
|
|
black_row(1)
|
|
flyto(-300, -50)
|
|
forward(50)
|
|
|
|
"six row - white tile first"
|
|
black_row(1)
|
|
flyto(-300, -100)
|
|
|
|
"seven row - black tile first"
|
|
black_row(1)
|
|
flyto(-300, -150)
|
|
forward(50)
|
|
|
|
"eight row - white tile first"
|
|
sizes = [50,50,50,50]
|
|
black_row(1)
|
|
flyto(-300, -200)
|
|
|
|
|
|
for frame in animate(40):
|
|
|
|
game(1)
|
|
"blue coin rows"
|
|
forward(75)
|
|
blue_row(1)
|
|
flyto(-275, -150)
|
|
with frame.translate([0, 0], [50, 50], 1, 5):
|
|
|
|
blue_coin(25)
|
|
flyto(-175, -150)
|
|
with frame.translate([0, 0], [50, 50], 10, 15):
|
|
|
|
blue_coin(25)
|
|
flyto(-75, -150)
|
|
with frame.translate([0, 0], [50, 50], 20, 25):
|
|
|
|
blue_coin(25)
|
|
flyto(25, -150)
|
|
with frame.translate([0, 0], [50, 50], 30, 35):
|
|
|
|
blue_coin(25)
|
|
|
|
"red coin rows"
|
|
flyto(-275, 150)
|
|
red_row(1)
|
|
flyto(-225, 100)
|
|
with frame.translate([0, 0], [-50, -50], 5, 10):
|
|
|
|
red_coin(25)
|
|
flyto(-125, 100)
|
|
|
|
with frame.translate([0, 0], [-50, -50], 15, 20):
|
|
|
|
red_coin(25)
|
|
flyto(-25, 100)
|
|
|
|
with frame.translate([0, 0], [-50, -50], 25, 30):
|
|
|
|
red_coin(25)
|
|
flyto(75, 100)
|
|
with frame.translate([0, 0], [-50, -50], 35, 40):
|
|
|
|
red_coin(25)
|
|
flyto(-300, 200)
|
|
input()
|
|
|
|
|
|
|
|
|