| View previous topic :: View next topic |
| Author |
Message |
Hopper
Joined: 27 Mar 2006 Posts: 2
|
Posted: Mon Mar 27, 2006 8:46 pm Post subject: Flipping an Image |
|
|
I searched but couldn't find any help.
What i'm doing is a 2D fighting game. i have all my sprites but they all face right. i need to start the game with on of the sprite flipped and facing left(so both sprites are facing center) but i dont know how?
is it something i need to do while blitting the images?
thanks for any help=]
what i have been using is
screen:blit(150,120,image, 0,0,image:width() * - 1, image:height(), true) |
|
| Back to top |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Tue Mar 28, 2006 12:54 am Post subject: |
|
|
| im not sure but in aplications like photsop you can flip your images edit>rotate or something like that but flip it vertically i think. you can even do it in ms word |
|
| Back to top |
|
 |
Hopper
Joined: 27 Mar 2006 Posts: 2
|
Posted: Tue Mar 28, 2006 1:20 am Post subject: |
|
|
thanks but that's cheating!!
i know most places i've looked they use a different image but that's annoying and if i already have 50sprites for one character i'll have 100 your way and that's more code and more space taken up. |
|
| Back to top |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Tue Mar 28, 2006 3:07 am Post subject: |
|
|
| well im pretty sure there is no way of flipping an image otherwise most games i have seen would have used it |
|
| Back to top |
|
 |
matriculated
Joined: 04 Mar 2006 Posts: 31
|
Posted: Wed Mar 29, 2006 12:35 am Post subject: |
|
|
| It's possible to flip images but it would be quite slow using Lua. Basically you would create an empty image with the same dimensions as your img. The use the image:pixel(x, y) function to check the color of the pixel in an img but instead of using x you would use img.width - x. You would have to do this over the enitre img! |
|
| Back to top |
|
 |
glynnder
Joined: 04 Sep 2005 Posts: 35
|
Posted: Mon Apr 03, 2006 10:14 pm Post subject: |
|
|
hmmm at one point im sure i found some code to flip and image...
Why dont u just use the rotate code and rotate it 180 degrees? |
|
| Back to top |
|
 |
Kameku
Joined: 23 Mar 2006 Posts: 32 Location: Oregon, USA
|
Posted: Tue Apr 04, 2006 4:21 pm Post subject: |
|
|
| Because then it would be upside-down, too. |
|
| Back to top |
|
 |
Gary13579
Joined: 15 Aug 2005 Posts: 93
|
Posted: Thu Apr 06, 2006 5:43 am Post subject: Re: Flipping an Image |
|
|
| Hopper wrote: | I searched but couldn't find any help.
What i'm doing is a 2D fighting game. i have all my sprites but they all face right. i need to start the game with on of the sprite flipped and facing left(so both sprites are facing center) but i dont know how?
is it something i need to do while blitting the images?
thanks for any help=]
what i have been using is
screen:blit(150,120,image, 0,0,image:width() * - 1, image:height(), true) |
It's ugly, and will use more RAM, load times will be longer, but this should work.
Create a new image the same size as the image you want to flip.
Use a for loop from 0 to the image height, then one from 0 to the width.
Then do what matriculated said, but instead of blitting it to the screen, blit it to the new image.
Like I said, it's going to use twice the RAM, and images in luaplayer take up quite a bit of RAM (one full screen picture = ~1MB).
I really suggest learning C and taking luaplayer's graphics.c, or possibly using the OldSchool library. It has a function built in to flip images (but I won't use it because it's not open source :().
Edit: I just realized matriculated said the exact same thing I did.. oh well, still look into the C thing :) |
|
| Back to top |
|
 |
matriculated
Joined: 04 Mar 2006 Posts: 31
|
Posted: Thu Apr 06, 2006 7:04 am Post subject: |
|
|
| It would probably be faster to just use preflipped images rather than "rendering them". |
|
| Back to top |
|
 |
DiabloTerrorGF
Joined: 15 Jul 2005 Posts: 64
|
Posted: Thu Apr 06, 2006 10:52 am Post subject: |
|
|
| matriculated wrote: | | It would probably be faster to just use preflipped images rather than "rendering them". |
Well, it depends on what you need more.
If you need the MS space, you would render. If you need less start-up time, you would pre-render. |
|
| Back to top |
|
 |
|