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 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]
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 get_angle(self): angle = (self.posIndex + 0.5) * (math.pi * 2 / GameManager.levelCurrentSides) if GameManager.sideChangePercent != 0: min_sides = min(GameManager.levelCurrentSides, GameManager.levelNextSides) start_angle = (self.posIndex + 0.5) * (math.pi * 2 / GameManager.levelCurrentSides) end_angle = (self.posIndex + 0.5) * (math.pi * 2 / GameManager.levelNextSides) if self.posIndex >= min_sides: if min_sides == GameManager.levelNextSides: end_angle = 2 * math.pi else: start_angle = 2 * math.pi angle = GameMath.pow_lerp(start_angle, end_angle, GameManager.sideChangePercent, Settings.LERP_POW) return angle