-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathenemy.py
More file actions
32 lines (26 loc) · 1.08 KB
/
enemy.py
File metadata and controls
32 lines (26 loc) · 1.08 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
'''Defines behaviour of enemies of Mario'''
from people import People
from base import Point, Dimension, IDENTIFIER
class SlaveEnemy(People):
'''Small and weak Villans'''
def __init__(self, x, y, board):
ch = IDENTIFIER['SlaveEnemy']
shape = [[ch, ch], [ch, ch]]
board.all_enemies.append(self)
People.__init__(self, Point(x, y), 1, shape, Dimension(2, 2), board)
class BossEnemy(People):
'''Weak and smart enemy'''
def __init__(self, x, y, board):
ch = IDENTIFIER['BossEnemy']
shape = [[ch, ch, ch], [ch, ch, ch], [ch, ch, ch]]
board.all_enemies.append(self)
People.__init__(self, Point(x, y), 1, shape, Dimension(3, 3), board)
def self_move(self, unit):
if 20 > self.point.y - self.board.mario.point.y > 0:
if not self.move_left(2 * unit):
self.move_right(2 * unit)
elif 20 > self.board.mario.point.y - self.point.y > 0:
if not self.move_right(2 * unit):
self.move_left(2 * unit)
else:
People.self_move(self, 2 * unit)