-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
34 lines (31 loc) · 1 KB
/
utils.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
31
32
33
34
import random
from termcolor import colored
class Block():
def __init__(self, type):
self.type = type
self.color = 'white'
self.chardmg = 'X'
self.char = ''
self.health = 2
self.x = 0
self.y = 0
self.id = random.randint(0,999999)
self.getChar()
def getInfo(self):
return {'id':self.id,'x':self.x,'y':self.y,'color':self.color,'char':self.char,'type':self.type,'health':self.health}
def getChar(self):
if(self.health == 2):
char = colored(self.chardmg, self.color, 'on_' + self.color)
else:
char = colored(self.chardmg, 'grey', 'on_' + self.color)
self.char = char
class Bullet():
def __init__(self):
self.range = 10
self.x = 0
self.y = 0
self.id = random.randint(0,9999999)
self.xadd = 0
self.yadd = 0
def getInfo(self):
return {'id':self.id,'x':self.x,'y':self.y,'range':self.range,'xadd':self.xadd,'yadd':self.yadd}