Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Walk Program #14

Merged
merged 3 commits into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions projects/Turtle Pattern/randomPattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from turtle import * #importing libraries
import turtle as t
import random
import time

tim = t.Turtle()

t.colormode(255)
def random_colour(): #random colour generator
r=random.randint(0,255)
g=random.randint(0,255)
b=random.randint(0,255)

return r,g,b #red,blue,green

def turtle_movement():
tim.pensize(10) #sets the size
rgb = random_colour()
direction = random.randint(1, 4)
tim.pencolor(rgb[0],rgb[1],rgb[2])
#defining the movement
if direction == 1:
tim.left(90)
tim.forward(30)
time.sleep(.5)
elif direction == 2:
tim.right(90)
tim.forward(30)
time.sleep(.5)
elif direction == 3:
tim.forward(30)
time.sleep(.5)
elif direction == 4:
tim.backward(30)
time.sleep(.5)

colours=["GreenYellow","Chartreuse","Tan","LightSkyBlue","DeepPink","MediumSlateBlue"]

t.pensize(10)
for _ in range(0,200):
turtle_movement()

screen=Screen()
screen.exitonclick()