コード例 #1
0
def main():
    global wnd, ship, boundPen, interval1

    def destroy_wrapper():
        interval1.cancel()
        delwindow(wnd)

    wnd = newwindow(title="Stay Inbounds [$teven edit]", size=(800, 600))
    wnd[2].onkey(destroy_wrapper, "Escape")
    ship = turtle.RawTurtle(wnd[2])
    ship.speed(0)
    ship.penup()
    boundPen = turtle.RawTurtle(wnd[2])
    boundPen.speed(0)
    boundPen.penup()
    boundPen.hideturtle()
    boundPen.color("red")
    drawUniverseBoundaries()
    interval1 = itv3.Interval(intervalContent, .05)
    wnd[2].onkeypress(pressLeftKey, "Left")
    wnd[2].onkeypress(pressRightKey, "Right")
    wnd[2].onkeypress(pressUpKey, "Up")
    wnd[2].onkeyrelease(releaseLeftKey, "Left")
    wnd[2].onkeyrelease(releaseRightKey, "Right")
    wnd[2].onkeyrelease(releaseUpKey, "Up")
    wnd[2].listen()
    interval1.start()
    return 0
コード例 #2
0
ファイル: main.py プロジェクト: chromium7/turtle_race
def setup():
    turtle_screen.bgcolor("#49d444")
    t = turtle.RawTurtle(turtle_screen, visible=False)
    t.penup()
    t.speed(0)
    t.goto(-390, 230)
    t.pendown()
    t.color("navy")
    t.write("LETS GOOOOOOOOO pEpEG", font=("Helvetica", 38, "bold italic"))
    tt = turtle.RawTurtle(turtle_screen, visible=False)
    tt.penup()
    tt.speed(0)
    tt.goto(-500, -257)
    tt.fillcolor("brown")
    tt.begin_fill()
    tt.forward(1000)
    tt.right(90)
    tt.forward(100)
    tt.right(90)
    tt.forward(1000)
    tt.right(90)
    tt.forward(100)
    tt.end_fill()
    ttt = turtle.RawTurtle(turtle_screen, visible=False)
    ttt.penup()
    ttt.speed(0)
    ttt.goto(400, 180)
    ttt.pensize(5)
    ttt.color("brown")
    ttt.pendown()
    ttt.right(90)
    ttt.forward(400)
コード例 #3
0
 def __init__(self):
     self.__root = tk.Tk()
     self.__canvas = turtle.ScrolledCanvas(self.__root,
                                           width=1000,
                                           height=600)
     self.__canvas.pack()
     self.__screen = turtle.TurtleScreen(self.__canvas)
     self.__turtle = turtle.RawTurtle(self.__screen)
     self.__ship = turtle.RawTurtle(self.__screen)
     self.__screen.setworldcoordinates(-500, -500, 500, 500)
     self.build_ship()
コード例 #4
0
def graph(outsideSize, insideSize, penDistance, penNumber):
    x = 2 * outsideSize
    y = 2 * insideSize
    myCanvas.config(width=x, height=x)
    t1 = turtle.RawTurtle(myCanvas)
    t1.hideturtle()
    t1.speed(0)

    pen = turtle.RawTurtle(myCanvas)
    pen.hideturtle()
    pen.speed(0)

    theta = 0.2 * penNumber
    angle = 0
    pen.up()
    pen.goto(outsideSize - insideSize + outsideSize, 0)
    pen.down()

    steps = (6 * np.pi / theta)

    for t in range(0, int(steps)):
        t1.clear()
        t1.penup()
        t1.setheading(0)
        t1.goto(0, -outsideSize)
        t1.color("red")
        t1.pendown()
        t1.circle(outsideSize)
        angle += theta

        a = (outsideSize - insideSize) * np.cos(angle)
        b = (outsideSize - insideSize) * np.sin(angle)
        t1.penup()
        t1.goto(a, b - insideSize)
        t1.color("black")
        t1.pendown()
        t1.circle(insideSize)
        t1.penup()
        t1.goto(a, b)
        t1.dot(5)

        a = (outsideSize - insideSize) * np.cos(angle) + penDistance * np.cos(
            ((outsideSize - insideSize) / insideSize) * angle)
        b = (outsideSize - insideSize) * np.sin(angle) - penDistance * np.sin(
            ((outsideSize - insideSize) / insideSize) * angle)

        t1.goto(a, b)
        t1.pendown()

        t1.dot(5)
        pen.goto(t1.pos())

        t1.getscreen().update()
コード例 #5
0
 def __init__(self, master):
     super().__init__(master=master)
     self.grid_columnconfigure(0, weight=1)
     self.grid_rowconfigure(0, weight=1)
     self.canvas = tk.Canvas(self, height=CANVAS_HEIGHT, width=CANVAS_WIDTH)
     self.canvas.grid(row=0, column=0, sticky="NESW")
     self.t_screen = turtle.TurtleScreen(self.canvas)
     self.t_screen.delay(0)
     self.line_t = turtle.RawTurtle(self.t_screen)
     self.line_t.setpos(100, 100)
     self.scale_t = turtle.RawTurtle(self.t_screen)
     ##        self.scale_t.pu()
     self.draw_all()
コード例 #6
0
 def __init__(self):
     self.size = {'width': 700, 'height': 500}
     self.root = tk.Tk()
     self.root.title('画图')
     self.root.geometry('{0}x{1}+500+100'.format(self.size['width'],
                                                 self.size['height']))
     self.canvas = tk.Canvas(self.root,
                             width=self.size['width'],
                             height=self.size['height'])
     self.canvas.place(relx=0, rely=0, relwidth=1, relheight=1)
     self.turtle = tl.RawTurtle(self.canvas)
     self.turtle.hideturtle()
     self.turtle._tracer(False)
     self.turtle.penup()
     self.pen_color = '#000000'
     self.turtle.pencolor(self.pen_color)
     self.graphics = list()
     self.graphic_list = Stack()
     self.recover_list = StackQ(7)
     self.graphics_count = 0
     self.select = True
     self.draw_func = None
     self.click1_pos = None
     self.click2_pos = None
     self._click2_pos = None
     self.is_saved = False
     self.pan = Pan()
コード例 #7
0
 def __init__(self, ground_level, canvas):
     self.sprite = turtle.RawTurtle(canvas)
     self.sprite.hideturtle()
     self.sprite.penup()
     self.sprite.goto(-400, ground_level)
     self.sprite.pendown()
     self.sprite.fd(800)
コード例 #8
0
def display_help_window():
    from turtle import TK
    root = TK.Tk()
    frame = TK.Frame()
    canvas = TK.Canvas(root, width=300, height=200, bg="white")
    canvas.pack()
    help_screen = turtle.TurtleScreen(canvas)
    help_t = turtle.RawTurtle(help_screen)
    help_t.penup()
    help_t.hideturtle()
    help_t.speed('fastest')

    width, height = help_screen.screensize()
    line_height = 20
    y = height // 2 - 30
    for s in ("Click on cells to make them alive or dead.",
              "Keyboard commands:",
              " E)rase the board",
              " R)andom fill",
              " S)tep once or",
              " C)ontinuously -- use 'S' to resume stepping",
              " Q)uit"):
        help_t.setpos(-(width / 2), y)
        help_t.write(s, font=('sans-serif', 14, 'normal'))
        y -= line_height
コード例 #9
0
    def drawBrush(self, fig_param_stack, res_address):
        """Crea un pincel sobre el canvas actual 

		args:
			fig_param_stack -- list(params) : lista de parámetros de inicialización
			res_address -- int : dirección donde guardar pincel
		"""

        color = self.mem.getValue(fig_param_stack.pop())

        # create a turtle object
        ttl = turtle.RawTurtle(self.canvas)

        try:
            ttl.color(color)
        except:
            try:
                color = g.colorDict[color]
                ttl.color(color)
            except KeyError:
                self.caller.print('Error: color ' + color + ' no me sirve')
                self.caller.running = False
                return

        ttl.speed('fastest')
        ttl.shape('circle')

        self.mem.setValue(ttl, int(res_address))
コード例 #10
0
def drawLewis(canvas, pMolecule, forbiddenAngle, angle, originalX, originalY,
              isFirst):
    turtlePainter = turtle.RawTurtle(canvas)
    turtlePainter.hideturtle()
    turtlePainter.speed(0)
    drawLewisAux(canvas, turtlePainter, pMolecule, forbiddenAngle, angle,
                 originalX, originalY, isFirst)
コード例 #11
0
 def des3(self):
     self.deswin.destroy()
     self.deswin = Tk()
     self.deswin.title("Designs")
     self.deswin.lift()
     self.deswin.attributes("-topmost", True)
     self.deswin.geometry(WINDOW_DIM)
     self.deswin.resizable(False, False)
     self.deswin.config(bg="yellow")
     self.homebtn = Button(self.deswin,
                           text="HOME",
                           bg="black",
                           fg="white",
                           command=self.home_button2)
     self.homebtn.place(x=140, y=370)
     self.canvas = Canvas(master=self.deswin,
                          width=325,
                          height=350,
                          bg="black")
     self.t = turtle.RawTurtle(self.canvas)
     self.canvas.place(x=0, y=0)
     for i in range(50):
         self.t.speed(20)
         self.t.pencolor("red")
         self.t.backward(100)
         self.t.pencolor("green")
         self.t.circle(30)
         self.t.right(70)
コード例 #12
0
 def setup_turtle(master_canvas):
     t = turtle.RawTurtle(master_canvas)
     t._tracer(0)
     t.speed(0)
     t.hideturtle()
     t.penup()
     return t
コード例 #13
0
 def run_logo_emit_svg(self, code, outfile):
     # create a new canvas
     f = tk.Frame(None).pack()
     cv = tk.Canvas(master=f, width=500, height=500)
     cv.pack()
     # create a python turtle on it
     t = turtle.RawTurtle(cv, shape='square', visible=False)
     # run that turtle superfast
     t._tracer(0, None)
     # create our logo-runner turtle with the python turtle
     ps_turtle.createturtle(self.interp, t)
     # tokenize the given code
     input = StringIO(code)
     input.name = '<string>'
     tokenizer = reader.FileTokenizer(reader.TrackingStream(input))
     self.interp.push_tokenizer(tokenizer)
     try:
         while True:
             tok = self.interp.tokenizer.peek()
             if tok is EOF:
                 break
             val = self.interp.expr_top()
     finally:
         self.interp.pop_tokenizer()
     t.screen.update()
     #cv = turtle.getcanvas()
     canvasvg.saveall(outfile, cv)
     print("Closing.")
     cv.destroy()
     print("Destroyed.")
コード例 #14
0
def printChart():
    ###getting dictionary of character and their percentage frequency from percentages.py module
    percents = percentages.getPercentages()
    ###puts turtle module in tkinter using canvas method
    turt = turtle.RawTurtle(canvas)
    ###set position for piechart
    turt.sety(-100)
    numStr = entry.get()
    if (numStr is ''):
        ###if no input provided, set the default to 1
        numStr = 1
    else:
        numStr = int(entry.get())
    print("num string: ", numStr)

    #def recalculatePercentages(numStr) :

    ###drawing the chart! Where the magic happens
    for i in percents:
        ###color generator - ensures different hex number for each slice
        ranColor = "#%06x" % random.randint(0, 0xFFFFFF)

        ###filling color for pie slices
        turt.fillcolor(ranColor)
        turt.begin_fill()

        ###dividing circle for pie slices
        turt.circle(100, percents[i] * 360 / 100)

        position = turt.position()
        turt.goto(0, 0)
        turt.end_fill()
        turt.setposition(position)
コード例 #15
0
    def __init__(self, size):
        """Creates an array with a given capacity.
        """

        # Set up the new array...
        self._size = size
        self._elements = [None] * size
        self._which = Array._which
        self._freed = False

        # Record the fact that a new array has been created...
        Array._which += 1
        Array._all_existing_arrays.append(self)

        if Array.visible:
            # Create a screen if this is the first array to be
            # instantiated...
            if Array._screen == None:
                Array._screen = turtle.Screen()
                Array._screen.setup(width=_SCREEN_WIDTH,
                                    height=_SCREEN_HEIGHT,
                                    startx=0,
                                    starty=0)
                Array._screen.setworldcoordinates(0, 0, 640, 480)
                Array._screen.tracer(0, 0)

            # Create a turtle that will be used to draw the newly
            # created array.  (Each array has its own turtle object.)
            self._my_turtle = turtle.RawTurtle(Array._screen)
            self._my_turtle.speed(0)
            self._my_turtle.hideturtle()
            self._draw()
            time.sleep(Array.speed)
コード例 #16
0
ファイル: face.py プロジェクト: timothyabbott/face
    def __init__(self, master):
        self.master = master
        self.master.title("Your Face!")
        self.canvas = tk.Canvas(master)
        self.canvas.config(width=600, height=600)
        self.canvas.pack(side=tk.LEFT)
        self.screen = turtle.TurtleScreen(self.canvas)
        self.faceColour = (0,'#FFC0CB')
        print(type(self.faceColour[1]))
        self.eyeColour = "blue"
        self.mouthColour = "red"
        self.screen.colormode(255)
        
        # button
        tk.Button(self.master, text="Draw Face", command=self.drawFace).pack()
          # label 
        self.faceColourCombo = ttk.Label(root, text = "Select the Month :", 
            font = ("Times New Roman", 10))
        self.faceColourCombo.pack()
        
        # Combobox creation 
        n = tk.StringVar() 
        self.monthchoosen = ttk.Combobox(root, width = 27, textvariable = n) 
        self.turtle = turtle.RawTurtle(self.screen, shape="turtle")
        self.turtle.color("green")

  
        tk.Button(self.master, text="Choose face colour", command=self.chooseFaceColour).pack()
        tk.Button(self.master, text="Choose eye colour", command=self.chooseEyeColour).pack()
        tk.Button(self.master, text="Choose mouth colour", command=self.chooseMouthColour).pack()  
コード例 #17
0
def colocarObjeto(canvas, x, y):
    tortuga = turtle.RawTurtle(canvas)
    tortuga.shape("turtle")
    tortuga.shapesize(1, 1, 1)
    tortuga.color("white")
    tortuga.setpos(x, y)
    return tortuga
コード例 #18
0
 def __init__(self, canvas, n, length, dotSize):
     self.vc = turtle.RawTurtle(canvas, shape="turtle")
     self.n = n
     self.length = length
     self.dotSize = dotSize
     self.l = [x - (n / 2) + 0.5 for x in range(self.n)]
     self.l2 = [(n / 2) - 0.5 - x for x in range(self.n)]
コード例 #19
0
ファイル: north_gui.py プロジェクト: sebems/star-coordinates
    def animate(self):
        turtle_screen = turtle.TurtleScreen(self.canvas)
        turtle_screen.bgcolor("#2a408c")

        self.canvas.pack()

        for i in range(0, self.num_turtles):
            DEC = star_pos[i][0]
            RA = star_pos[i][1] * 2.5

            pen = turtle.RawTurtle(turtle_screen)
            self.canvas.pack()
            pen.hideturtle()

            pen.speed(int(self.e.get()))
            pen.pensize(2)
            pen.up()

            pen.forward(abs(RA - 2.31) * 16)
            pen.pendown()

            pen.left(90)
            pen.color(random.choice(self.colors))
            pen.circle(((self.radius(RA, 2.31, DEC, 89)) * 2), self.extent)
            self.stars.append(pen)

        for x in range(0, 4):
            for i in range(0, self.num_turtles):
                DEC = star_pos[i][0]
                RA = star_pos[i][1] * 2.5
                self.stars[i].circle(((self.radius(RA, 2.31, DEC, 89)) * 2),
                                     self.extent)
コード例 #20
0
    def __init__(self, size, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry("%sx%s+0+0" % (size[0], size[1]))
        self.Csize = min(size)
        self.size = size

        self.home = [0, 0]
        self.stack = []

        self.angle = 0
        self.length = 0

        self.presets = {
            "A": lambda: None,
            "B": lambda: None,
            "X": lambda: None,
            "Y": lambda: None,
            "F": lambda: self.turtle.forward(self.length),
            "f": self.move,
            "G": lambda: self.turtle.forward(self.length),
            "+": lambda: self.turtle.left(self.angle),
            "-": lambda: self.turtle.right(self.angle),
            "[": self.push,
            "]": self.pop,
            "|": lambda: self.turtle.right(180)
        }
        self.system = RuleSystem(self.presets, "", {})

        self.createFrame()

        self.turtle = turtle.RawTurtle(self.turtleCnv)
        self.clear()
コード例 #21
0
ファイル: turtle_engine.py プロジェクト: devYaoYH/dev_CMR_py
    def __init__(self, size_x=400, size_y=300, scaling=0.5):
        ##########
        # CONFIG #
        ##########
        # COLORS
        self.col_black = (0, 0, 0)
        self.col_grey = (216, 216, 216)
        self.col_red = (196, 32, 32)
        self.col_green = (32, 196, 32)
        self.col_blue = (32, 32, 196)
        self.col_purple = (196, 32, 196)

        # Setup Display Configuration
        self.SIZE_X = size_x
        self.SIZE_Y = size_y
        self.SCALING = scaling

        ############################
        # Turtle-drawing functions #
        ############################
        turtle.setup(self.SIZE_X*self.SCALING+50, self.SIZE_Y*self.SCALING+50)

        self.SCREEN = turtle.Screen()
        self.SCREEN.colormode(255)               # Set to RGB color mode

        self.TPEN = turtle.RawTurtle(self.SCREEN)
        self.TPEN.speed('fastest')               # Speed optimisations for turtle
        self.TPEN.ht()                           # Hide the little turtle that helps us draw

        if (sys.version_info.major > 2):    # Disable animations => Faster drawing of graphics
            self.SCREEN.tracer(0, 0)
        else:
            self.TPEN.tracer(0, 0)
コード例 #22
0
 def des1(self):
     self.deswin.destroy()
     self.deswin = Tk()
     self.deswin.lift()
     self.deswin.attributes('-topmost', True)
     self.deswin.geometry("325x400")
     self.deswin.config(bg="yellow")
     self.homebtn = Button(self.deswin,
                           text="HOME",
                           bg="black",
                           fg="white",
                           command=self.home_button2)
     self.homebtn.place(x=140, y=370)
     self.canvas = Canvas(master=self.deswin,
                          width=325,
                          height=350,
                          bg="black")
     self.t = turtle.RawTurtle(self.canvas)
     self.canvas.place(x=0, y=0)
     colors = ['red', 'purple', 'blue', 'green', 'yellow', 'orange']
     self.t.speed(0)
     for x in range(160):
         self.t.pencolor(colors[x % 6])
         self.t.width(x / 100 + 1)
         self.t.forward(x)
         self.t.left(59)
コード例 #23
0
def turtlestuff:
    import turtle
    screen = turtle.Screen()
    t = turtle.RawTurtle(screen, 'turtle')
    for i in range(36):
        t.forward(10)
        t.right(10)
コード例 #24
0
    def insertCar(self):
        self.car = turtle.RawTurtle(self.canvas)
        self.car.color("red")
        self.car.shape("triangle")

        self.car.up()
        self.car.goto(0, -125)
コード例 #25
0
 def des1(self):
     self.deswin.destroy()
     self.deswin = Tk()
     self.deswin.title("Designs")
     self.deswin.lift()
     self.deswin.attributes("-topmost", True)
     self.deswin.geometry(WINDOW_DIM)
     self.deswin.config(bg="yellow")
     self.deswin.resizable(False, False)
     self.homebtn = Button(self.deswin,
                           text="HOME",
                           bg="black",
                           fg="white",
                           command=self.home_button2)
     self.homebtn.place(x=140, y=370)
     self.canvas = Canvas(master=self.deswin,
                          width=325,
                          height=350,
                          bg="black")
     self.t = turtle.RawTurtle(self.canvas)
     self.canvas.place(x=0, y=0)
     colors = ["red", "purple", "blue", "green", "yellow", "orange"]
     self.t.speed(0)
     for x in range(160):
         self.t.pencolor(colors[x % 6])
         self.t.width(x / 100 + 1)
         self.t.forward(x)
         self.t.left(59)
コード例 #26
0
def main():

    root = tkinter.Tk()

    cv = tkinter.Canvas(root, width=600, height=600)

    cv.pack(side=tkinter.LEFT)

    root.title("Draw!")

    t = turtle.RawTurtle(cv)

    screen = t.getScreen()

    screen.setworldcoordinates(0, 0, 600, 600)

    frame = tkinter.Frame(root)

    frame.pack(side=tkinter.RIGHT, fill=tkinter.BOTH)

    def quitHandler():
        sys.exit(0)

    quitButton = tkinter.Button(frame, text="Quit", command=quitHandler)

    quitButton.pack()

    tkinter.mainloop()
コード例 #27
0
 def des4(self):
     self.deswin.destroy()
     self.deswin = Tk()
     self.deswin.title("Designs")
     self.deswin.lift()
     self.deswin.attributes("-topmost", True)
     self.deswin.geometry(WINDOW_DIM)
     self.deswin.resizable(False, False)
     self.deswin.config(bg="yellow")
     self.homebtn = Button(self.deswin,
                           text="HOME",
                           bg="black",
                           fg="white",
                           command=self.home_button2)
     self.homebtn.place(x=140, y=370)
     self.canvas = Canvas(master=self.deswin,
                          width=325,
                          height=350,
                          bg="black")
     self.t = turtle.RawTurtle(self.canvas)
     self.canvas.place(x=0, y=0)
     self.t.speed(700)
     for i in range(180):
         self.t.forward(80)
         self.t.right(30)
         self.t.forward(20)
         self.t.left(60)
         self.t.forward(50)
         self.t.right(30)
         self.t.penup()
         self.t.setposition(0, 0)
         self.t.pendown()
         self.t.right(2)
コード例 #28
0
ファイル: main.py プロジェクト: 4465/Disk
 def displayStartLine(self, point):
     point = list(point)
     theScreen = t.TurtleScreen(self.canvas2)
     path = t.RawTurtle(theScreen)
     path.clear()
     #隐藏画笔
     path.hideturtle()
     #抬起画笔
     path.penup()
     for i in range(len(point)):
         path.goto(point[i] * 5 - 250, 230)
         path.write(str(point[i]))
     path.goto(point[0] * 5 - 250, 230)
     path.pendown()
     self.canvas2.create_line(-250, -230, 250, -230, fill="red")
     x = 10
     path.pendown()
     for i in range(len(point)):
         # self.canvas.create_line(point[i],x+(i+1)*10,point[i+1],x+(i+2)*10,fill="red")
         path.goto(point[i] * 5 - 250, 230 - 20 * i)
         path.penup()
         path.write(point[i], font=("Arial", 8))
         path.pendown()
     self.textLog.insert(
         END, '\n********' + str(self.var.get()) + '************')
     self.textLog.insert(END, '\n访问的磁道序列为:\n' + str(point))
     sum_gap = sum([(abs(point[i] - point[i - 1]))
                    for i in range(1, len(point))])
     self.textLog.insert(END, '\n移动的磁道数为:' + str(sum_gap))
     self.textLog.insert(
         END, '\n平均移动的磁道数为:' + str(sum_gap / self.Al.TRACK_REQUEST_COUNT))
     self.RectangleShow(point)
コード例 #29
0
 def des2(self):
     self.deswin.destroy()
     self.deswin = Tk()
     self.deswin.lift()
     self.deswin.attributes('-topmost', True)
     self.deswin.geometry("325x400")
     self.deswin.config(bg="yellow")
     self.homebtn = Button(self.deswin,
                           text="HOME",
                           bg="black",
                           fg="white",
                           command=self.home_button2)
     self.homebtn.place(x=140, y=370)
     self.canvas = Canvas(master=self.deswin,
                          width=325,
                          height=350,
                          bg="black")
     self.t = turtle.RawTurtle(self.canvas)
     self.canvas.place(x=0, y=0)
     for i in range(0, 24):
         self.t.speed(-9)
         self.t.right(46)
         self.t.pencolor("blue")
         self.t.circle(30)
         self.t.right(20)
         self.t.pencolor("green")
         self.t.circle(60)
         self.t.circle(70)
         self.t.pencolor("red")
         self.t.circle(55)
         self.t.circle(57)
         self.t.left(10)
         self.t.pencolor("yellow")
         self.t.right(5)
コード例 #30
0
def init_game():
    global target, target_pos, snake
    draw_game()

    screen.listen()

    screen.onkey(right, 'Right')
    screen.onkey(up, 'Up')
    screen.onkey(left, 'Left')
    screen.onkey(down, 'Down')
    screen.onkey(toggle, 'space')

    screen.tracer(0)

    target = turtle.RawTurtle(screen)
    target.speed(0)  # turn off animations
    target.shape("square")
    target.resizemode("user")
    target.turtlesize(0.5, 0.5)  # resize the square (the original is 20x20px)
    target.color("red")
    target.pu()
    target_pos = (
        0, 0
    )  # storing the targets position in a seperate variable to avoid calling .xcor() and .ycor() every "frame"

    snake = []
    add_segment()

    scored(reset=True)
    screen.update()