Advertisement
JkSoftware

food.py

Dec 5th, 2021
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. from turtle import Turtle
  2. import random
  3.  
  4.  
  5. class Food(Turtle):
  6.  
  7.     def __init__(self):
  8.         super().__init__()
  9.         self.shape("circle")
  10.         self.penup()
  11.         self.shapesize(stretch_wid=0.5, stretch_len=0.5)
  12.         self.color("blue")
  13.         self.speed(0)
  14.         self.refresh()
  15.  
  16.     def refresh(self):
  17.         random_x = random.randint(-275, 275)
  18.         random_y = random.randint(-275, 275)
  19.         self.goto(random_x, random_y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement