-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirus.py
More file actions
47 lines (36 loc) · 1.02 KB
/
virus.py
File metadata and controls
47 lines (36 loc) · 1.02 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
import gtk
import random
from sprite import Sprite
DEFAULT_WIDTH=20
DEFAULT_HEIGHT=20
class Virus(Sprite):
def __init__(self, posX=0, posY=0):
Sprite.__init__(self,posX,posY)
self.width=DEFAULT_WIDTH
self.height=DEFAULT_HEIGHT
self.color=(0.3,0.6,0.5)
self.maxHp=1000
self.hp=self.maxHp
self.deltaHp=1
self.transHp=self.hp
self.isDead=False
self.velX=0.0;
self.velY=0.0;
def __str__(self):
return "The Virus hp:%d" % (self.transHp)
def get_type(self):
return "Virus"
def update(self):
Sprite.update(self)
self.posX+=self.velX
self.posY+=self.velY
if self.transHp<=0:
self.isDead=True
if self.transHp<self.hp-self.deltaHp:
self.transHp+=self.deltaHp
elif self.transHp>self.hp+self.deltaHp:
self.transHp-=self.deltaHp
elif self.transHp != self.hp:
self.transHp=self.hp
def paint(self,window):
pass