Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
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 17872 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: 421
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)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
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)
        {
            Thread.yield();
            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





« 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: 1
Projects: 1


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.

Blog for our project (Codenamed Lead Crystal): http://silvergoblet.tumblr.com
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: 1
Projects: 1


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.

Blog for our project (Codenamed Lead Crystal): http://silvergoblet.tumblr.com
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (29 views)
2014-11-22 12:13:56

xFryIx (71 views)
2014-11-13 12:34:49

digdugdiggy (50 views)
2014-11-12 21:11:50

digdugdiggy (44 views)
2014-11-12 21:10:15

digdugdiggy (38 views)
2014-11-12 21:09:33

kovacsa (62 views)
2014-11-07 19:57:14

TehJavaDev (67 views)
2014-11-03 22:04:50

BurntPizza (64 views)
2014-11-03 18:54:52

moogie (80 views)
2014-11-03 06:22:04

CopyableCougar4 (80 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!