i thought about this after i posted it here is the code in use but in darkbasic format
sync on
synce rate 0
an=10
tx#=320
ty#=240
x#=320
y#=240
do
cls
text 1,1,"true angle "+str$(an)
text 1,20,"Difference between x''s "+str$(newx#)
text 1,40,"Difference between y''s "+str$(newy#)
text 1,60,"My angle "+str$(angle#)
x1#=0+cos(an)*50
y1#=240+sin(an)*50
dx#=x#-mousex()
dy#=y#-mousey()
angle#=int(ca(dx#,dy#))
line x#,y#,mousex(),mousey()
if leftkey()=1 then an=wrapvalue(an-1)
if rightkey()=1 then an=wrapvalue(an+1)
sync
loop
function ca(dx#,dy#)
quadflag=0
if dx#<0 then dx#=dx#*-1 : inc quadflag
if dy# < 0 then dy#=dy#*-1 : quadflag= quadflag+2
if dx# <> 0
angle#=ATAN(dy#/dx#)
else
angle#=ATAN(dy#)
endif
if quadflag=1 then angle# = 180-angle#
if quadflag=2 then angle# = 360-angle#
if quadflag=3 then angle# = 180+angle#
if angle# > 0 then angle# =angle# +.50
angle#=wrapvalue(angle#+180)
endfunction angle#
Please some one help me with orientation !!!
i forgot to mention darkbasic uses degrees not rads
sorry for the confusion.

http://www.lectersoft.com
Thanks a lot guys
with your help, and some little thinking i was able to figure it out
... you guys rock ...
dfawcett Thanks a lot man for the professional explaination ... WOW! i never thought anyone can be this much helpful and supportive ...
Thanks a million rodzilla and daher ... i appricate everything you wrote
again you guys rock
here is how it finally worked for me ...
float dx = wx_pos - player.wx_pos;
float dy = wy_pos - player.wy_pos;
int quadflag=0;
if (dx < 0)
{
dx = dx * -1;
quadflag ++;
}
if (dy < 0)
{
dy = dy * -1;
quadflag += 2;
}
if (quadflag == 0)
{
cTanksceneroty = RAD2DEG * atan2(dx,dy);
cTanksceneroty = 180 + cTanksceneroty;
}
if (quadflag == 1)
{
cTanksceneroty = RAD2DEG * atan2(dy,dx);
cTanksceneroty = 90 + cTanksceneroty;
}
if (quadflag == 2)
{
cTanksceneroty = RAD2DEG * atan2(dy,dx);
cTanksceneroty = 270 + cTanksceneroty;
}
if (quadflag == 3)
{
cTanksceneroty = RAD2DEG * atan2(dx,dy);
cTanksceneroty = cTanksceneroty;
}
glRotatef(cTanksceneroty,0,1.0f,0);


dfawcett Thanks a lot man for the professional explaination ... WOW! i never thought anyone can be this much helpful and supportive ...
Thanks a million rodzilla and daher ... i appricate everything you wrote

again you guys rock

here is how it finally worked for me ...
float dx = wx_pos - player.wx_pos;
float dy = wy_pos - player.wy_pos;
int quadflag=0;
if (dx < 0)
{
dx = dx * -1;
quadflag ++;
}
if (dy < 0)
{
dy = dy * -1;
quadflag += 2;
}
if (quadflag == 0)
{
cTanksceneroty = RAD2DEG * atan2(dx,dy);
cTanksceneroty = 180 + cTanksceneroty;
}
if (quadflag == 1)
{
cTanksceneroty = RAD2DEG * atan2(dy,dx);
cTanksceneroty = 90 + cTanksceneroty;
}
if (quadflag == 2)
{
cTanksceneroty = RAD2DEG * atan2(dy,dx);
cTanksceneroty = 270 + cTanksceneroty;
}
if (quadflag == 3)
{
cTanksceneroty = RAD2DEG * atan2(dx,dy);
cTanksceneroty = cTanksceneroty;
}
glRotatef(cTanksceneroty,0,1.0f,0);
"If you don''t like something, change it. If you can''t change it, change the way you think about it!""He who asks is a fool for five minutes, but he who does not ask remains a fool forever.""Imagination is more important than knowledge, for knowledge is limited while imagination embraces the entire world."(Einstein)"The normal teacher tells. The good teacher explains. The superior teacher demonstrates. The great teacher inspires."(William Arthur Ward)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement