Пример #1
0
"""
Tejveer Singh
CS 100 2015F Section 009


HW 02, Sept 15, 2015
"""

import turtle

s = turtle.Screen()
t = turtle.Turtle()
t.color('blue')

t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
s.bye()

s = turtle.Screen()
t = turtle.Turtle()
t.color('blue')

t.left(60)
t.forward(100)
t.right(120)
t.forward(100)
t.right(60)
Пример #2
0
import turtle

scn = turtle.Screen()
bob = turtle.Turtle()
joe = turtle.Turtle()
jim = turtle.Turtle()
sue = turtle.Turtle()
tom = turtle.Turtle()
bill = turtle.Turtle()

bill.speed(10)
bob.speed(10)
sue.speed(10)
joe.speed(10)
jim.speed(10)

bill.penup()
bill.goto(-360, 335)
bill.pendown()
bill.color("light sky blue")
bill.begin_fill()
bill.forward(720)
bill.right(90)
bill.forward(670)
bill.right(90)
bill.forward(720)
bill.right(90)
bill.forward(670)
bill.end_fill()

sue.penup()
Пример #3
0
import turtle
win = turtle.Screen()
t = turtle.Turtle()

# add some display options
t.pensize(4)  # increase pensize (takes integer)
t.pencolor("red")  # set pencolor (takes string)
t.shape("turtle")

#commands from here to the last line can be replaced

# draw a N sided polygon
numSides = int(input("How many sides in the polygon?"))

angle = 360 / numSides
sides = range(numSides)
# distance = 300 / numSides # try different values
distance = 80

for i in sides:
    t.forward(distance)
    t.left(angle)

# end commands
win.mainloop()  # Wait for user to close window
Пример #4
0
    x_offset = int(width / cols)
    y_offset = int(height / rows)
    # the coordinates go from -300 to +300 (i.e. half the height or width)
    # initial offset by half of the distance between each dot
    x_pos = int(width / -2 + x_offset / 2)
    y_pos = int(height / -2 + y_offset / 2)
    for _ in range(0, rows):
        for __ in range(0, cols):
            brush.setx(x_pos)
            brush.sety(y_pos)
            brush.dot(30, random.choice(color_list))
            x_pos += x_offset
        # reset the x position to the first column
        x_pos = int(width / -2 + x_offset / 2)
        y_pos += y_offset


# set the color mode to accept RGB values instead of color name strings
turtle.colormode(255)
# set up the screen
screen = turtle.Screen()
screen.title("Hirst-like art")
# possible to modify the canvas size
screen.setup(width=800, height=600)

# paint the image, the number of columns and rows can be any (reasonable) positive INT
paint(cols=6, rows=4)

# make the window wait for a click, rather than closing immediately after completion
screen.exitonclick()
Пример #5
0
import turtle as t
from turtle import Turtle
import time
from random import randint

# set up window
window = t.Screen()
window.title('Turtle Race')
t.bgcolor('#7bc043') # green field
t.speed(0)
t.penup()
t.setpos(-140, 200)
t.color('white')
t.write("TURTLE RACE", font=("Arial", 30, "bold"))
t.penup()

# dirt
t.setpos(-400, -180)
t.color('#4f372d')
t.begin_fill()
t.pendown()
t.forward(800) # draw 800 pixels going forward
t.right(90) # same logic as this ^
t.forward(300)
t.right(90)
t.forward(800)
t.right(90)
t.forward(300)
t.end_fill()

# finish line
Пример #6
0
import turtle
import math
import random
import winsound

hakan = turtle.Screen()
hakan.title("Şehir Savunmaya Hoşgeldiniz")
hakan.bgcolor("black")
hakan.bgpic("space_station_defense_game_background.gif")
hakan.tracer(0)

player_vertices = ((0, 15), (-15, 0), (-18, 5), (-18, -5), (0, 0), (18, -5),
                   (18, 5), (15, 0))
hakan.register_shape("player", player_vertices)

dooku_vertices = ((0, 10), (5, 7), (3, 3), (10, 0), (7, 4), (8, -6), (0, -10),
                  (-5, -5), (-7, -7), (-10, 0), (-5, 4), (-1, 8))
hakan.register_shape("dooku", dooku_vertices)


class silah(turtle.Turtle):
    def __init__(self):
        turtle.Turtle.__init__(self)
        self.penup()


def get_heading_to(a, b):
    x1 = a.xcor()
    y1 = a.ycor()

    x2 = b.xcor()
Пример #7
0
import turtle

window = turtle.Screen()
turtle = turtle.Turtle()


def straight(x, y):
    turtle.reset()
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.right(144)


turtle.onclick(straight)

run = True


def start():
    #	char=list(main)
    #	valid=["c", "C", "e", "E", "l", "L", "i", "I", "f", "F", "h", "H"]
    #	if valid[1] or valid[2] or valid[3] or valid[4] or valid[5] or valid[6] or valid[7] or valid[8] or valid[9] or valid[10] or valid[11] or valid[12]:
    #	main=str(input("Please choose any of the follwing six letters to see them printed out in ASCII art (C, E, L, I, F, H). Or type 'quit' to leave the loop: "))
    string1 = str(len(main))
###### Import tools ######
import turtle


# Window Setup
window = turtle.Screen()
window.title("Drawing a plan ")
turtle.bgcolor("green")
turtle.color("black")


# Turtle
elsa = turtle.Turtle()
turtle.Screen().bgcolor("orange")
elsa.color("black")
elsa.speed(1)
elsa.penup()

class PlanPoint: # Definition of a class
    name = ''
    x = 0
    y = 0
    connections = [] # array

allpoints = {} # dictionary

import csv
with open('Sample Plan.csv') as csvfile:
    readCSV = csv.reader(csvfile, delimiter=',')
    for row in readCSV:
Пример #9
0
    '85. 出塞': '秦时',
    '86. 从军行': '青海',
    '87. 塞下曲': '林暗',
    '88. 塞下曲': '月黑',
    '89. 回乡偶书': '少小',
    '90. 古朗月行': '小时',
    '91. 池上': '小娃',
    '92. 小儿垂钓': '蓬头',
    '93. 寻隐者不遇': '松下',
    '94. 元日': '爆竹',
    '95. 游园不值': '应怜',
    '96. 所见': '牧童',
}

import turtle as tt
win = tt.Screen()
b = int(tt.numinput("背背古诗运气好", "挑战一下吧:(按空格开始)", 10, 5, 20))
w, h = 800, b * 55
win.setup(w, h)
tt.speed(0)
tt.colormode(255)
tt.up()


def draw(n, y):
    tt.goto(-w / 3, y)
    for i in n:
        tt.pencolor(random.randint(0, 255), random.randint(0, 20),
                    random.randint(0, 255))
        if i == "*":
            tt.bk(30)
Пример #10
0
#Name: Joey Fong
#Email: [email protected]
#Date: October 21, 2019
#A program that uses command strings to control turtle drawing

import turtle

tess = turtle.Turtle()
myWin = turtle.Screen()  #The graphics window
commands = input("Please enter a command string: ")

for ch in commands:
    #perform action indicated by the character
    if ch == 'F':  #move forward
        tess.forward(50)
    elif ch == 'L':  #turn left
        tess.left(90)
    elif ch == 'R':  #turn right
        tess.right(90)
    elif ch == '^':  #lift pen
        tess.penup()
    elif ch == 'v':  #lower pen
        tess.pendown()
    elif ch == 'B':  #go backwards
        tess.backward(50)
    elif ch == 'g':  #turn green
        tess.color("green")
    elif ch == 'b':  #turn blue
        tess.color("blue")
    elif ch == 'S':
        tess.stamp()  #put a turtle stamp
Пример #11
0
import turtle
from turtle import Turtle
from typing import Type

paper = turtle.Screen()
leonardo = turtle.Turtle()
leonardo.pensize(10)

window = turtle.Screen()
window.bgcolor("light gray")

colors = ['red', 'orange', 'green', 'blue', 'purple']

for element in range(12):
    leonardo.color(colors[element % len(colors)])
    leonardo.forward(50)
    leonardo.left(30)

size = 10

size = size + 3

dicaprio = turtle.Turtle()
dicaprio.shape("turtle")
dicaprio.forward(size)
dicaprio.left(120)
dicaprio.forward(80)
dicaprio.left(120)
dicaprio.forward(80)
dicaprio.left(120)
Пример #12
0
#     elif i<255:
#         b+=3
#     elif i<255*4//3:
#         g-=3
#     elif i<255*5//3:
#         r+=3
#     else:
#         b-=3
#     fd(50+i)
#     rt(91)
#     pencolor(r,g,b)
# import turtle

# colors = [ "red","purple","blue","green","orange","yellow"]
# my_pen = turtle.Pen()
# turtle.bgcolor("black")
# for x in range(360):
#    my_pen.pencolor(colors[x % 6])
#    my_pen.width(x/100 + 1)
#    my_pen.forward(x)
#    my_pen.left(59)

import turtle
speed(500)
my_wn = turtle.Screen()
turtle.speed(2)
for i in range(30):
    turtle.circle(5 * i)
    turtle.circle(-5 * i)
    turtle.left(i)
turtle.exitonclick()
Пример #13
0
#绘制创意几何图案
import turtle


def drawSpiral(t, angle):
    ''' takes a turtle, t, and an angle in degrees '''
    length = 1
    for i in range(84):
        t.forward(length)
        t.right(angle)
        length = length + 2


wn = turtle.Screen()  # Set up the window and its attributes
wn.bgcolor("lightyellow")

turing = turtle.Turtle()  # create turing
turing.color('red')
turing.speed(0)

## draw the first spiral ##
# position turing

turing.penup()

turing.backward(200)
turing.pendown()

# draw the spiral using a 90 degree turn angle
drawSpiral(turing, 90)
Пример #14
0
import steamCoding
import turtle

window = turtle.Screen()  #click the screen to close it
tur = turtle.Turtle()
#tur.ht()
tur.penup()
tur.goto(-330, 0)
#tur.goto(-650, 0)
tur.pendown()

tur.write('Happy birthday', font=("courier new", 18, "normal"))
tur.up()
tur.goto(-330, -125)
tur.down()
steamCoding.drawJ(tur)
steamCoding.drawA()
steamCoding.drawK()
steamCoding.drawE()
tur.write('the best dad ever!!!!!!!!!', font=("courier new", 18, "normal"))
tur.ht()
Пример #15
0
import turtle as t
import random
import math

# 스크린 객체 생성
screen = t.Screen()
# 스크린 배경색 지정
screen.bgcolor("lightgreen")
screen.tracer(2)

# 울타리 그리기
mypen = t.Turtle()
mypen.penup()
mypen.setposition(-300, 300)
mypen.pendown()
mypen.pensize(3)

for x in range(4):
    mypen.forward(600)
    mypen.right(90)

mypen.hideturtle()

# Create bugs
maxBugs = 20
bugs = []
colors = ['red', 'blue', 'purple', 'white', 'black', 'pink', '#FFFF00']
shapes = ['arrow', 'blank', 'circle', 'classic', 'square', 'triangle']
tcolors = [
    '#95B9D3', '#77ADD3', '#4497D2', '#2A84C5', '#1A5D8E', '#CE8F91',
    '#CB4E53', '#B4252A', '#8B1317', '#780409'
Пример #16
0
    play_freq("b4")


def key_8():

    play_freq("c5")


def key_9():

    play_freq("d5")


t.setup(600, 600)

s = t.Screen()

s.onkey(key_1, "1")

s.onkey(key_2, "2")

s.onkey(key_3, "3")

s.onkey(key_4, "4")

s.onkey(key_5, "5")

s.onkey(key_6, "6")

s.onkey(key_7, "7")
Пример #17
0
import turtle

p = turtle.Pen()
p.speed(0)
size = 20
turtle.Screen().tracer(False)


def cube(p, x, y, color):
    """
    draw a small cube
    :param p: turtle pen
    :param x: x position
    :param y: y postion
    :param color:  fill color
    """
    p.color('grey')
    p.penup()
    p.goto(x, y)
    p.pendown()
    p.fillcolor(color)
    p.begin_fill()
    for i in range(4):
        p.forward(size)
        p.left(90)
    p.end_fill()


metric = [[0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
          [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
Пример #18
0
def exercise_102():
    count = 10
    global wn, tess
    turtle.setup(400, 500)  # Determine the window size
    wn = turtle.Screen()  # Get a reference to the window
    wn.title("Handling keypresses!")  # Change the window title
    wn.bgcolor("lightgreen")  # Set the background color
    tess = turtle.Turtle()  # Create our favorite turtle
    tess.pensize(count)


    # The next four functions are our "event handlers".
    def h1():
        tess.forward(30)


    def h2():
        tess.left(45)


    def h3():
        tess.right(45)


    def h4():
        wn.bye()


    def h5():
        tess.pencolor("red")


    def h6():
        tess.pencolor("green")


    def h7():
        tess.pencolor("blue")

    def h8():
        count = tess.pensize()
        tess.pensize(count + 1)
        wn.title('{0}'.format(tess.pensize()))

    def h9():
        count = tess.pensize()
        tess.pensize(count - 1)

    # These lines "wire up" keypresses to the handlers we’ve defined.
    wn.onkey(h1, "Up")
    wn.onkey(h2, "Left")
    wn.onkey(h3, "Right")
    wn.onkey(h4, "q")
    wn.onkey(h5, "r")
    wn.onkey(h6, "g")
    wn.onkey(h7, "b")
    wn.onkey(h8, "+")
    wn.onkey(h9, "-")
    # Now we need to tell the window to start listening for events,
    # If any of the keys that we’re monitoring is pressed, its
    # handler will be called.
    wn.listen()
    wn.mainloop()
Пример #19
0
def dancing():
    print("Jack: OK, let's dance with a turtle!")
    print('---Tip: You can exit from "dancing" by clicking on the window with turtle.---')
    print('')
    ####################################################################################################################
    # creating a turtle
    ####################################################################################################################
    wn = turtle.Screen()

    rootwindow = wn.getcanvas().winfo_toplevel()
    rootwindow.call('wm', 'attributes', '.', '-topmost', '1')
    rootwindow.call('wm', 'attributes', '.', '-topmost', '0')

    dk = turtle.Turtle()

    wn.bgcolor('lightgreen')
    dk.shape('turtle')
    dk.color('red')
    dk.pensize(3)
    dk.speed(2)

    # run and get ready to jump
    dk.right(270)
    dk.speed(1)
    dk.forward(100)
    dk.speed(1.5)
    dk.right(225)
    dk.left(90)
    dk.right(45)

    # jump
    dk.penup()
    dk.right(45)
    dk.speed(1)
    dk.forward(75)
    dk.pendown()

    # rotating and going back
    dk.speed(2)
    dk.left(450)
    dk.speed(1)
    dk.forward(75)

    # creating a symbol
    dk.penup()
    dk.speed(2)
    dk.right(45)
    dk.speed(1)
    dk.forward(100)
    dk.pendown()
    dk.speed(2)
    dk.left(180)
    dk.speed(1)
    dk.forward(100)
    dk.speed(2)
    dk.right(45)
    dk.speed(1)
    dk.forward(75)

    # going up
    dk.penup()
    dk.speed(2)
    dk.left(90)
    dk.speed(1)
    dk.forward(75)
    dk.speed(2)
    dk.right(405)

    wn.exitonclick()
Пример #20
0
def main():
    import random
    import time
    import turtle
    #
    #Todo:Change instructions on line 41

    #=======================================================================================================================
    #Opens file and reads lines into list
    with open("English_words.txt") as f:
        lines = f.read().splitlines()

    x = [[i] for i in (lines)]
    print(
        "\n\nWelcome to I-CYPHER,this is an early alpha version. \nThanks for using and have fun."
    )
    #=======================================================================================================================
    #INSTRUCTIONS:

    instruction = str(
        raw_input("Would you like to read the instructions?\nType: Yes/No\n"))

    if instruction.lower() == "yes":
        print(
            "\n\n\nThis is a tool for you to practice quick thinking and witty creativity.\nYou will be prompted with a series of words."
            "Get a beat ready or freestyle acapella.\nThe words will continue based on how much time you would like.\n"
            "You should follow the prompts in this screen and when instructed click on the new window that will open."
            "\nThis new window will show you your words. \nHave fun!\n\n")
        time.sleep(8)
    if instruction.lower() == "no":
        print("Okay, follow the prompts. Have fun!")
        time.sleep(2)

    #=======================================================================================================================
    #TIMED RHYME
    #Propmted if you would like to rhyme for a timed amount.
    timed = raw_input("Would you like to rhyme on a timer?\n\n")

    def timed_rhyme(x, timed):
        if timed.lower() == "yes":  #Timed case
            timed = raw_input(
                "How long would you like to go?\nFor example if you want 2 minutes and 30 seconds type:\t2:30\t\n\n"
            )
            minutes, seconds = timed.split(":")
            print('You have ' + str(minutes) + ' minute(s) and ' +
                  str(seconds) + ' second(s) on the clock.')
            time.sleep(1)
            delay = raw_input(
                "How many seconds would you like in between each word?\n\n")

            #=======================================================================================================================
            #Turtle Implementation

            rapper = turtle.Turtle()
            wn = turtle.Screen()
            wn.bgcolor("black")
            rapper.color("white")
            rapper.setpos(0, 0)
            rapper.shape("blank")
            #=======================================================================================================================

            ready = raw_input(
                "Start your beat and open the new window created. The first word will appear when you press enter.\n\n"
            )
            sec = (int(minutes) * 60) + (int(seconds))
            t0 = time.time()

            while ready == '' and sec != 0:
                random_word = random.choice(x)
                # print ('\n\n\n\n\n',random_word[0])
                #Time for the word to appear.
                rapper.write(random_word[0], False, "center",
                             ("Arial", 40, "bold"))
                time.sleep(int(delay))
                print('\n\n\n')
                rapper.write(random_word[0])
                t1 = time.time()
                total_time = int(t1 - t0)
                if total_time == int(sec) or total_time > int(sec):
                    time.sleep(int(delay))
                    wn.bye()
                    print("Good cypher!")
                    return 0
                # elif total_time==10 or total_time<10:
                #     print "10 seconds left"
                rapper.clear()
                # wn.exitonclick()
        elif timed.lower() == "no":
            return 1
        elif timed.lower() != "yes" or timed.lower() != "no":
            return 2

    #======================================================================================================================

    #======================================================================================================================
    #NON TIMED RHYME
    cypher = timed_rhyme(x, timed)
    if cypher == 1:  #No time case
        print("Okay, the words won't stop coming. Have fun!\n\n")

        delay = raw_input(
            "How many seconds would you like in between each word?\n\n")

        #=======================================================================================================================
        #Turtle Implementation

        rapper = turtle.Turtle()
        wn = turtle.Screen()
        wn.bgcolor("black")
        rapper.color("white")
        rapper.setpos(0, 0)
        rapper.shape("blank")

        #=======================================================================================================================

        ready = raw_input(
            "Start your beat. The first word will appear when you press enter."
        )

        while ready == '':
            #Picks a random word

            random_word = random.choice(x)
            # print (random_word[0])
            rapper.write(random_word[0], False, "center",
                         ("Arial", 40, "bold"))
            time.sleep(int(delay))
            rapper.clear()

    #======================================================================================================================
    #Exception Handler
    if cypher == 2:  #If user choses niether yes or no then prompt program to restart.
        print('press shift+F10')
        timed_rhyme(x, timed)
Пример #21
0
import turtle as t

wn = t.Screen()
wn.title("My PingPong Game")
wn.bgcolor("black")
wn.setup(width=800, height=600)
wn.tracer(0)

paddle_a = t.Turtle()
paddle_a.speed(0)
paddle_a.shape("circle")
paddle_a.color("white")
paddle_a.shapesize(stretch_len=1, stretch_wid=5)
paddle_a.penup()
paddle_a.goto(-375, 0)

paddle_b = t.Turtle()
paddle_b.speed(0)
paddle_b.shape("circle")
paddle_b.color("white")
paddle_b.shapesize(stretch_len=1, stretch_wid=5)
paddle_b.penup()
paddle_b.goto(375, 0)

ball = t.Turtle()
ball.speed(0)
ball.shape("square")
ball.color("red")
ball.shapesize(stretch_len=0.7, stretch_wid=0.7)
ball.penup()
ball.goto(0, 0)
Пример #22
0
pen = turtle.Turtle()
pen.pu()
pen.ht()
pen.speed(0)
pen.color('blue')
def Write(text,size,x,y):
        pen.goto(x,y)
        pen.write(text, move=False, align="center", font=("AR BLANCA", size, "bold"))

port = random.randint(10000,65535)           # Reserve a port for your service.
Write(str(" AGARIO  Game Pin: "+str(port)),24,0,0)#gmae port printing 
s.bind((host, port))        # Bind to the port



window = turtle.Screen()   #game screen set up in the begining
window.setup(1280,800)

#USE FOR FULLSCREEN
window.screensize()
window.setup(width = 1.0, height = 1.0)

turtle.bgpic("blue-graph.gif")
turtle.colormode(1)
turtle.tracer(0)
turtle.ht()
running=True 
screen_width = turtle.getcanvas().winfo_width()//2
screen_height = turtle.getcanvas().winfo_height()//2

Пример #23
0
import turtle

# Create screen
from turtle import Turtle

sc = turtle.Screen()
sc.title("Pong game")
sc.bgcolor("white")
sc.setup(width=1000, height=600)

# Left paddle
left_pad = turtle.Turtle()
left_pad.speed(0)
left_pad.shape("square")
left_pad.color("black")
left_pad.shapesize(stretch_wid=6, stretch_len=2)
left_pad.penup()
left_pad.goto(-400, 0)

# Right paddle
right_pad = turtle.Turtle()
right_pad.speed(0)
right_pad.shape("square")
right_pad.color("black")
right_pad.shapesize(stretch_wid=6, stretch_len=2)
right_pad.penup()
right_pad.goto(400, 0)

# Ball of circle shape
hit_ball = turtle.Turtle()
hit_ball.speed(40)
Пример #24
0
    a_turtle.up()
    a_turtle.goto(x, y)
    a_turtle.down()


def draw_circle(a_turtle, x, y, radius):
    goto(a_turtle, x, y - radius)
    a_turtle.circle(radius)


def draw_filled_circle(a_turtle, x, y, radius):
    goto(a_turtle, x, y)
    a_turtle.dot(radius * 2)


world = turtle.Screen()
world.setup(400, 400)
world.setworldcoordinates(0, 400, 400, 0)
world.bgcolor("#FFFFFF")
turt = turtle.Turtle()

turt.color("#5010C0")
draw_circle(turt, 200, 200, 50)
draw_filled_circle(turt, 200, 200, 30)
sleep(1)

world.clear()

turt = turtle.Turtle()

# a = float(input("Enter side length a"))
import time
import turtle
import math
import random
import pyglet


print ("\nRED TURTLE = THIEF\nBLUE TURTLE = POLICE\n\nPOLICE HAS TO CATCH THIEF AS SOON AS POSSIBLE\nBOTH THIEF AND POLICE CAN TAKE BOOST(GREEN CIRCLE) TO INCREASE THEIR SPEED\n\nCONTROLS:\nTHIEF- LEFT ARROW KEY TO TURN 22.5 DEGREE LEFT & RIGHT ARROW KEY TO TURN 22.5 DEGREE RIGHT\nPOLICE- a TO TURN 22.5 DEGREE LEFT & d TO TURN 22.5 DEGREE RIGHT\n")
pres=input("PRESS ENTER TO START")



start = time.time()
w=turtle.Screen()
w.setup(width = 1.0, height = 1.0)
w.title("CATCH THE THIEF")
w.bgcolor('orange')

snd = pyglet.media.load('music1.mp3')
looper = pyglet.media.SourceGroup(snd.audio_format, None)
looper.loop = True
looper.queue(snd)
p = pyglet.media.Player()
p.queue(looper)
p.play()

b=turtle.Turtle()
b.hideturtle()
b.penup()
b.speed(0)
b.color('black')
            drawer.forward(amount - barrier)

        else:
            drawer.forward(barrier)

            #barrier thingy part 2
            drawer.left(90)
            drawer.forward(wall_width * 2)
            drawer.back(wall_width * 2)
            drawer.right(90)

            drawer.forward(door - barrier)

            #door thingy part 2
            drawer.penup()
            drawer.forward(door_width)
            drawer.pendown()

            drawer.forward(amount - door - door_width)

    drawer.left(90)
    amount += wall_width

wn = trtl.Screen()
wn.onkeypress(up, "Up")
wn.onkeypress(left, "Left")
wn.onkeypress(right, "Right")
wn.onkeypress(down, "Down")
wn.listen()
wn.mainloop()
Пример #27
0
import turtle  # 1. import the modules
import random
wn = turtle.Screen()  # 2. Create a screen
wn.bgcolor('lightblue')

lance = turtle.Turtle()  # 3. Create two turtles
andy = turtle.Turtle()
lance.color('red')
andy.color('blue')
lance.shape('turtle')
andy.shape('turtle')
lance.penup()
andy.penup()

andy.up()  # 4. Move the turtles to their starting point
lance.up()
andy.goto(-100, 20)
lance.goto(-100, -20)
lance.pendown()
andy.pendown()
# your code goes here

for distance in range(0, 22, 1):  # generates [0..22]

    andy_distance = random.randrange(0, 22)
    lance_distance = random.randrange(0, 22)
    # move each turtle forward by distance
    andy.forward(andy_distance)
    lance.forward(lance_distance)

print(andy.distance(-100, 20))
import turtle 
screen_show = turtle.Screen()
screen_show.title("Turtle Exercises")
drawing_pen = turtle.Turtle()
drawing_pen.speed(-1)
drawing_pen.color("blue")
length = 6
for i in range(40):
    for j in range(4):
        drawing_pen.forward(length)
        drawing_pen.left(90)
    drawing_pen.left(10)
    length = length + 3    
screen_show.mainloop()
Пример #29
0
""" lets see what I build today .... """
# Goal : Building a city scape generator ->

# imports line
import turtle
import random
loadWindow = turtle.Screen()
turtle.colormode(255)
turtle.speed(0)
"""

turtle.forward(1000)
turtle.backward(1000)
turtle.left(90)
turtle.forward(1000)
turtle.exitonclick()
"""
def home():
    turtle.home()
    
def speed(x):
    turtle.speed(x)
    
def right(x):
    turtle.right(x)

def left(x):
    turtle.left(x)

def forward(x):
    turtle.forward(x)
Пример #30
0
def easy_input(prompt = "Enter Input Here: ", title = "Input"):
	screen = turtle.Screen()
	screen.setup(0,0)
	user_input = screen.textinput(title,prompt)
	turtle.bye()
	return user_input