100-Days-Of-Code/PycharmProjects/Snake Game/food.py
Arcron ArchLinux 8e5462f8db 100Days
2024-10-26 14:55:49 +05:30

20 lines
452 B
Python

from turtle import Turtle
import random
class Food(Turtle):
def __init__(self):
super().__init__()
self.shape("circle")
self.penup()
self.shapesize(stretch_len=1.0, stretch_wid=1.0)
self.color("red")
self.speed("fastest")
self.refresh()
def refresh(self):
random_x = random.randint(-280, 280)
random_y = random.randint(-280, 280)
self.goto(random_x, random_y)