Passed
Push — master ( fe7579...78f560 )
by Erik
01:07
created

examples/example_007.py (3 issues)

1
from pypen import *
2
3
4
class Icon():
5
    def __init__(self, x, y):
6
        self.x = x
7
        self.y = y
8
        self.types = 2
9
        self.type = int(random(self.types))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable random does not seem to be defined.
Loading history...
10
        self.variation = random(1)
11
        self.width = 20
12
        self.color = "#383838"
13
        self.secondary_color = "#565656"
14
15
    def update(self):
16
        save()
17
        translate(self.x, self.y)
18
        rotate(TIME)
19
20
        self.color = "#fe3060" if sqrt((self.x-MOUSE.x)**2 + (self.y-MOUSE.y)**2) <= 100 else "#383838"
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable sqrt does not seem to be defined.
Loading history...
21
22
        if self.variation > 0.5:
23
            rotate(90)
24
25
        if self.type == 0:
26
            self.rectangle()
27
28
        elif self.type == 1:
29
            self.circle()
30
31
        restore()
32
33
    def rectangle(self):
34
        if self.variation > 0.9:
35
            rectangle(0 - self.width/2, 0 - self.width/2, self.width, self.width, self.secondary_color)
36
            return
37
38
        rectangle(0 - self.width/2, 0 - self.width/2, self.width, self.width, self.color)
39
40
    def circle(self):
41
        circle(0, 0, self.width/2, self.color)
42
        if self.variation > 0.6:
43
            arc(0, 0, self.width/2, 0, PI, self.secondary_color)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable PI does not seem to be defined.
Loading history...
44
45
46
def start():
47
    settings.fps = 60
48
49
    global icons
50
    icons = []
51
    for x, y in grid(50):
52
        icons.append(Icon(x, y))
53
54
55
def update():
56
    fill_screen("#343434")
57
58
    for icon in icons:
59
        icon.update()
60
61
    circle(MOUSE.x, MOUSE.y, 100, (0, 0, 0, 100))
62