Passed
Push — master ( d162e0...e74029 )
by Erik
53s
created

example_007.Icon.__init__()   A

Complexity

Conditions 1

Size

Total Lines 9
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nop 3
dl 0
loc 9
rs 9.95
c 0
b 0
f 0
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
        save()
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable save does not seem to be defined.
Loading history...
17
        translate(self.x, self.y)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable translate does not seem to be defined.
Loading history...
18
        rotate(TIME)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable rotate does not seem to be defined.
Loading history...
19
20
        self.color = "#fe3060" if sqrt((self.x-MOUSE.x)**2 + (self.y-MOUSE.y)**2) <= 100 else "#383838"
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()
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable restore does not seem to be defined.
Loading history...
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)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable rectangle does not seem to be defined.
Loading history...
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)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable circle does not seem to be defined.
Loading history...
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 arc 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
    global current_x, current_y
57
    fill_screen("#343434")
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable fill_screen does not seem to be defined.
Loading history...
58
    for icon in icons:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable icons does not seem to be defined.
Loading history...
59
        icon.update()
60
61
    circle(MOUSE.x, MOUSE.y, 100, (0, 0, 0, 100))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable circle does not seem to be defined.
Loading history...
62