Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (687)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Player sprite just doesnt move smooth?  (Read 21255 times)
0 Members and 1 Guest are viewing this topic.
Offline Addictman

Senior Devvie

Medals: 3
Projects: 1

Java games rock!

« Reply #30 - Posted 2011-05-06 16:59:02 »

My point was that my rendering loop is nothing special whatsoever, except that it uses Thread.yield() instead of Thread.sleep()
Offline princec

« JGO Spiffy Duke »

Medals: 625
Projects: 3
Exp: 16 years

Eh? Who? What? ... Me?

« Reply #31 - Posted 2011-05-06 19:43:52 »

I use yield() these days still. sleep() just too unreliable.

Cas Smiley

Offline Cero
« Reply #32 - Posted 2011-06-04 10:35:06 »

I never ever used .sleep(), always .yield()

and its just not a code issue: this behavior only occurs on the DirectX pipeline. Using the OpenGL pipeline forces even a windowed game to VSync when using bufferedstrategy.
in that case, when using opengl, I obviously don't even need my game slow down class; since its automatically vsynced.

no screentearing ever on opengl. obviously that pipeline has so many problems...

this is my experience with java2D + pipelines... my engine is switching to lwjgl soon; I hope it will be gone alltogether.

here is how I do the slow down: (btw Awt.Toolkit.sync() results in abysmal slowdowns)

public class FrameSkipper
    private int fps;
    private long timeThen;

    public FrameSkipper(int frameRate)
        fps = frameRate;
        timeThen = System.nanoTime();

    public void changeFPS(int frameRate)
        fps = frameRate;

    public void sync()
        long gapTo = 1000000000L / fps + timeThen;
        long timeNow = System.nanoTime();

        while (gapTo > timeNow)
            timeNow = System.nanoTime();

        timeThen = timeNow;

so you initialize with the FPS you want, and then just call sync every frame.

also note: I currently do not use any threads; I would like to maintain a frame based synced game, which should be entirely possible (like your standard C++ game)

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Swattkidd7

Junior Devvie

Exp: 8 years

« Reply #33 - Posted 2011-08-04 11:36:20 »

If ten more persons come and claim they can animate a moving circle/rectangle without stuttering... I think I have to believe it. Why it is so complicated just to prove it and give a minimal example so that we all can learn from the rendering loop?
Doesn't seem to be that simple...

I would love to see this also.

old thread but still a problem.
Offline Rejechted

Senior Devvie

Medals: 2
Projects: 2

Just a guy making some indie games :D

« Reply #34 - Posted 2011-09-22 13:39:45 »

I see a similar problem in our OpenGL Application in windowed mode but we think it's because we aren't using linear interpolation when we render, so every second or so (pretty predictable, depends on updates/second), we get a slight stutter where everything seems to "shift" and "snap back" while moving the character from side to side. 

Trying really hard to discern whether this is due to some vertical sync issue, loop timing, or lack of interpolation.

We use Phys2D with a fixed timestep.

Silver Goblet Games' first released product:
Offline sproingie

JGO Kernel

Medals: 202

« Reply #35 - Posted 2011-09-22 16:45:16 »

On Windows, the compositor will drop frames since it doesn't seem to sync up with OpenGL the way it does with DirectX.  Just a simple bouncing box will occasionally make a jump due to a dropped frame.  It's still the same actual speed, but the discontinuity is very visible.   I don't know any way around this annoying behavior other than disabling aero or running fullscreen.

Offline Rejechted

Senior Devvie

Medals: 2
Projects: 2

Just a guy making some indie games :D

« Reply #36 - Posted 2011-09-23 02:20:43 »

We now enable vsync and run in full screen which produces the optimal results with our fixed timestep - no screen tearing, and no stuttering, looks like a knife through butter.

Silver Goblet Games' first released product:
Offline Z-Man
« Reply #37 - Posted 2011-09-23 02:22:46 »

We now enable vsync and run in full screen which produces the optimal results with our fixed timestep - no screen tearing, and no stuttering, looks like a knife through butter.
When I use LWJGL (which uses OpenGL) I just turn on VSync and interpolate the movement of the sprite. Works great.
Pages: 1 [2]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (71 views)
2015-11-07 13:29:08

Rems19 (80 views)
2015-10-31 01:36:56

Rems19 (73 views)
2015-10-31 01:32:37

williamwoles (106 views)
2015-10-23 10:42:59

williamwoles (92 views)
2015-10-23 10:42:45

Jervac_ (106 views)
2015-10-18 23:29:12

DarkCart (134 views)
2015-10-16 00:58:11

KaiHH (116 views)
2015-10-11 14:10:14

KaiHH (155 views)
2015-10-11 13:26:18

BurntPizza (171 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!