Passed
Push — master ( b6fdd8...a60f45 )
by Yohann
01:13
created

bullet.Bullet.setup()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
from random import randrange
2
3
from src.utils import load
4
5
PLATFORM_TEXTURE_PATH = "src/assets/images/bullet-bill.png"
6
7
8
class Bullet:
9
    _texture = None
10
11
    def __init__(self):
12
        self.rect = self.texture.get_rect()
13
        self.setup()
14
15
    def setup(self):
16
        self.rect.x = randrange(1300, 3000)
17
        self.rect.y = randrange(720)
18
19
    @property
20
    def texture(self):
21
        if self._texture is None:
22
            self._texture = load(PLATFORM_TEXTURE_PATH)
23
        return self._texture
24
25
    def move(self, game):
26
        self.rect.x -= 2 * int(game.player.ax)
27
28
        if self.rect.x - self.rect.width > 0:
29
            self.setup()
30
31
    def check_hit_box(self, player):
32
        return self.rect.colliderect(player.rect)
33