forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Flipping an Image

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Hopper



Joined: 27 Mar 2006
Posts: 2

PostPosted: Mon Mar 27, 2006 8:46 pm    Post subject: Flipping an Image Reply with quote

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
View user's profile Send private message
JorDy



Joined: 11 Dec 2005
Posts: 121

PostPosted: Tue Mar 28, 2006 12:54 am    Post subject: Reply with quote

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
View user's profile Send private message
Hopper



Joined: 27 Mar 2006
Posts: 2

PostPosted: Tue Mar 28, 2006 1:20 am    Post subject: Reply with quote

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
View user's profile Send private message
JorDy



Joined: 11 Dec 2005
Posts: 121

PostPosted: Tue Mar 28, 2006 3:07 am    Post subject: Reply with quote

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
View user's profile Send private message
matriculated



Joined: 04 Mar 2006
Posts: 31

PostPosted: Wed Mar 29, 2006 12:35 am    Post subject: Reply with quote

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
View user's profile Send private message
glynnder



Joined: 04 Sep 2005
Posts: 35

PostPosted: Mon Apr 03, 2006 10:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Kameku



Joined: 23 Mar 2006
Posts: 32
Location: Oregon, USA

PostPosted: Tue Apr 04, 2006 4:21 pm    Post subject: Reply with quote

Because then it would be upside-down, too.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Gary13579



Joined: 15 Aug 2005
Posts: 93

PostPosted: Thu Apr 06, 2006 5:43 am    Post subject: Re: Flipping an Image Reply with quote

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
View user's profile Send private message
matriculated



Joined: 04 Mar 2006
Posts: 31

PostPosted: Thu Apr 06, 2006 7:04 am    Post subject: Reply with quote

It would probably be faster to just use preflipped images rather than "rendering them".
Back to top
View user's profile Send private message
DiabloTerrorGF



Joined: 15 Jul 2005
Posts: 64

PostPosted: Thu Apr 06, 2006 10:52 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group