Don't forget to read the rules of the forum. No current release restrictions. | Help Search Members Calendar

Logged in as: The Dreamslayer ( Log Out ) | My Controls · 0 New Messages · View New Posts · My Assistant

Mugen DEV Forum -> Development and Help Forums -> Development Discussion

Angle between player and EnemyNear(0)
Track this topic | Email this topic | Print this topic

SMI | Posted: Feb 4 2004, 09:42 PM
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]

« Next Oldest | Development Discussion | Next Newest »

Close Topic Options
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
- M.U.G.E.N Development Forum - Contact an admin - ELECBYTE - Shin Mugen -
Powered by Invision Power Board(U) v1.2 © 2003 IPS, Inc.