howdy~
i’m developing a game based on J2ME which needs sin, cos and tag values but i found no such methods in J2ME, is there any way to do that then ?
howdy~
i’m developing a game based on J2ME which needs sin, cos and tag values but i found no such methods in J2ME, is there any way to do that then ?
if you are programming with cldc1.0 you’re lost. the only workaround is to use hard coded constants like in good ole’
days. i know thats not a big deal but for my experience you need real sin/cos methods in j2me very(!) rarely if you are not programming 3D games.
You can also use sin/cos routines for fixed-point numbers. If you google you will probably find some open source J2ME class with them in.
I looked into this when I started my last game. It was a 2d, so I’m not sure what your requirements are? I ended up doing some odd contortions to make my collision detection logic happen. ShiftFP2D was very handy to do what I needed, but no sign/cos or sqrt.
For distances I ended up keeping all my measurements squared and measuring against values that were also squared. It worked for me.
For cases where I needed to know direction, I ended up using unit vectors and in some cases dot products to calculate facing values. Like I said, not pretty, but it did work.
If you can use cldc 2.0, that would also solve the problems.
Wood
if im with cldc1.1 then how could i achieve exactly sin, cos and tag values ?
regards~
you’r enot lost, you can use:
Float midp Point
http://henson.newmail.ru/j2me/Float.htm
for:
double asin(double x)
double acos(double x)
double atan(double x)
double atan2(double y, double x)
double exp(double x)
double log(double x)
double log10(double x)
double pow(double x, double y)
go to:
http://henson.newmail.ru/j2me/Float11.htm
regards,
Franck