# Distance problem

Get help using Construct 2

### » Tue Feb 19, 2013 7:31 pm

I think there may be a simple solution to this, either something in C2 or a trigonometry answer (I think one of the basic trig rules covers this but can't remember it).

I have two points that I wish to know the distance between, but all I know is their start location (the centre of the screen), their angle and their distance from that point. Since I want my screen to be stretched, I can't used C2's built-in distance function.

So I guess if I know one corner of a triangle and the length and angle of the two sides coming from that point, is it possible to work out the distance between the two other points?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

### » Tue Feb 19, 2013 10:11 pm

There is, and you don't need any trig for it. This will tell you the distance in pixels:

distance(sprite1.x, sprite1.y, sprite2.x, sprite2.y)

https://www.scirra.com/manual/126/system-expressions
B
7
Posts: 38
Reputation: 476

### » Tue Feb 19, 2013 11:22 pm

It probably sounded like I know the locations of my sprites, but I don't. I'm placing them by moving them both a certain distance from the same location, but the screen can be stretched so I need to know the distance between them regardless of screen size.

So basically I know the point of a triangle, and the 2 angles and sides coming from that point. I'm trying to then calculate the length of the third side.
B
25
S
5
G
3
Posts: 446
Reputation: 5,633