Passed
Push — master ( 2f29cd...4bc53c )
by Yohann
01:12
created

bullet.Bullet.move()   A

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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