Mugen DEV Forum


  Reply to this topicStart new topicStart Poll

> Angle between player and EnemyNear(0)
SMI
  Posted: Feb 4 2004, 09:42 PM
Report PostQuote Post


Member
**

Group: Members
Posts: 62
Member No.: 111
Joined: 14-September 02



Okay, okay, okay. After a few minutes smacking my head against the wall, I gotta this code to calculate the angle between player and EnemyNear(0):
(Btw, I'm giving away a code to calculate absolute distance between player and EnemyNear(0) with it :P)

[State -3, Distance Between Player and the Nearest enemy]
Type = VarSet
trigger1 = 1
fvar(10) = Exp(0.5*ln((((EnemyNear(0), Pos X) - (Pos X)) * (( EnemyNear(0), Pos X) - (Pos X)) + ((EnemyNear(0), Pos Y - Pos Y) * (EnemyNear(0), Pos Y - Pos Y)))))

[State -3, M]
Type = VarSet
trigger1 = EnemyNear(0), Pos X != Pos X
fvar(11) = -((EnemyNear(0), Pos Y - Pos Y)/(EnemyNear(0), Pos X - Pos X))

[State -3, M] ;There can be no triangle if both points share the same X cord
Type = VarSet
trigger1 = EnemyNear(0), Pos X = Pos X
fvar(11) = 0

[State -3, Angle]
Type = VarSet
trigger1 = 1
fvar(12) = Atan(fvar(11)) * (180.0/Pi) ;Angle given in degrees.

And that was "Yet another code no one will use, nor will give a damn" brought to you by SMEE.

Have fun.

Edit: Removed the ABS in the M formula and fixed the inverted cartesian plan that mugen uses by multipling M by -1.

This post has been edited by SMI on Feb 4 2004, 09:52 PM


--------------------
[murray voice]
I'm a powerful demonic force!
I'm the harbinger of your doom!
And the forces of darkness will applaud me as I stride through the gates of hell carrying your head on a pike!
[/murray voice]
Mini ProfilePMEmail PosterUsers Website
Top

Topic Options Reply to this topicStart new topicStart Poll

 


- M.U.G.E.N Development Forum - Contact an admin - ELECBYTE - Shin Mugen -