This repository was archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemy.py
More file actions
79 lines (63 loc) · 2.04 KB
/
enemy.py
File metadata and controls
79 lines (63 loc) · 2.04 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
# --- Imports --- #
import sprites
import random
# --- Enemy Class --- #
class Enemy(object):
X = random.randrange(0,1280)
Y = 530
direction = "Right"
damage = 30
animation_int = 0
current = sprites.Enemy_Walking_List
speed = 5
health = 100
counter = 0
wait_counter = 0
moving = False
dead = False
attack = False
next_0 = True
next_1 = False
def movement(self, Player_X):
if not self.attack and self.moving and not self.dead:
if Player_X < self.X:
self.direction = "Left"
self.X -= self.speed
elif Player_X > self.X:
self.direction = "Right"
self.X += self.speed
def animation(self):
self.counter += 1
if self.counter == 10:
if self.moving:
self.current = sprites.Enemy_Walking_List
if self.next_0:
self.animation_int = 0
self.next_0 = False
self.next_1 = True
elif self.next_1:
self.animation_int = 1
self.next_0 = True
self.next_1 = False
if self.dead == True:
self.moving = False
self.wait_counter += 1
if self.wait_counter == 8:
self.X = self.new_X()
self.Y = 530
self.health = 100
self.dead = False
self.moving = False
self.wait_counter = 0
else:
if self.dead == True and self.moving == False:
self.wait_counter += 1
if self.wait_counter == 8:
self.moving = True
self.wait_counter = 0
self.counter = 0
def new_X(self):
return random.randrange(0,1280)
def __main__(self, Player_X):
self.animation()
self.movement(Player_X)