![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on need help with sprite rotation within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hey, I've been gone for a long time because of school and all but I'm trying to get back to ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() |
Hey, I've been gone for a long time because of school and all but I'm trying to get back to developing games. I refreshed my memory by going through the psp-programming tutorials so I'm using the graphics.c file right now and I have a problem. I need a sprite to rotate by the amount of radians I want it to because I'm making it so he will walk in the direction he is facing(assuming you're at a bird's eye view). I can get the movement fine because I know how to use cosf and sinf but I'm not sure how to get the actual sprite to rotate. I want to modify blitAlphaImageToScreen() function to apply a certain rotation in radians to the sprite so obviously I had to add an extra argument.
here is the function with a new argument for rotation in it(but I never used it): Code:
void blitAlphaImageToScreenRot(int sx, int sy, int width, int height, Image* source, int dx, int dy,float rad)
{
if (!initialized) return;
sceKernelDcacheWritebackInvalidateAll();
guStart();
sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, (void*) source->data);
float u = 1.0f / ((float)source->textureWidth);
float v = 1.0f / ((float)source->textureHeight);
sceGuTexScale(u, v);
int j = 0;
while (j < width) {
Vertex* vertices = (Vertex*) sceGuGetMemory(2 * sizeof(Vertex));
int sliceWidth = 64;
if (j + sliceWidth > width) sliceWidth = width - j;
vertices[0].u = (sx + j);
vertices[0].v = (sy);
vertices[0].x = (dx + j);
vertices[0].y = (dy);
vertices[0].z = 0;
vertices[1].u = (sx + j + sliceWidth);
vertices[1].v = (sy + height);
vertices[1].x = (dx + j + sliceWidth);
vertices[1].y = (dy + height);
vertices[1].z = 0;
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
j += sliceWidth;
}
sceGuFinish();
sceGuSync(0, 0);
}
Last edited by pspballer07; 01-27-2009 at 06:15 PM.. |
|
|
|
|
|
#2 |
![]() No longer a community member.
|
Well, to start I advise you to not rotate and strip blit as it causes images to be choppy, second, setup 4 vertices and use a triangle fan. THen from there it is a simple cos/sin to translate the vertices to their proper location. It is just simple trig.
|
|
|
|
|
|
#3 |
![]() |
Thanks, can you write how you would do it into that function and comment whatever you add? I'm in high school and we haven't done that much trig. we just finished with quadratic equations and started trig.
|
|
|
|
|
|
#4 |
![]() ![]() Developer
|
Couldn't you just print with sceGum and rotate with sceGumRotateZ?
Then again I have very little GU experience so it may not be that easy
__________________
Last edited by Xsjado7; 01-27-2009 at 06:45 PM.. |
|
|
|
|
|
#5 | |
![]() |
Quote:
Code:
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices); Code:
sceGumRotateZ(rad); sceGumDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices); |
|
|
|
|
|
|
#6 |
![]() ![]() Bush Programmer
|
Looking at this:
http://community.hackingpsp.com/foru.../ShowPost.aspx would probably give you some idea, because it's based on graphics.c. |
|
|
|
|
|
#8 |
![]() |
I asked you to modify the code I had. and I get straight As so if they haven't taught us something, I try to look it up, but sometimes it's hard to get a good explanation.
|
|
|
|
|
|
#9 |
![]() No longer a community member.
|
|
|
|
|
|
|
#10 | |
![]() |
Quote:
well I already knew all that, I just wasn't sure how to apply it to vertices but it's ok because I'm going to use the lib that you gave me a link to. thanks. |
|
|
|
|
![]() |
| Tags |
| rotation , sprite |
| Thread Tools | |
|
|