def step(self): if self.droga: direction = self.droga.pop(0) else: print("-1 lives") c.HP -= 1 self.update_stats() print("Monster reached destination. Player HP is", c.HP) self.kill() return if self.hp <= 0: self.image_current = u.RGBAImage("blood.png") self.image_current_tk = u.RGBAImageTk(self.image_current) self.master.itemconfig(self.image, image=self.image_current_tk) self.master.after(100, self.kill) c.GOLD += self.gold self.update_stats() print("Killed by tower") return if direction == [1, 0]: self.image_current = self.monster1r_image self.image_current_tk = u.RGBAImageTk( u.drawProgressBarOver(self.image_current, self.hp, self.MAX_HP)) self.master.itemconfig(self.image, image=self.image_current_tk) elif direction == [0, -1]: self.image_current = self.monster1u_image self.image_current_tk = u.RGBAImageTk( u.drawProgressBarOver(self.image_current, self.hp, self.MAX_HP)) self.master.itemconfig(self.image, image=self.image_current_tk) elif direction == [-1, 0]: self.image_current = self.monster1l_image self.image_current_tk = u.RGBAImageTk( u.drawProgressBarOver(self.image_current, self.hp, self.MAX_HP)) self.master.itemconfig(self.image, image=self.image_current_tk) elif direction == [0, 1]: self.image_current = self.monster1d_image self.image_current_tk = u.RGBAImageTk( u.drawProgressBarOver(self.image_current, self.hp, self.MAX_HP)) self.master.itemconfig(self.image, image=self.image_current_tk) self.x += direction[0] self.y += direction[1] self.pos = self.y * c.skala + self.x self.animate_step(3, direction) if self.slowDuration > 0: self.slowDuration -= 1 else: self.speedModifier = 1.0 self.setImagesBase() if self.alive: self.master.after(int(self.stepInterval * self.speedModifier), self.step)
def __init__(self, id, C=None): print("IcyTower created with ID: %i" % id) self.alive = True self.id = id self.x = self.__getX() self.y = self.__getY() # wspolrzedne na Canvas self.xx = u.convertToCanvasCoord(self.x) self.yy = u.convertToCanvasCoord(self.y) self.range = 5 self.attackInterval = 2000 self.projectileStepInterval = 100 self.damage = 1 self.cost = c.icy_tower_cost self.slow = 2.0 #percentage self.slowTime = 5 #number of steps self.aoeSize = 2 self.C = C self.pos = self.y * c.skala + self.x self.master = C self.tower1_image = u.RGBAImageTk(u.RGBAImage('t2.png')) self.image = self.master.create_image(self.xx, self.yy, image=self.tower1_image) self.attack()
def kill(self): if self.alive: self.tower1_image = u.RGBAImageTk(u.RGBAImage("explosion.png")) self.master.itemconfig(self.image, image=self.tower1_image) self.alive = False del self.image c.towers.remove(self) del self
def kill(self): if self.alive: self.tower1_image = u.RGBAImageTk(u.RGBAImage("explosion.png")) self.master.itemconfig(self.image, image=self.tower1_image) self.alive = False del self.image c.towers.remove(self) print("CannonTower with ID: %i destroyed" % self.id) del self
def __init__(self, x, y, C=None, stats_C=None): self.master = C self.stats_C = stats_C # potrzebne do A* self.x = x self.y = y self.droga = [] self.queue = [] self.MAX_HP = 20 self.hp = self.MAX_HP self.pos = self.y * c.skala + self.x self.gold = 30 self.stepInterval = 1600 self.speedModifier = 1.0 self.slowDuration = 0 self.explosionRange = 1 self.opened = [] self.closed = [] self.start = None self.koniec = None self.local_map = create_blocks() self.exploded = False self.alive = True # wspolrzedne na Canvas self.xx = self.x * c.kratka + c.kratka // 2 self.yy = self.y * c.kratka + c.kratka // 2 # rysuj kwadrat o rogach: #self.image = self.master.create_rectangle(self.x * c.kratka, self.y * c.kratka, (self.x + 1) * c.kratka, (self.y + 1) * c.kratka, # fill="red", # width=c.block_outline_width) self.monster1r_image_base = u.RGBAImage('m2r.png') self.monster1d_image_base = u.RGBAImage('m2d.png') self.monster1l_image_base = u.RGBAImage('m2l.png') self.monster1u_image_base = u.RGBAImage('m2u.png') self.monster1r_image_slowed = u.createCircle(u.RGBAImage('m2r.png')) self.monster1d_image_slowed = u.createCircle(u.RGBAImage('m2d.png')) self.monster1l_image_slowed = u.createCircle(u.RGBAImage('m2l.png')) self.monster1u_image_slowed = u.createCircle(u.RGBAImage('m2u.png')) self.monster1r_image = self.monster1r_image_base self.monster1d_image = self.monster1d_image_base self.monster1l_image = self.monster1l_image_base self.monster1u_image = self.monster1u_image_base self.image_current = self.monster1r_image self.image_current_tk = u.RGBAImageTk(self.image_current) self.image = self.master.create_image(self.xx, self.yy, image=self.image_current_tk) self.find_way() self.step()
def __init__(self, id, C=None): print("CannonTower created with ID: %i" % id) self.alive = True self.id = id self.x = self.__getX() self.y = self.__getY() # wspolrzedne na Canvas self.xx = self.x * c.kratka + c.kratka // 2 self.yy = self.y * c.kratka + c.kratka // 2 self.range = 6 self.attackInterval = 1500 self.projectileStepInterval = 50 self.damage = 3 self.cost = c.cannon_tower_cost self.C = C self.pos = self.y * c.skala + self.x self.master = C self.tower1_image = u.RGBAImageTk(u.RGBAImage('t1.png')) self.image = self.master.create_image(self.xx, self.yy, image=self.tower1_image) self.attack()
def rotate_image(self, angle): self.tower1_image = u.RGBAImageTk(u.RGBAImage('t2.png').rotate(angle)) self.image = self.master.create_image(self.xx, self.yy, image=self.tower1_image)
def updateHealthBar(self): self.image_current_tk = u.RGBAImageTk( u.drawProgressBarOver(self.image_current, self.hp, self.MAX_HP)) self.master.itemconfig(self.image, image=self.image_current_tk)