def _create_random_towers(self): tower_count = randint(6,15) while len(self.towers) < tower_count: row = randint(1,18) col = randint(1,18) self.build_tower(coord2xy_mid((row,col)), (255,200,50), self.towers)
def _compute_direction(self, time_passed): """ Finds out where to go """ coord = xy2coord(self.pos) x_mid, y_mid = coord2xy_mid(coord) # if ((x_mid - self.pos.x) * (x_mid - self.prev_pos.x) < 0 or # (y_mid - self.pos.y) * (y_mid - self.prev_pos.y) < 0): if self.pos == (x_mid,y_mid): next_coord = self.next_on_path(coord) self.direction = v(next_coord[1] - coord[1], next_coord[0] - coord[0]).normalized()
def _compute_direction(self, time_passed): """ Finds out where to go """ coord = xy2coord(self.pos) x_mid, y_mid = coord2xy_mid(coord) # if ((x_mid - self.pos.x) * (x_mid - self.prev_pos.x) < 0 or # (y_mid - self.pos.y) * (y_mid - self.prev_pos.y) < 0): if self.pos == (x_mid, y_mid): next_coord = self.next_on_path(coord) self.direction = v(next_coord[1] - coord[1], next_coord[0] - coord[0]).normalized()