Forum Archive

[SOLVED] Player Scale Acting Up

RocketBlaster05

Hello! I have a player where I need to scale them down to properly fit the size I need, and I also need to change their x_scale to make them flip. However If I set the overall scale before the x_scale, it results in the player being stretched outwards horizontally. If I put the overall scale AFTER the x_scale, the character remains small but does not flip directions. Here is the code I am using:

#This is the code that results in the character not flipping directions
#All necessary imports are present
#And yes, this is working off of the built in game tutorial example
def cmp(a, b)
    return ((a > b) - (a < b))

def update_player(self):
    g = gravity()
    if abs(g.x) > 0.05:
        self.player.x_scale = cmp(g.x, 0)
        self.player.scale = (0.1) #scale comes after x_scale
        x = self.player.position.x
        max_speed = 40
        x = max(0, min(self.size.w, x + g.x * max_speed))
        self.player.position = x, 32
        step = int(self.player.position.x / 40) % 2
        if step != self.walk_step:
            self.player.texture = walk_textures[step]
            sound.play_effect('rpg:Footstep00', 0.05, 1.0 + 0.5 * step)
            self.walk_step = step
    else:
        self.player.texture = standing_texture
        self.walk_step = -1

#------------------------------------------------------------

#This is the code that results in the character stretching horizontally
#All necessary imports are present
#And yes, this is working off of the built in game tutorial example
def cmp(a, b)
    return ((a > b) - (a , b))

def update_player(self):
    g = gravity()
    if abs(g.x) > 0.05:
        self.player.scale = (0.1) #scale comes before x_scale
        self.player.x_scale = cmp(g.x, 0)
        x = self.player.position.x
        max_speed = 40
        x = max(0, min(self.size.w, x + g.x * max_speed))
        self.player.position = x, 32
        step = int(self.player.position.x / 40) % 2
        if step != self.walk_step:
            self.player.texture = walk_textures[step]
            sound.play_effect('rpg:Footstep00', 0.05, 1.0 + 0.5 * step)
            self.walk_step = step
    else:
        self.player.texture = standing_texture
        self.walk_step = -1

RocketBlaster05

Nevermind I solved it by dividing the x_scale value by (in my case) 10 and now it works fine.