def mushroom_attack_loop(self): g = self.g if self.health <= 0: if self.feeling != 'dead': self.feeling = 'dead' self.timer = 0 if self.feeling == 'dead': if self.timer > 70: self.image = pygame.Surface((1, 1), SRCALPHA) self.dead = 1 return if self.timer % 10 == 0: self.exp2.play() if self.timer % 3 == 0: # flash on and off self.image = pygame.Surface((1, 1), SRCALPHA) else: x = random.randint(0, 256) y = random.randint(0, 256) e = Effect(self.g, 'explosion', (self.rect.x + x, self.rect.y + y)) return if self.timer % 20 == 1: if self.timer % 200 < 100: c = random.randint(0, 20) s = Shot(self.g, self.direction, (self.rect.x + 128, self.rect.y + 128 + c), 'shot5', 'enemy') s.callback = self.create_slime_monster self.squirt2.play() s = Rect(self.rect) s.x += 80 s.width -= 100 s.y += 100 s.height -= 180 if s.colliderect (g.player.rect): g.player.touch(self) for b in g.bullets: if b.owner == 'player': drect = (b.rect.x + 30, b.rect.y ) if s.collidepoint(drect): b.destroy() self.health -= b.get_damage() e = Effect(self.g, 'health', (self.rect.x, self.rect.y)) e.healthchange = -b.get_damage() tmp = pygame.Surface((256, 256), SRCALPHA) tmp.blit(self.image, (0,0)) tmp.blit(self.secondImage, (0,0)) self.image = tmp self.hitme.play() speed = 2 self.rect.x += (1 - (self.direction * 2)) * speed self.draw_health_meter()
def doctor_attack_loop(self): speed = 6 self.feeling = 'walking' g = self.g if self.health <= 0: #destoryed walking too 813 targntx = self.rect.x if targntx > 813 + speed * 2: # walked too far left left self.dx -= .5 if self.dx < -speed: self.dx = -speed self.rect.x += int(self.dx) self.timer = self.timer % 10 elif targntx < 813 - speed * 2:# walked too far right self.dx += .5 if self.dx > speed: self.dx = speed self.rect.x += int(self.dx) self.timer = self.timer % 10 else: if self.spawnedspecialnurse == 0: print 'spawn special nurse' self.spawnedspecialnurse = 1 s = Shot(self.g, self.direction, (self.rect.x + 128, self.rect.y + 80 ), 'shot6', 'enemy') s.callback = self.create_nurse_character s.xvel = 0 if self.timer < 70: if self.timer % 3 == 0: # flash on and off self.image = pygame.Surface((1, 1), SRCALPHA) else: x = random.randint(0, 256) y = random.randint(0, 256) Effect(self.g, 'explosion', (self.rect.x + x, self.rect.y + y)) return #self.timer += 1 dx = (self.rect.x + self.rect.width/2) - g.player.rect.x dy = (self.rect.y + self.rect.height) - g.player.rect.y pdrect = 100 if self.timer % 1000 > 400: pdrect = 400 if self.dx < 0 and self.dx > -speed: self.dx += -.5 if self.dx > 0 and self.dx < speed: self.dx += .5 if dx > pdrect: # walked too far left left self.dx -= .5 if self.dx < -speed: self.dx = -speed elif dx < -pdrect:# walked too far right self.dx += .5 if self.dx > speed: self.dx = speed # attck with arms if dx > 70 and dx < 140: if dy <50 and dy > 0: if self.attackleft == 0: self.attackleft = 1 if self.attackleft == 5: g.player.touch(self) # attack with the right arm if dx < -70 and dx > -140: if dy <50 and dy > 0: if self.attackright == 0: self.attackright = 1 if self.attackright == 5: g.player.touch(self) # scratching self to stop continius shooting if self.timer % 1000 > 600: self.attackright = 10 # tracks hittin the player #if dx > -40 and dx < 40: # if dy < 40 and dy > 0: # g.player.touch(self) # like the monotane, it shits out little babies if self.timer % 20 == 1: if self.timer % 400 < 200: c = random.randint(0, 20) s = Shot(self.g, self.direction, (self.rect.x + 128, self.rect.y + 80 + c), 'shot6', 'enemy') s.callback = self.create_nurse_monster self.squirt.play() self.rect.x += int(self.dx) self.draw_health_meter()