Eclipse program runs faster than after it is exported

117 views Asked by At

Problem: I have a program that involves moving a bar (like in brick break) from side to side. The issue is that it moves at a different speed when running inside Eclipse than it does exported to the desktop.

Research:

When reading this it makes me think that I might not be creating my delta value correctly which could explain why it runs at different speeds. my computer is carrying out java programs which i have created to fast [closed]

After reading this post I found that maybe the Eclipse compiler is just faster which can cause the difference in speeds. Application runs faster in eclipse

    // run() is being ran with a while(true) game loop
    public void run(Input input)
    {
         init();
         // Ran at 60 FPS
         if(fps.tick())
              render();
         // Ran as fast as possible
         update(input);
    }

    private void render()
    {
         start = System.nanoTime();     

         if(render.getGraphics() != null)
         {
             Graphics g = render.getBS().getDrawGraphics();
             g.drawImage(new BufferedImage(Reference.WIDTH*Reference.SCALE, Reference.HEIGHT*Reference.SCALE, 
                BufferedImage.TYPE_INT_RGB), 0,0, AppGameContainer.canvas);
             activeState.render(render.getGraphics(), AppGameContainer.canvas);
             render.getGraphics().dispose();
             render.getBS().show();
         }
         end = System.nanoTime();

         // Time in ms
         delta =  (end-start)/1000000.0;
    }

I have a video if interested for a visual representation of the problem: Video of issue

1

There are 1 answers

0
user1953222 On
    // run() is being ran with a while(true) game loop
    public void run(Input input)
    {
         start = System.nanoTime();
         init();
         // Ran at 60 FPS
         if(fps.tick())
              render();
         // Ran as fast as possible
         update(input);
         end = System.nanoTime();

         // Time in ms
         delta =  (end-start)/1000000.0;
    }

    private void render()
    {       
         if(render.getGraphics() != null)
         {
             Graphics g = render.getBS().getDrawGraphics();
             g.drawImage(new BufferedImage(Reference.WIDTH*Reference.SCALE, Reference.HEIGHT*Reference.SCALE, 
                BufferedImage.TYPE_INT_RGB), 0,0, AppGameContainer.canvas);
             activeState.render(render.getGraphics(), AppGameContainer.canvas);
             render.getGraphics().dispose();
             render.getBS().show();
         }
    }