-
Notifications
You must be signed in to change notification settings - Fork 0
/
ETank.py~
52 lines (40 loc) · 1.77 KB
/
ETank.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
import pygame, sys , math
from pygame.locals import *
from Tank import *
class ETank(pygame.sprite.Sprite):
def __init__(self,X,Y):
self.health = 100
self.posX = X
self.posY = Y
self.tankw =168
self.tankh = 71
self.tankList =[Tank(X,Y)]
self.tankImages = [pygame.image.load('tanks/p2tank-str0.png'),pygame.image.load('tanks/p2tank-med0.png'),pygame.image.load('tanks/p2tank-high0.png')]
self.attackImages = [pygame.image.load('tanks/p2tank-str1.png'),pygame.image.load('tanks/p2tank-med1.png'),pygame.image.load('tanks/p2tank-high1.png')]
self.tankList[0].setImages(self.tankImages,self.attackImages)
self.clock = 0
self.moveX = 0
self.moveY = 0
self.limit = 2
def getX(self):
return self.posX
def getY(self):
return self.posY
def moveTank(self,maxX,maxY):
self.clock += 1
if self.clock > 80 and len(self.tankList) < self.limit :
self.clock = 0
self.tankList.append(Tank(self.posX,self.posY))
self.tankList[len(self.tankList)-1].setImages(self.tankImages,self.attackImages)
for i in range(0,len(self.tankList)-1):
self.tankList[i].IsInBounds(maxX,maxY,self.moveX,self.moveY)
def getCount(self):
return len(self.tankList)-1
def destroyTank(self):
for i in range(0, len(self.tankList)-1):
if self.tankList[i].getHP() <= 0:
self.tankList.pop(i)
def drawTank(self,screen):
for i in range(0,len(self.tankList)-1):
screen.blit(self.tankList[i].getImage(),(self.tankList[i].getX(),self.tankList[i].getY()))
pygame.display.update()