Re: DT in BGT

So, life has finally returned to normal after a ton of stress, and I've picked up this project again.  I figured out how to get theta to calculate correctly.  What I can't figure out is how to get the ball to travel in the correct direction based on degrees.  Degrees and theta show as correct, but the ball doesn't travel at the correct angle.  I thought that using cosine(theta) for x and sine(theta) for y would accomplish this, but it does not.  What I want to happen is for the ball to travel at whatever degree angle I choose.  If I set degrees to 45, that would be 1 on each axis.  If I set degrees to 60, it would be slightly more on the y axis, but travelling on x as well.  Just not sure how to get the ball to travel based on the degrees I choose.   Relevant code:
in math:
//velocity vector
vector vel((acc/M2)*cosine(theta), (acc.y/M2)*sine(theta), -9.81);
//to calculate theta from degrees:
double DTR(double deg)
{
return theta = deg*pi/180;
}
In move code within ball class:
//position vector before movement:
vector pos(0, 0, 0);
//move the ball:
pos += vel*DT;
The ball does move.  I put in tests to check if degrees and radians were calculated correctly when the degrees change, and they are.  But no matter what I set degrees to, the ball only moves along x.  This doesn't make any sense to me.  Unless I am misunderstanding what I read, calculating direction is done with atan2.  But we don't have atan2 in BGT, at least not that I saw, so not sure how to accomplish it.  I'm confused.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : JLove via Audiogames-reflector

Reply via email to