Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
Autumn!
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeykolosov committed Sep 17, 2018
1 parent b6cb9cc commit cf125fc
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions main.py
Expand Up @@ -11,19 +11,33 @@ class Colours:
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
AUTUMN = (204, 153, 0)
BROWN = (102, 78, 0)


class Particle:
def __init__(self, pos, size=10):
self.pos = pos
def __init__(self, pos, size=10, colour=Colours.WHITE):
self.x = pos[0]
self.y = pos[1]
self.size = size
self.colour = colour

@property
def pos(self):
return (self.x, self.y)

def draw(self):
screen.draw.filled_circle(self.pos, self.size, Colours.WHITE)
screen.draw.filled_circle(self.pos, self.size, self.colour)

@classmethod
def random(cls):
return cls((randint(0, WIDTH), randint(0, HEIGHT)), size=randint(5, 20))
def random(cls, colour=Colours.WHITE):
return cls(
(randint(0, WIDTH), randint(0, HEIGHT)),
size=randint(5, 20),
colour=colour
)


LEAVES = [Particle.random(colour=Colours.BROWN) for i in range(30)]


class Season:
Expand Down Expand Up @@ -61,7 +75,8 @@ def draw_summer():


def draw_autumn():
pass
for leaf in LEAVES:
leaf.draw()


def draw_winter():
Expand All @@ -78,7 +93,13 @@ def update_summer():


def update_autumn():
pass
for leaf in LEAVES:
leaf.x += randint(4, 7)
leaf.y += 3
if leaf.x > WIDTH:
leaf.x = -leaf.size
elif leaf.y > HEIGHT:
leaf.y = -leaf.size


def update_winter():
Expand Down

0 comments on commit cf125fc

Please sign in to comment.