# Course Distance Formula

Get help using Construct 2

### » Thu Aug 08, 2013 1:26 am

Since i am not a math dude, i am having trouble getting this visual position indicator done. The funny thing is i done this before back in a old old game of mine, but i forgot how i did it. Let me know if i fully explained my problem well.

On my gui, i have an icon that represents the player, and a line image representing the length of the level's course. So i am trying to figure out what formula to put in the x position of the player's icon, so the icon updates its x position along the length of the line image, based on the length of the course divided by the width of the line image.

-The course variable caps at 264,000, which is how long the course is.
this variable starts at zero, and every tick +1 is added to it until it reaches the maximum cap.

-The line image is 320 pixels in width.

-The player icon is 8 pixels in width. It start on the left and should end at the right side of the line image.

Any math dudes mind cracking this one? Thanks.
B
50
S
12
G
7
Posts: 274
Reputation: 8,201

### » Thu Aug 08, 2013 1:58 am

Well, it appears i solved it by sort of remembering and luck. 8P

Here is how i did it, if your interested. pdistance is the 264,000 variable i was talking about

Set the player's icon x position to; imageline.x(pdistance/304)/3

I dunno if i would have to adjust for different sizes, but it worked.
B
50
S
12
G
7
Posts: 274
Reputation: 8,201