made the blue piece move

I was struggling to figure out how to put the animation code into my code.
i had to change up the code for my piece so they were made separate and then move them.
it was hard to figure out have to calculate which way the piece would go but i got
one to move
This commit is contained in:
tsmith37
2025-10-04 23:58:55 -04:00
parent 7ba89f2965
commit 27fb68ccb2
5 changed files with 143 additions and 58 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,11 +1,27 @@
from superturtle.animation import animate from superturtle.animation import animate
from turtle import forward, right from turtle import forward, right
from shapes import red_coin
from turtle import *
from shapes import *
def square(side_length):
for side in range(4):
forward(side_length)
right(90)
for frame in animate(40, loop=True):
size = frame.interpolate(50, 100, mirror=True) for frame in animate(30):
square(size)
penup()
forward(100)
pendown()
black_tile(40)
with frame.translate([-275, -150], [-225, -100]):
red_coin(20)
goto(-175, -150)
blue_coin(25)
input()
# for frame in animate(frames=30):
# with frame.translate([0, 0], [100, 100]):
# red_coin(25)
input()

View File

@@ -4,12 +4,14 @@
# #
# (Briefly describe what this program does.) # (Briefly describe what this program does.)
from superturtle.animation import animate
from turtle import * from turtle import *
from shapes import board from shapes import board
from shapes import blue_coin from shapes import blue_coin
from shapes import red_coin from shapes import red_coin
from shapes import black_tile from shapes import black_tile
from shapes import game
from shapes import *
def flyto(x, y): def flyto(x, y):
penup() penup()
@@ -41,65 +43,79 @@ def red_row(times):
penup() penup()
forward(size * 2) forward(size * 2)
def game(times):
penup()
goto(-300, 200)
pendown()
board(400)
penup() "first row"
goto(-300, 200) black_row(1)
pendown() flyto(-300, 150)
board(400) forward(50)
"first row" "second row - white tile first"
black_row(1) black_row(1)
flyto(-300, 150) flyto(-300, 100)
forward(50)
"second row - white tile first" "third row - black tile first"
black_row(1) black_row(1)
flyto(-300, 100) flyto(-300, 50)
forward(50)
"third row - black tile first" "fourth row - white tile first"
black_row(1) black_row(1)
flyto(-300, 50) flyto(-300, 0)
forward(50)
"fourth row - white tile first" "five row - black tile first"
black_row(1) black_row(1)
flyto(-300, 0) flyto(-300, -50)
forward(50)
"five row - black tile first" "six row - white tile first"
black_row(1) black_row(1)
flyto(-300, -50) flyto(-300, -100)
forward(50)
"six row - white tile first" "seven row - black tile first"
black_row(1) black_row(1)
flyto(-300, -100) flyto(-300, -150)
forward(50)
"seven row - black tile first" "eight row - white tile first"
black_row(1) sizes = [50,50,50,50]
flyto(-300, -150) black_row(1)
forward(50) flyto(-300, -200)
"eight row - white tile first"
sizes = [50,50,50,50]
black_row(1)
flyto(-300, -200)
"blue checkers piece" for frame in animate(40):
forward(75)
blue_row(1)
flyto(-300, -150)
forward(25)
blue_row(1)
flyto(-300, 100)
"red checkers piece" game(1)
forward(75)
red_row(1)
flyto(-300, 150)
forward(25)
red_row(1)
flyto(-300, 200)
forward(75)
blue_row(1)
flyto(-275, -150)
blue_coin(25)
flyto(-175, -150)
blue_coin(25)
flyto(-75, -150)
blue_coin(25)
flyto(25, -150)
with frame.translate([0, 0], [50, 50]):
blue_coin(25)
flyto(-275, 150)
red_row(1)
flyto(-300, 100)
forward(75)
red_coin(25)
flyto(-125, 100)
red_coin(25)
flyto(-25, 100)
red_coin(25)
flyto(75, 100)
red_coin(25)
flyto(-300, 200)
input() input()

View File

@@ -30,3 +30,56 @@ def black_tile(size):
right(90) right(90)
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 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)