# Reverse a Sprite without editing?

**URL:** https://discourse.processing.org/t/reverse-a-sprite-without-editing/7444
**Category:** Processing.py
**Created:** [January 12, 2019, 5:16pm UTC](https://discourse.processing.org/t/reverse-a-sprite-without-editing/7444 "2019-01-12T17:16:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)
#### Post date: [January 12, 2019, 5:16pm UTC](https://discourse.processing.org/t/reverse-a-sprite-without-editing/7444/1 "2019-01-12T17:16:11Z")

</div>

I have sprite animation of a player walking to right direction, but not to left.  
Do I have to edit all the sprites?

(Credits to [MInd Chamber](https://opengameart.org/content/defector))

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [January 12, 2019, 5:29pm UTC](https://discourse.processing.org/t/reverse-a-sprite-without-editing/7444/2 "2019-01-12T17:29:58Z")

</div>

> [@\[SOLVED\] Question about flipping Images](https://discourse.processing.org/t/question-about-flipping-images-edit-solved/7391):
>
> How do you go ahead and flip an array of images in processing? Im trying to make a game where the character runs left and right but i only have the pictures for him to run right,

[https://www.reddit.com/r/processing/comments/aexm5u/how\_to\_flip\_an\_image\_on\_processing/](https://www.reddit.com/r/processing/comments/aexm5u/how_to_flip_an_image_on_processing/)

---

<div class="post-metadata">

### Author: ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)
#### Post date: [January 13, 2019, 5:43pm UTC](https://discourse.processing.org/t/reverse-a-sprite-without-editing/7444/3 "2019-01-13T17:43:05Z")

</div>

Considering that you draw your sprite of a character walking to the right using

```auto
image(sprite, x, y)

```

You could also use this to get exactly the same result

```auto
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:

```auto
image(sprite, x+sprite.width, y, -sprite.width, sprite.height)

```

So, then you could also make a function just for the direction:

```auto
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.

---

<div class="post-metadata">

### Author: ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)
#### Post date: [January 13, 2019, 7:26pm UTC](https://discourse.processing.org/t/reverse-a-sprite-without-editing/7444/4 "2019-01-13T19:26:21Z")

</div>

maybe its a stupid question, but  
this way I improve performance right?

---

<div class="post-metadata">

### Author: ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)
#### Post date: [January 13, 2019, 7:59pm UTC](https://discourse.processing.org/t/reverse-a-sprite-without-editing/7444/5 "2019-01-13T19:59:10Z")

</div>

Well, it matters on what you mean by performance.  
Maybe making copies of your sprites mirrored would make it run just a tiny bit better because it wouldn’t have to scale anything and would be able to just copy it onto the screen as-is - but that would also obviously eat up some more RAM, and would be harder to manage than just straight up drawing the sprite mirrored.
