PDA

View Full Version : Converting to Angular



Gleeok
04-10-2008, 02:20 AM
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?

jman2050
04-10-2008, 04:16 PM
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.