def set_verts(self): delta_angle = math.pi / GameManager.levelCurrentSides if GameManager.sideChangePercent != 0: min_sides = min(GameManager.levelCurrentSides, GameManager.levelNextSides) if self.posIndex < min_sides: delta_angle = GameMath.pow_lerp( math.pi / GameManager.levelCurrentSides, math.pi / GameManager.levelNextSides, GameManager.sideChangePercent, Settings.LERP_POW) else: if min_sides == GameManager.levelNextSides: delta_angle = GameMath.pow_lerp( math.pi / GameManager.levelCurrentSides, 0, GameManager.sideChangePercent, Settings.LERP_POW) else: delta_angle = GameMath.pow_lerp( 0, math.pi / GameManager.levelNextSides, GameManager.sideChangePercent, Settings.LERP_POW) vert1 = GameMath.cil2cart_local(self.vert_mag - self.width / 2, self.vert_angle + delta_angle) vert2 = GameMath.cil2cart_local(self.vert_mag - self.width / 2, self.vert_angle - delta_angle) vert3 = GameMath.cil2cart_local(self.vert_mag + self.width / 2, self.vert_angle + delta_angle) vert4 = GameMath.cil2cart_local(self.vert_mag + self.width / 2, self.vert_angle - delta_angle) self.vertices = [vert1, vert2, vert4, vert3]
def get_max_magnitude(self, angle): delta_angle = math.pi / GameManager.levelCurrentSides p1 = GameMath.cil2cart_local(self.vert_mag + self.width / 2, self.vert_angle - delta_angle) p2 = GameMath.cil2cart_local(self.vert_mag + self.width / 2, self.vert_angle + delta_angle) p3 = (0, 0) p4 = (math.cos(angle), math.sin(angle)) intersection = GameMath.intersection_between_lines(p1, p2, p3, p4) return GameMath.cart2cil_local(intersection[0], intersection[1])[0]
def get_initial_verts(self): verts = [] for i in range(6): verts.append( GameMath.cil2cart_local(Settings.MENU_HEXAGON_RADIUS, i * math.pi * 2 / 6)) return verts
def get_polygon_vertices(self, sides): verts = [] delta_angle = 2 * math.pi / sides for i in range(sides): verts.append( GameMath.cil2cart_local(self.polygonSize, i * delta_angle)) return verts
def get_lerped_vertices(self, start_sides, end_sides, t): min_sides = min(start_sides, end_sides) power_to_lerp = Settings.LERP_POW verts = [] start_delta_angle = 2 * math.pi / start_sides end_delta_angle = 2 * math.pi / end_sides current_delta_angle = GameMath.pow_lerp(start_delta_angle, end_delta_angle, t, power_to_lerp) for i in range(min_sides): verts.append( GameMath.cil2cart_local(self.polygonSize, i * current_delta_angle)) for i in range(abs(start_sides - end_sides)): if start_sides > end_sides: extra_end_angle = 2 * math.pi extra_current_delta_angle = GameMath.pow_lerp( start_delta_angle * (i + min_sides), extra_end_angle, t, power_to_lerp) verts.append( GameMath.cil2cart_local(self.polygonSize, extra_current_delta_angle)) else: extra_start_angle = 2 * math.pi extra_current_angle = GameMath.pow_lerp( extra_start_angle, end_delta_angle * (i + min_sides), t, power_to_lerp) verts.append( GameMath.cil2cart_local(self.polygonSize, extra_current_angle)) return verts
def set_vertices(self): min_sides = min(GameManager.levelCurrentSides, GameManager.levelNextSides) start_delta_angle = (2 * math.pi / GameManager.levelCurrentSides) end_delta_angle = (2 * math.pi / GameManager.levelNextSides) current_delta_angle = GameMath.pow_lerp(start_delta_angle, end_delta_angle, GameManager.sideChangePercent, Settings.LERP_POW) vert1 = (0, 0) vert2 = GameMath.cil2cart_local(self.max_screen_size * 2, current_delta_angle * self.index) vert3 = GameMath.cil2cart_local(self.max_screen_size * 2, current_delta_angle * (self.index + 1)) if GameManager.sideChangePercent != 0 and self.index >= min_sides: if GameManager.levelCurrentSides > GameManager.levelNextSides: vert2 = GameMath.cil2cart_local(self.max_screen_size * 2, start_delta_angle * self.index) vert3 = GameMath.cil2cart_local( self.max_screen_size * 2, GameMath.pow_lerp(start_delta_angle * (self.index + 1), 2 * math.pi, GameManager.sideChangePercent, Settings.LERP_POW)) else: vert2 = GameMath.cil2cart_local(self.max_screen_size * 2, end_delta_angle * self.index) vert3 = GameMath.cil2cart_local( self.max_screen_size * 2, GameMath.pow_lerp(2 * math.pi, end_delta_angle * (self.index + 1), GameManager.sideChangePercent, Settings.LERP_POW)) self.vertices = [vert1, vert2, vert3]