Issues (10)

examples/example_007.py (1 issue)

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