-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemies.py
More file actions
109 lines (86 loc) · 2.51 KB
/
enemies.py
File metadata and controls
109 lines (86 loc) · 2.51 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import math
import n
from cmu_112_graphics import *
def getCellBounds(row, col):
cellWidth = 1200 / 15
cellHeight = 700 / 15
x0 = col * cellWidth
x1 = (col+1) * cellWidth
y0 = row * cellHeight
y1 = (row+1) * cellHeight
return (x0, y0, x1, y1)
def distance(x, y, x1, y1):
return ((x-x1)**2 + (y-y1)**2)**0.5
def board(rows, cols):
return [[0] * cols for row in range(rows)]
class Enemy(object):
def __init__(self, row, col):
self.color = "red"
self.health = 1
self.rows = 15
self.cols = 15
self.board = board(self.rows, self.cols)
self.peth = []
self.path1 = n.createmap(self.board, self.peth)[0]
self.gold = 15
self.pos = 0
self.row, self.col = row, col
self.freeze = False
def weakerballoon(self):
self.health = 0
return self
class BlueBalloon(Enemy):
def __init__(self, row, col):
super().__init__(row,col)
self.color = "blue"
self.gold = 30
self.health = 2
self.row = row
self.col = col
self.pos = 0
self.freeze = False
def weakerballoon(self):
balloon = Enemy(self.row, self.col)
balloon.pos = self.pos
return balloon
class GreenBalloon(Enemy):
def __init__(self, row, col):
super().__init__(row, col)
self.color = "green"
self.gold = 60
self.health = 3
self.row = row
self.col = col
self.pos = 0
self.freeze = False
def weakerballoon(self):
balloon = BlueBalloon(self.row, self.col)
balloon.pos = self.pos
return balloon
class YellowBalloon(Enemy):
def __init__(self, row, col):
super().__init__(row, col)
self.color = "yellow"
self.gold = 100
self.health = 4
self.row = row
self.col = col
self.pos = 0
self.freeze = False
def weakerballoon(self):
balloon = GreenBalloon(self.row, self.col)
balloon.pos = self.pos
return balloon
class MetalBalloon(Enemy):
def __init__(self, row, col):
super().__init__(row, col)
self.color = "black"
self.gold = 100
self.health = 20
self.row = row
self.col = col
self.pos = 0
self.freeze = False
def weakerballoon(self):
self.health -=1
return self