-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enemy.py
30 lines (27 loc) · 983 Bytes
/
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
#################################################
# Enemy.py
# Enemy class used in minigame
#
# Your name: Jackie Yang Section: J
# Your andrew id: jaclyny
#
#################################################
from Drawnimate import *
import random
class Enemy(object):
def __init__(self, app):
self.app = app
self.margin = 170
self.locX = self.makeLocX()
self.locY = self.app.height - self.margin
# determines random x location of the enemy
def makeLocX(self):
num = 2
randNum = random.randint(0,2)
# randomly chooses if enemy will be to the left or right of player
if randNum == 0:
return random.randint(self.app.player.locX - self.app.width * num,
self.app.player.locX - self.margin * 2)
else:
return random.randint(self.app.player.locX + self.margin * 2,
self.app.player.locX + self.app.width * num)