Course Distance Formula

0 favourites
  • 2 posts
  • 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. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)