Understanding Active Rendering game loops

I linked to the source code, although Idk what happened to my link to the app…did you really see the app or did the link disappear? also the code is extremely basic, but I made it using my “library” but it is really only 4 files, 2 of them are significant, GameScreen (where the block is moved and drawn) and Game (the loop)

Try this, I just made it right now: http://ra4king.is-a-geek.net/games/Stutter
Also try my JDoodleJump game: http://ra4king.is-a-geek.net/games/JDoodleJump

I saw stuttering your jar, but I don’t see stuttering in either of my games. However, if you still do, then that is normal Java2D behavior since it is known to be quite slow and stuttering.

Both were made using my library: http://code.google.com/p/java-game-utils

EDIT: The source:

Stutter.java


package stutter;

import gameutils.Game;
import gameutils.gameworld.GameWorld;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

public class Stutter extends Game {
	private static final long serialVersionUID = 6410054290342779730L;
	
	public static void main(String args[]) {
		Stutter game = new Stutter();
		game.setupFrame("Stutter", 800, 300, false);
		game.start();
	}
	
	protected void initGame() {
		setSize(800,300);
		
		useYield(true);
		
		GameWorld world = new GameWorld();
		world.add(new Block(200));
		setScreen(world,"GameWorld");
	}
	
	public void paint(Graphics2D g) {
		g.setColor(Color.white);
		super.paint(g);
		
		if(isPaused() && System.currentTimeMillis()/500%2 == 0) {
			g.setFont(new Font(Font.SANS_SERIF,Font.BOLD,30));
			g.drawString("Click to run!", getWidth()/2-50, getHeight()/2+20);
		}
	}
}

Block.java


package stutter;

import gameutils.gameworld.GameComponent;

import java.awt.Color;
import java.awt.Graphics2D;

public class Block extends GameComponent {
	private int speed;
	
	public Block(int speed) {
		super(0,125,50,50);
		this.speed = speed;
	}
	
	public void update(long deltaTime) {
		setX(getX()+speed*deltaTime/1e9);
		
		if(getX()+getWidth() > getParent().getWidth()) {
			speed = -speed;
			setX(getParent().getWidth()-getWidth());
		}
		else if(getX() < 0) {
			speed = -speed;
			setX(0);
		}
	}
	
	public void draw(Graphics2D g) {
		g.setColor(Color.black);
		g.fillRect(0,0,getParent().getWidth(),getParent().getHeight());
		
		g.setColor(Color.green);
		g.fill(getBounds());
	}
}

Thanks for the code and example, although I seem to see stuttering in your example also…I guess this is just something that will happen no matter what, and in a game setting I doubt it will be noticeable