def shoot(self, creeps, game): creep = creeps[math.rand(len(creeps) - 1)] shots = turret.shots % 4 missile = { "x": self.x + (shots % 2 === 0 ? -5 : 5), "y": self.y + (shots < 2 ? -5 : 5) } game.untilfalse.push(function(){ if (creep.hp <= 0) { var creeps = game.creeps.filter(function(){ return true; }); if (creeps.length) { creep = creeps[Math.rand(creeps.length - 1)]; } else { return false; } } if (Math.move(missile, creep, 3)) { if (turret.full) { game.creeps.forEach(function(c){ if (Math.inRadius(creep, c, 20)) { c.hp -= turret.damage; } }); } else { creep.hp -= turret.damage; } return false; } else { canvas.fillStyle = "#fff"; canvas.fillRect(missile.x - 2, missile.y - 2, 4, 4); } });
def shoot(self, creeps, game): creep = creeps[0] creep.hp -= self.damage if self.maxed and math.rand(9) == 0 waypoint = game.map[0] creep.x, creep.y = waypoint.x, waypoint.y creep.nextpoint = 0
def __init__(self, x, y, hp, wave): self.x = x self.y = y self.offset = math.rand() self.nextpoint = 0 self.speed = 1 self.slowfor = 0 self.fire = False self.hp = hp self.orighp = hp self.cash = wave
def shoot(self, creeps, game): creep = creeps[math.rand(len(creeps) - 1)] shots = turret.shots % 4 missile = { "x": self.x + (shots % 2 === 0 ? -5 : 5), "y": self.y + (shots < 2 ? -5 : 5) }