The Daily Click ::. Forums ::. Klik Coding Help ::. Arc Tangent
 

Post Reply  Post Oekaki 
 

Posted By Message

Ganymede Graphics

Possibly Insane

Registered
  17/04/2006
Points
  2711

GOTW JANUARY 2011
24th April, 2008 at 00:07:03 -

I am pretty certain i'm right in thinking that this kind of code is meant to retrieve a direction which points towards a given object:
{
//The mouse is the object we're pointing at

-always
+anglevalue=ArcTan(ydistancevalue/istancevalue)
+istancevalue=xmouse-x(active)
+ydistancevalue=ymouse-y(active)
}
This is simply following an idea behind a method of finding the angle between two points on a linear set of cartesian co-ordiantes. If you get yourself a scientific calculator and type in the values in the code, you can retrieve the angle between two spots by using Arc Tangent and the points x and y positions.
The clickteam software doesn't want to behave the same way. I find that when I use this code the andgle angle value comes out very obsurely. Roughly between the angles 80-110, 250-290 (the angles being between the active object and the mouse) I retrieve something which looks roughly like a proper value. Anything outside those appoximate values are either rounded to a pretty random value, or are 0.
I'm thinking its going to be pretty hard for someone to find a solution, but if anyone else actually works with clickteam products and much raw trig, could they give me an idea into why this could be happening?

Much appreciation for any help.



 
Especially that.

Ganymede Graphics

Possibly Insane

Registered
  17/04/2006
Points
  2711

GOTW JANUARY 2011
24th April, 2008 at 00:08:41 -

._." those smiles are supposed to be 'd'

 
Especially that.

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
24th April, 2008 at 05:27:37 -

its because clickteam doesnt like to use floating point numbers. those bastards.

use an extension to do it. advanced direction object (gets you your angle easy) or advanced math object (lets you set the decimal offset and use maths)

 
n/a

Ganymede Graphics

Possibly Insane

Registered
  17/04/2006
Points
  2711

GOTW JANUARY 2011
18th May, 2008 at 01:34:39 -

gah! bah! silly peoples -_-

why would there even be an atan function if it doesn't bloody work >.>



 
Especially that.

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
18th May, 2008 at 02:07:43 -

Yah, you'll need the advanced math object and some mathematical trickery to work around it. Just assume that your numbers are being rounded to integers at every single possible operation in each expression.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
18th May, 2008 at 06:24:59 -

The trouble with atan is that it will only return one value, where in actual fact there are several.

Let me draw you an example.

Say you're returning the angle between Object A and Mouse.

Object A is your point of origin.

All distances are calculated using Mouse(X,Y) - Object A(X,Y) but beware, A and B labels change with direction.

if Mouse (X,Y) is > than Object (X,Y) this will happen:

Image

Both A and B should be Positive.

If Mouse (X) is < than object (X), but Mouse > than object this will happen:

Image

(A should be positive, B should be negative, up/right are positive directions, down/left are negative)

If Mouse (X,Y) is < than object (X,Y) this will happen:

Image

Both A and B are negative. You can also do 270 - the atan result.

If Mouse (X) > Object (X) but Mouse < object this will happen:

Image

A is negative, B is positive.

So as you can see, it'd be easier using an object that does these chekcs for you, rather than doing them yourself.


 
My signature is never too big!!!

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
18th May, 2008 at 06:42:37 -

Thank you for taking the time and effort to post that Joe.H. It's a fair bit of work to post pictures and explain

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
18th May, 2008 at 07:21:00 -

I had nothing else to do

 
My signature is never too big!!!
   

Post Reply



 



Advertisement

Worth A Click