-
Notifications
You must be signed in to change notification settings - Fork 0
/
pandaAttack1.py
62 lines (46 loc) · 1.76 KB
/
pandaAttack1.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
import pygame, sys , math
from pygame.locals import *
from Tank import *
#Panda = pandaAttack(gameWidth*3/4, groundHeight-50)
#Panda.movePanda(gameWidth,gameHeight)
class pandaAttack(pygame.sprite.Sprite):
def __init__(self,X,Y):
self.health = 100
self.posX = X
self.posY = Y
self.pandaw = 267
self.pandah = 306
self.pandaImages = pygame.image.load('enemies/pandas/p2atkPanda.png')
self.attackImage = pygame.image.load('enemies/pandas/p2slPanda.png')
def getX(self):
return self.posX
def getY(self):
return self.posY
def IsInBounds(self,maxX,maxY,moveX,moveY):
if self.posX + moveX >= 0 and self.posX + self.pandaw + moveX <= maxX:
self.posX = self.posX + moveX
if self.posY + moveY >= 0 and self.posY + self.pandah + moveY <= maxY:
self.posY = self.posY + moveY
def getImage(self):
return self.pandaImages
class pandaList():
def __init__(self,X,Y):
self.pandaList = []
self.clock = 0
self.posX = X
self.posY = Y
self.moveX = -2
self.moveY = 0
self.limit = 2
def movePanda(self,maxX,maxY):
self.clock = self.clock + 1
if self.clock > 50 and len(self.pandaList) < self.limit :
self.clock = 0
self.pandaList.append(pandaAttack(self.posX,self.posY))
for tempPanda in self.pandaList:
tempPanda.IsInBounds(maxX,maxY,self.moveX,self.moveY)
def getCount(self):
return len(self.pandaList)-1
def drawPanda(self,screen):
for i in range(0,len(self.pandaList)-1):
screen.blit(self.pandaList[i].getImage(),(self.pandaList[i].getX(),self.pandaList[i].getY()))