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

bullet   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Bullet.check_hit_box() 0 2 1
A Bullet.__init__() 0 3 1
A Bullet.move() 0 6 2
A Bullet.texture() 0 5 2
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)