Пример #1
0
    def fire(self, screen):

        nbullet = Bullet(self)
        nbullet.mx = 1
        self.bullets.append(nbullet)
        # her ateş edilişinde bir ateş edilme animasyonu devreye girmelidir
        # bu işlem farklı yollarla yapılabilir
        # burada yaprığımız normalde -1 olan shoot değerini 0  yapıyoruz ve nesnenin çizim fonksiyonunda bir if yapısıyla bu durumu kontrol ediyoruz.
        self.shootImageOrder = 0
Пример #2
0
 def fire(self, mposition):
     nbullet = Bullet(self)
     mx = float(mposition[0] - self.width / 2)
     my = float(mposition[1] - self.height / 2)
     angle = math.atan2(my, mx)
     nbullet.mx = float(math.cos(angle)) * 10
     nbullet.my = float(math.sin(angle)) * 10
     print(nbullet.mx)
     print(nbullet.my)
     nbullet.image = pygame.transform.rotate(nbullet.image,
                                             -math.degrees(angle))
     self.bullets.append(nbullet)