-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemy.py
More file actions
58 lines (49 loc) · 1.78 KB
/
enemy.py
File metadata and controls
58 lines (49 loc) · 1.78 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
'''This is code for enemy'''
from board import BOARD
class Enemy():
'''class enemy'''
def __init__(self, xps, yps, vel, sym, no):
self.xps = xps
self.yps = yps
self.vel = vel
self.sym = sym
self.type = no
self.tym = 0
def collision(self, xps, yps):
'''code for collision'''
if BOARD.checkstar(xps, yps + self.vel) == 1:
self.vel = -self.vel
def move(self, i=None):
'''for enemy movement'''
if BOARD.checkstar(self.xps + 1, self.yps) != 1 and i is None:
self.xps += 1
# BOARD.plr(pre_x,pre_y,self.x,self.y,self.sym)
self.collision(self.xps, self.yps)
self.yps += self.vel
# BOARD.plr(self.x,pre_y,self.x,self.y,self.sym)
def print_on_board(self, xps, yps):
'''print enemy'''
BOARD.mat[xps][yps] = self.sym
ELIST = []
ELIST.append(Enemy(18, 70, -1, '@', "enemy1"))
ELIST.append(Enemy(25, 95, 1, '@', "enemy1"))
ELIST.append(Enemy(25, 126, 1, '@', "enemy1"))
ELIST.append(Enemy(25, 136, -1, '@', "enemy1"))
ELIST.append(Enemy(7, 200, -1, '@', "enemy1"))
ELIST.append(Enemy(25, 260, -1, '@', "enemy1"))
ELIST.append(Enemy(25, 265, -1, '@', "enemy1"))
ELIST.append(Enemy(25, 310, -1, '@', "enemy1"))
ELIST.append(Enemy(25, 315, -1, '@', "enemy1"))
ELIST.append(Enemy(25, 325, +1, '@', "enemy1"))
ELIST.append(Enemy(25, 330, +1, '@', "enemy1"))
class Enemy1(Enemy):
'''Turle enemy'''
# DUCK DUCK
def print_on_board(self, xps, yps):
'''print turtle enemy'''
BOARD.mat[xps - 1][yps] = self.sym
BOARD.mat[xps][yps] = 'D'
ELIST.append(Enemy1(25, 15, 1, '^', "enemy2"))
ELIST.append(Enemy1(25, 35, 1, '^', "enemy2"))
ELIST.append(Enemy1(25, 98, -1, '^', "enemy2"))
ELIST.append(Enemy1(25, 275, -1, '^', "enemy2"))