Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Converting to Angular

1 replies · 890 views · Started 10 April 2008

In the past i've been using this code to fire ffc projectiles directly at Link. Since Angular doesn't rely on Vx and Vy I'm having to rethink some of the code so it works with eweapons.

I'm having trouble finding a formula that would convert x,y to angles, or even rewriting it completely and would appreciate some help.

		int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
shuriken1->Vx = dx/norm*speed;
shuriken1->Vy = dy/norm*speed;
}

And...What I've been using for angles:

eweapon->Angle = deg*(PI/180);

Edit: Aaaahh! I think I just broke my brain. 😞 Any chance in posted the built in zc fireball code?

No, you pretty much have the angle variable done right. To modify velocity just change the Step variable.

EDIT - Sorry, misunderstood the question. Actually, what you need to do what you want to is an arctan function, which hasn't been added to ZScript yet. Next build, I promise.