Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created November 17, 2023 23:25
Show Gist options
  • Save stephengruppetta/f79b58865ed08f2d55e989ec15154796 to your computer and use it in GitHub Desktop.
Save stephengruppetta/f79b58865ed08f2d55e989ec15154796 to your computer and use it in GitHub Desktop.
# dot.py
import turtle
import random
class Dot(turtle.Turtle):
DOT_COLOURS = "#fdb33b", "#6d227a", "#fff3e6"
def __init__(self, x, y, size_range, speed_range):
super().__init__()
self.shape("circle")
self.color(random.choice(self.DOT_COLOURS))
self.penup()
self.setposition(x, y)
self.setheading(-90)
self.shapesize(
random.random()
* (size_range[1] - size_range[0])
+ size_range[0]
)
self.dot_speed = (
random.random()
* (speed_range[1] - speed_range[0])
+ speed_range[0]
)
def fall(self):
self.forward(self.dot_speed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment