Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:17:23+00:00 2026-05-25T14:17:23+00:00

I am messing around with some Javascript game development, trying to create a simple

  • 0

I am messing around with some Javascript game development, trying to create a simple Framework for drawing a playing field (for a sports game).

I am horrible at math and really need help with this algorithm.

Say I have these variables:

GAME_WIDTH = 1024;  
FIELD_LENGTH = 170;  
PLAYER_SPEED = 4.72;  
update_duration = 30;  

The first 3 in caps are variable, meaning they can be set by the user. The last is essentially how often my “update” code is called in 1 second.

GAME_WIDTH is pixels, FIELD_LENGTH is meters, PLAYER_SPEED is how many seconds a player can cover 40 meters.

What I want to do, is take those 4 variables and translate that into how many pixels a player can move in 1 “update”. I have never really done any Game Development and I never payed attention to Geometry or Trigonometry in school so I am completely at a loss here.
Can anyone help?

EDIT
This is a 2D top-down game so this algorithm is only dealing with X (right-to-left) coordinates.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:17:24+00:00Added an answer on May 25, 2026 at 2:17 pm

    You need to embrace the fine art of “Units Conversion”.
    http://oakroadsystems.com/math/convert.htm

    For example, 12 inches = 1 foot. So you can convert inches to feet like so:

    48 inches * (1 foot / 12 inches) = 4 feet. The “inches” cancel out, leaving just feet.

    So the answer we want is pixels per update. (Is update_duration in milliseconds? assuming so…)

    (40 meters / 4.72 seconds) 
     * (1024 pixels / 170 meters) 
     * (1 second / 1000 ms) 
     * (30 ms / 1 update) = 1.53140578 pixels / update
    

    or if the 30 is updates/second, same idea:

      (40 meters / 4.72 seconds) 
       * (1024 pixels / 170 meters) 
       * (1 second / 30 updates = 1.70156198 pixels / update
    

    (I may have misinterpreted the meaning of your constants… but that’s the technique. The concept is that each of those fractions, a / b, is equivalent to “1”.

    This looks better when you write it in full classroom fraction style, all the canceling becomes chalkboard-perfect. Very useful technique to embrace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just messing around with some C++ at the moment trying to make a
Messing around with some CSS trying to learn some stuff as I haven't done
I am messing around in Node.js trying to replicate that simple chat server that
I'm messing around with some C code using floats, and I'm getting 1.#INF00, -1.#IND00
I am currently messing around with some stuff for an idea for a site
I'm messing around with some windows functions using p/invoke. Occasionally, I get an error
The situation is that I've spent some time messing around with some experimental code.
I have finally started messing around with creating some apps that work with RESTful
I have been messing around with writing some stored procedures in .NET code with
I'm trying clear the value of a lookup field via Javascript. I've tried this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.