-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.py
66 lines (55 loc) · 1.73 KB
/
enemy.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import pygame
from characters import Character
from textures import img
from weapons import Pistol, Tompson, Mp40
class Enemy(Character):
def __init__(self, x, y):
super().__init__()
self.rect.x = x
self.rect.y = y
self.last_attack = 0
self.period = 0
self.enemy = True
self.pointsdamage = 0
self.points = 0
def damage(self, n):
super().damage(n)
if self.hp <= 0:
self.kill()
return True
return False
def attack(self, blasts):
if pygame.time.get_ticks() - self.last_attack < self.period:
return
blasts.add(self.selectedgun.blast(self, self.direction))
self.last_attack = pygame.time.get_ticks()
def draw(self, screen):
self.selectedgun.drawmini(self, screen)
class Enemy1(Enemy):
def __init__(self, x, y):
super().__init__(x, y)
self.image = self.org_image = img.enemy1
self.hp = 100
self.selectedgun = Pistol(0, 0)
self.period = 2000
self.pointsdamage = 5
self.points = 10
class Enemy2(Enemy):
def __init__(self, x, y):
super().__init__(x, y)
self.image = self.org_image = img.enemy2
self.hp = 300
self.selectedgun = Tompson(0, 0)
self.period = 500
self.pointsdamage = 7
self.points = 20
class Enemy3(Enemy):
def __init__(self, x, y):
super().__init__(x, y)
self.image = self.org_image = img.enemy3
self.hp = 600
self.selectedgun = Mp40(0, 0)
self.selectedgun.blast.speed = 12
self.period = 500
self.pointsdamage = 9
self.points = 35