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 8792705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:01:01+00:00 2026-06-13T23:01:01+00:00

So, I’ve been making a small demo program in java using opengl just as

  • 0

So, I’ve been making a small demo program in java using opengl just as an exercise. All was going well until I implemented getTime(); and getDelta(); functions to calculate how much time each frame takes. I then applied it to all my movement calculations by multiplying their speed with getDelta(); and it works well, only that when frames randomly slightly drop and getDelta(); returns a slightly larger value, my calculations start outputting really weird values which are still in the range of the movement the calculation calculates but incorrect, that happens for a few frames until the framerate goes up to normal (250FPS in this case) and the movement continues normally and even from the exact position. I have no idea what could cause this since the getDelta(); seems to function properly?

Heres some code:

private void movementCalculations(double delta) {

    sinInc += 0.0015;
    sinInc2 += 0.010;

    xMove[0] = xSpeed * (float) Math.sin(Math.toDegrees(sinInc / 100 * delta)) * 7500;
    yMove[0] = ySpeed * (float) Math.sin(Math.toDegrees(sinInc / 200 * Math.PI * delta)) * 2500;
    zMove[0] = zSpeed * (float) Math.sin(Math.toDegrees(sinInc / 200 * delta)) * 1250;

    for (int i = 1; i<16; i++) {
        xMove[i] = xSpeed * (float) Math.sin(sinInc2 / 128 * Math.PI * i/2 * delta) * WIDTH * 16;
        yMove[i] = ySpeed * (float) Math.sin(sinInc2 / 64 * Math.PI * i * delta) * HEIGHT * 4;
    }

    xMove[16] = xSpeed * (float) Math.sin(sinInc2 / 64 * Math.PI * 2 * delta) * WIDTH * 8;
    yMove[16] = ySpeed * (float) Math.sin(sinInc2 / 32 * Math.PI * 2 * delta) * HEIGHT * 4;

    xMove[17] = xSpeed * (float) Math.sin(sinInc2 / 32 * Math.PI * 2 * delta) * HEIGHT * 10;
}

In the following debug output, Delta 4.0 is the normal value for 250FPS, then FPS drops and suddenly xMove[17] returns a nearly as large but NEGATIVE value?


Last frame in milliseconds: 231884072
Delta: 4.0
xMove[17]: 164.297
Last frame in milliseconds: 231884077
Delta: 5.0
xMove[17]: -160.83817
Last frame in milliseconds: 231884080
Delta: 3.0
xMove[17]: -0.7198944
Last frame in milliseconds: 231884084
Delta: 4.0
xMove[17]: 162.12277

And if not that’s enough, here’s a working JAR exectuable of the application which has everything for running it inside the JAR so you can see yourself:
http://harha.us.to/files/files_public/Starfield_Exe.jar

I just can’t figure out what’s wrong or is there even anything wrong in my code at all?

  • 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-06-13T23:01:02+00:00Added an answer on June 13, 2026 at 11:01 pm

    You’re currently multiplying sinInc and sinInc2 with delta, so what’s framerate-independent is the… rotation speed?

    You probably want to multiply the movement speeds ({x|y|z}Speed), though it’s hard to be sure.

    You should start by moving the delta multiplication up to the common factor instead of pasting * delta everywhere.

    sinInc += (0.0015 * delta);
    

    will make it clear that the sine increase will be framerate-independent, .0015 units per unit time.

    As for movement, I suspect you’re doing someXCoordinate[i] += xMove[i] somewhere. If so, then that’s the place to put delta:

    obj.xPosition += (obj.xVelocity * delta);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a small JavaScript validation script that validates inputs based on Regex. I

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.