-
Notifications
You must be signed in to change notification settings - Fork 0
/
shoots.py
50 lines (38 loc) · 1.18 KB
/
shoots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
This work with the different attacks types for this game.
The attacks change acording to populational size, age , and specification of
the individual.
"""
# import things
import random
import pygame as pg
from definitions import *
from animations import Animations
# create the POPULATION_CLASSES
class Shoot(Animations):
"""
Default class for other shoots.
it creates itself.
if defines itself with
"""
def __init__(self , enemy_list = None , strenght = 2 , pos = (0,0) , area = (.01 , .01), color = 'black' , velocity = 10 , ang = 0):
if enemy_list is None:
enemy_list = []
self.enemy_list = enemy_list
Animations.__init__(self , color = color , center = pos , groups = (shoots_group) , area = area)
self.damage = 2+strenght
self.angule = ang
self.max_velocity = velocity
self.velocity = [-math.cos(ang)*self.max_velocity , -math.sin(ang)*self.max_velocity]
def update(self):
Animations.update(self)
self.hit_enemies()
if not screen_rect.colliderect(self.rect):
self.kill()
def hit_enemies(self):
for ind in self.enemy_list:
if ind.check_hit(self.rect):
ind.hit(self.damage)
self.kill()
def move(self):
self.rect.move_ip(self.velocity)