Considering that you draw your sprite of a character walking to the right using
image(sprite, x, y)
You could also use this to get exactly the same result
image(sprite, x, y, sprite.width, sprite.height)
And, you could then simply reverse the horizontal size of the sprite by prepending a minus and then moving it to the right the same amount, to draw that character walking to the left:
image(sprite, x+sprite.width, y, -sprite.width, sprite.height)
So, then you could also make a function just for the direction:
def spriteDirection(sprite, x, y, dir):
if(dir):
image(sprite, x, y)
else:
image(sprite, x+sprite.width, y, -sprite.width, sprite.height)
where dir
is True
if you want the character going to the right, or False
if you want the character going to the left.