def __init__(self): self.pywindow = pygame.display.set_mode((900, 600), 0, 32) #窗口大小 self.image = Image.Image() #导入图片 self.botany = Botany.Botany() #植物类 self.zombie = Zombie.Zombie() #僵尸类 self.collision = Collision.Collision() #碰撞类 self.audio = Audio.Audio() #音频类 self.Sunny_Collect = [] #回收的阳光坐标列表 self.Sunny_Collect_x = 0 self.Sunny_Collect_y = 0 self.Botany_Type = 0 #植物类型 self.Botany_Animation_Type = 0 #植物动画类型 self.Zombie_Animation_Type = 0 #僵尸动画类型 self.Stop_image = self.image.game_pause_nor #暂停初始图标 self.Zombie_image_list = 0 #僵尸图片列表索引 self.SunFlower_image_list = 16 #向日葵图片列表索引(从后往前索引只是想测试一下,并无大碍) self.Peashooter_image_list = 12 #豌豆列表索引 self.ZombieAttack_image_list = 0 #僵尸吃植物索引 self.FootballZombie_image_list = 0 #重装僵尸图片索引 self.FootballZombieAttack_image_list = 0 #重装僵尸吃植物图片索引 self.FootballZombieDie_image_list = 0 #重装僵尸死亡图片索引 self.evillaugh = pygame.mixer.Sound(self.audio.evillaugh) #僵尸暴走音效 self.Zombie_Go_ballistic_audio = 0 #暴走音效控制变量 self.scream = pygame.mixer.Sound(self.audio.scream) #僵尸胜利音效 self.buttonclick = pygame.mixer.Sound(self.audio.buttonclick) # 按钮音效 self.Zdie = pygame.mixer.Sound(self.audio.groan4) #僵尸死亡音效 self.ZWon = 0 #僵尸胜利后音效控制
def __init__(self, temp): self.initImg() self.initButts() self.zomb = Zombie(gameMode.width, gameMode.height/2, self.zombImg) self.gunn = Gun(self.gunImg) diff = random.randint(50, 150) self.zombs = \ [Zombie(gameMode.width+i*random.randint(200, 400),\ random.choice(range(100, gameMode.height-100,50)), self.zombImg) for i in range(temp)] self.temp = temp self.bulls = [] self.originNum = len(self.zombs) self.isReloading = False self.reload = 500 self.HP = 1 self.origin = self.HP # game status: self.isLost = False self.isWon = False self.isPause = False
def load_sprites(self): """Load all of the human sprites.""" self.zombie_group = pygame.sprite.Group() for i in range(NUMBER_OF_zombieS): self.zombie_group.add( Zombie.Zombie(rect=pygame.Rect(random() * self.width, random() * self.height, 30, 30), color='zombie2.png')) self.alive_group = pygame.sprite.Group() for i in range(NUMBER_OF_alive): self.alive_group.add( Alive.Alive(rect=pygame.Rect(random() * self.width, random() * self.height, 10, 10), deathSound=self.chewSound, color='brain4.png'))
def createUnitToBuy(self): self.uniteToBuy = [ Amazon(), Dwarf(), Elf(), Giant(), Hobbit(), Humans(), Mago(), Orc(), Rats(), Skeletton(), Triton(), Troll(), Wizzard(), Zombie() ] shuffle(self.uniteToBuy)
def __init__(self, parent): self.parent = parent self.livraison = Livraison.Livraison() self.uniteEnJeu = {} self.survivant = {} self.caisse = {} self.caisseAttribuer = {} self.creerSurvivor() pos = [] for i in range(10): porteDepart = random.randrange(1, 5) edgeX = random.randrange(1, 10) edgeY = random.randrange(1, 10) if porteDepart == 1: pos = [755 + edgeX, 250 + edgeY] elif porteDepart == 2: pos = [755 + edgeX, 350 + edgeY] elif porteDepart == 3: pos = [35 + edgeX, 250 + edgeY] elif porteDepart == 4: pos = [35 + edgeX, 350 + edgeY] self.uniteEnJeu[i] = Zombie.Zombie(pos, porteDepart)
def _createRoom(self): #,name,description, zombies, spawnpoint): """ Creats an individual room. See Room list in Layout.py for info """ i = 0 #create rooms for name, description, spawnpoint, itemSpawnPoint, item, safeRoom in rowanHallRooms: tempRoom = Room(name, description, spawnpoint, itemSpawnPoint, item, safeRoom) self._rooms.append(tempRoom) self._name2InstanceMap[name] = i i = i + 1 #create zombies for roomName, name, power, toughness, hitpoints in zombies: zombietmp = Zombie.Zombie(name=name, power=power, toughness=toughness, min=0, max=hitpoints, locationName=roomName) roomid = self._name2InstanceMap[roomName] self._rooms[roomid]._zombies.append(zombietmp)
def create_zombie(self): zombie = Zombie() return zombie
pygame.display.flip() pygame.display.set_caption('ZOMBIE') cursor = Cursor.Cursor() cgroup = pygame.sprite.RenderUpdates() cgroup.add(cursor) zombies = pygame.sprite.RenderUpdates() heroes = pygame.sprite.RenderUpdates() for i in xrange(0,1): heroes.add(Hero.Hero()) for i in xrange(0,6): zombies.add(Zombie.Zombie(heroes)) def update(): cgroup.clear(window, media.BACKGROUND) zombies.clear(window, media.BACKGROUND) heroes.clear(window, media.BACKGROUND) cgroup.update() zombies.update() heroes.update() rectlist = zombies.draw(window) + heroes.draw(window) + cgroup.draw(window) pygame.display.update(rectlist) pygame.display.flip() pygame.event.set_allowed([KEYDOWN, KEYUP, QUIT])
def loadZombie(self) -> Zombie.Zombie: '''Return Zombie''' self._zombies.append(Zombie.Zombie(self._zombieSpeed))
def initZombies(x): global zombies global swarm swarm = Swarm.Swarm((Util.WINDOW_WIDTH, Util.WINDOW_HEIGHT)) for i in range(0, x): zombies.append(Zombie.Zombie(hero, swarm))