-
Notifications
You must be signed in to change notification settings - Fork 0
/
sprite.py
67 lines (58 loc) · 1.16 KB
/
sprite.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
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
import math
from colorcode import color
class sprite:
def __init__(self,x,y,ch):
self.__x=x
self.__y=y
self.valid=1
self.ch=ch
def printsp(self,co):
ch=self.ch
xp=math.floor(self.__x)
yp=math.floor(self.__y)
print(co+"\033[{};{}f {}".format(yp,xp,ch)+color.END)
def upd(self,dx,dy):
self.__x+= dx
self.__y+= dy
def getx(self):
return self.__x
def gety(self):
return self.__y
class spr(sprite):
def __init__(self,x,y,ch):
sprite.__init__(self,x,y,ch)
def update(self,sp):
self.upd(-sp,0)
xc=self.getx()
if xc<=3:
self.valid=0
class bull(sprite):
def __init__(self,x,y,vx,vy,ch):
sprite.__init__(self,x,y,ch)
self.vx=vx
self.vy=vy
def update(self):
self.upd(-self.vx,-self.vy)
xc=self.getx()
yc=self.gety()
# self.vy-=0.07
if xc<=3:
self.valid=0
if yc>35 or yc <3:
self.valid=0
class dragon(sprite):
def __init__(self,x,y,ch):
sprite.__init__(self,x,y,ch)
def update(self):
self.upd(-1,0)
xc=self.getx()
if xc<0:
self.valid=0
class magnets(sprite):
def __init__(self,x,y,ch):
sprite.__init__(self,x,y,ch)
def update(self,sp):
self.upd(-sp,0)
xc=self.getx()
if xc<0:
self.valid=0