def __init__(self, x, y, sprite): self.image = sprite.image self.spawnX = x self.spawnY = y self.x = x self.y = y + Level.yOffset self.width = sprite.width self.height = sprite.height self.rect = pygame.Rect(self.x, self.y, self.width, self.height) self.speed = 10 self.hp = 10 self.score = 0 self.xp = 0 self.level = 0 self.levelNum = Font.createTextObject(Font.smallCambria, str(self.level), Color.black) self.healthBar = Bar(self, self.hp, self.hp) self.levelBar = LevelBar(self, self.xp, 100, Color.purple, Color.white, yOffset=-2, height=2) self.inv = Inventory(self) self.weapon = Weapons.Flame(self) self.cooldown = 0
def __init__(self, x, y, sprite, hp): self.x = x self.y = y self.width = sprite.width self.height = sprite.height self.rect = pygame.Rect(self.x, self.y, self.width, self.height) self.sprite = sprite self.image = sprite.image self.hp = hp self.healthBar = Fighter.Bar(self, self.hp, self.hp) self.radius = 50 self.score = 0 self.weapon = Weapons.Flame(self) self.time = 0
def __init__(self, x, y, sprite): self.cooldown = 0 self.direction = 0 self.image = sprite.image self.x = x + 50 * random.gauss(0, 1) self.y = y + 20 * random.gauss(0, 1) + Level.yOffset self.width = sprite.width self.height = sprite.height self.rect = pygame.Rect(self.x, self.y, self.width, self.height) self.speed = 2 self.hp = 10 self.healthBar = Bar(self, self.hp, self.hp) self.stop = False self.defeated = False self.killer = None self.weapon = Weapons.Flame(self)
b.draw(screen) class TowerShop(Shop): pass map = Map(Sprite.map) bg = Map(Sprite.bg) alphabg = Map(Sprite.alphabg) alphabg2 = Map(Sprite.greyalpha, 600, 100) wave = Wave(5, FPS) offset = Offset(xOffset, yOffset) shop = Shop(0, height + yOffset, [ Weapons.Flame(Fighter.player), Weapons.Thunder(Fighter.player), Weapons.Icer(Fighter.player) ], [5, 10, 20]) skinsShop = Shop( width - 100, 200, [Sprite.zach, Sprite.victoriaGold, Sprite.allison, Sprite.ben], [1, 2, 3, 4], style=1) #Examples of Bad Object Oriented Programming Below #wave1 = Wave(5, FPS, 1) #wave2 = Wave(10, FPS * 1.1, 2) #wave3 = Wave(20, FPS * 1.2, 3)