GP32 Rotation


nerd of nerds

w00t!!!!
Joined
Feb 25, 2003
Messages
838
ok, so say i have an image that i blitted onto the screen from another C file that was converted using the gpconverter program... is there any way i can rotate it? preferably simple...code samples are VERY welcome ;)
 
how do i do the sine whatnot with the gp32 sdk? iirc it didn't have that and joo had to use a table... anyone know how to use that and where to get it?
 
sin() and cos() are part of math.h, you need to include it.

They are not very fast, and they use floating point, so you want to use them as little as possible. Some games choose to precalculate sin and cos into a lookup table, this is not a bad way to go if you want to restrict your possible rotations to a fixed amount.

There is an include file I use called math-sll.h, which is a fixed point alternative to the floating poing math.h, but it's not really something you should look into until you have got the basics down.
 
hmmm, well, thats what i get for being a tard...umberrasment...wow...ok kewl...

would it be ok to use these for a gta like clone where the cars would rotate? like, 5 cars onscreen rotating at the same time? or would that slow it down a lot...
 
As far as I know they are slower than a sqrt, but I think 5 or 6 times a frame would be totally fine. As long as you cull the calculation for cars that are offscreen.. Then that opens up a whole can of worms as to how you are going to update the position of the offscreen cars if you aren't going to do the anglular calculations for them.
 
well, couldn't i just have the cars set to x and y and not be rotated?just have thembe sitting there and when they are "on camera" "activate" them? or, like, 50 pixels from the camera, to make it look more real...
 
ok, thank you VERY much for your help...i got a program to compile that was supposed to do the circle of dots thing, but it didn't... i have tried several times and changed a TON of stuff to try and get those damn dots to appear... but nothing...

here is what i have....

#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "math.h"
void GpMain(void *arg)
{
int i;
int x, y;
int length = 50;
float angle = 0.0;
float angle_stepsize = 0.1;

GPDRAWSURFACE gpDraw;


i = GpLcdSurfaceGet(&gpDraw, 0);



GpSurfaceSet(&gpDraw);

if ( !(GPC_LCD_ON_BIT & GpLcdStatusGet()) )
GpLcdEnable();



while (angle < 2 * 3.14159265)
{
x = length * sin (angle);
y = length * cos (angle);

GpPointSet(&gpDraw,x, y, 100);

angle += angle_stepsize;



while(1);
}
}
 
I have some simple sprite scaling and rotation code for GP32.. I could post a link to when I manage to locate it <_<
 
I can't get this to work. Annoys me to death. I added the -lm switch in the gp32.mk file, i included math.h but still it acts really odd.

I doesn't display a circle instead i get this:
http://www.grapefrukt.com/dump/gp32_trig.gif
(skipped clearing the buffer to show how it moves)

My code looks like this:
http://www.grapefrukt.com/dump/gp32_trig_code.gif

(if you wanna try it on your own the code is here:)
http://www.grapefrukt.com/dump/gp32_trig_code.rar

It compiles without errors, and everything seems to be fine. But still, no luck.

So, please help.
 
hmmmm... maybe mine works becuase i use ADS... but, i can't wait until we get mr.spivs stuff... i want to make a crime-em-up game...

ok, it think i know what the prob is:

x = length * sin (angle) + 160;
y = length * cos (angle) + 120;

should be:
x = length * sin (angle);
y = length * cos (angle);

and if you want to center it then just to this:
GpPointSet(&gpDraw, x + 160, y + 120, 100);
 
mr.spiv posted on Mar 10 2004 at 07:49 AM said:
I have some simple sprite scaling and rotation code for GP32.. I could post a link to when I manage to locate it <_<
I guess someone is getting funny lately....
 
Last edited by a moderator:
nerd of nerds posted on Mar 11 2004 at 09:05 PM said:
hmmmm... maybe mine works becuase i use ADS... but, i can't wait until we get mr.spivs stuff... i want to make a crime-em-up game...

ok, it think i know what the prob is:

        x = length * sin (angle) + 160;
        y = length * cos (angle) + 120;

should be:
        x = length * sin (angle);
        y = length * cos (angle);

and if you want to center it then just to this:
GpPointSet(&gpDraw, x + 160, y + 120, 100);
naw, same result, even if i omit the centering part it draws the same rounded square (but only a quarter of it visible on screen due to the non centering).
Neither does changing the length variable make a difference, it just changes the scale of the square.
 
Last edited by a moderator:
synkro posted on Mar 11 2004 at 09:17 PM said:
mr.spiv posted on Mar 10 2004 at 07:49 AM said:
I have some simple sprite scaling and rotation code for GP32.. I could post a link to when I manage to locate it <_<
I guess someone is getting funny lately....
whats that supposed to mean?

@other person with problems...
hmmm, maybe you need a new math.h..
 
Last edited by a moderator:
Arnout posted on Mar 12 2004 at 08:48 AM said:
I have the same problems when using math functions like sin() cos sqrt() they all return 0.

So I use a .h with pre generated sin/cos tables.

BTW, I'm using the devkitadv from Rico's website:
http://www.thaworx.co.uk/ninja/
So am I. Maybe the math.h from that pack is faulty in some way?
 
Last edited by a moderator:
Back
Top