Flipping an Image

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Hopper
Posts: 2
Joined: Mon Mar 27, 2006 8:42 pm

Flipping an Image

Post by Hopper »

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)
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post by JorDy »

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
Hopper
Posts: 2
Joined: Mon Mar 27, 2006 8:42 pm

Post by Hopper »

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.
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post by JorDy »

well im pretty sure there is no way of flipping an image otherwise most games i have seen would have used it
matriculated
Posts: 31
Joined: Sat Mar 04, 2006 1:35 am

Post by matriculated »

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!
glynnder
Posts: 35
Joined: Sun Sep 04, 2005 9:54 pm

Post by glynnder »

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?
Kameku
Posts: 32
Joined: Thu Mar 23, 2006 12:17 pm
Location: Oregon, USA

Post by Kameku »

Because then it would be upside-down, too.
Gary13579
Posts: 93
Joined: Mon Aug 15, 2005 7:43 am

Re: Flipping an Image

Post by Gary13579 »

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 :)
matriculated
Posts: 31
Joined: Sat Mar 04, 2006 1:35 am

Post by matriculated »

It would probably be faster to just use preflipped images rather than "rendering them".
DiabloTerrorGF
Posts: 64
Joined: Fri Jul 15, 2005 11:44 pm

Post by DiabloTerrorGF »

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.
Post Reply