Need help with flickering and timestep problem in my game

Hello, I’m new user in this forum but I was reading a lot of threads that helped me but in this case I didn’t get the answer.

My problem is that my game is flickering all the objects (jumping backforward) and I don’t understand why.
I tried to use delta for the movement…, I tried to use sleep…, but nothing works. I don’t know what more to do, and in other tests with delta and “unlimited fps” the code works perfect.
Example of code that works:
[spoiler]http://pastebin.com/vjZ0cgdh[/spoiler]

This is my game loop:

private static void bucleJoc()
	{
		double passat = 0;
		double dividir_entre = 1000.0/60.0;//cada milisegon 
		ultimTemps = lastFrame = Sys.getTime();

		objectes = new ArrayList<ObjecteJoc>();
		jugador = new Jugador(0, ALTURA / 2 - Jugador.ALTURA / 2);
		enemic = new Enemic(AMPLADA - Enemic.AMPLADA, ALTURA / 2 - Jugador.ALTURA / 2);
		pilota = new Pilota(AMPLADA / 2 - Pilota.MIDA / 2, ALTURA / 2 - Pilota.MIDA / 2);
		objectes.add(jugador);
		objectes.add(enemic);
		objectes.add(pilota);
		getDelta();

		while(!Display.isCloseRequested())
		{
			double delta = getDelta();
			passat += delta;

			while(passat >= dividir_entre)
			{
				glClear(GL_COLOR_BUFFER_BIT);
				glLoadIdentity();

				obtindreTecles();
				actualitzar(passat);
				passat = 0;
			}
			renderitzar();
			
			try
			{
				Thread.sleep(2);	
			} catch(InterruptedException e)
			{
				e.printStackTrace();
			}

			actualitzaFPS();
			Display.update();
		}
		tancarTot();
	}

This is my render function:

public void renderitzar()
	{
		crearRectangle(x,y,amplada,altura,cVermell,cVerd,cBlau,rotacio);
	}

	private void crearRectangle(float x, float y, int amplada, int altura, int vermell, int verd, int blau, float rotacio)
	{
		glPushMatrix();
		{
			glColor3ub((byte) vermell, (byte) verd, (byte) blau);

			glTranslatef(x,y,0);

			/*glTranslatef(amplada/2,altura/2,0);
			glRotatef(rotacio,0,0,1);
			glTranslatef(-amplada/2,-altura/2,0);*/

			glBegin(GL_QUADS);
				glVertex2f(0,0);
				glVertex2f(amplada,0);
				glVertex2f(amplada,altura);
				glVertex2f(0,altura);
			glEnd();
		}
		glPopMatrix();
	}

And this my update for the movement:

public void actualitzar(double delta)
	{
		System.out.println("Y: "+ this.y);
		
		if(Keyboard.isKeyDown(Keyboard.KEY_W) || Keyboard.isKeyDown(Keyboard.KEY_UP))
		{
			this.y += VEL * delta;
		}
		if(Keyboard.isKeyDown(Keyboard.KEY_S) || Keyboard.isKeyDown(Keyboard.KEY_DOWN))
		{
			this.y -= VEL * delta;
		}
		//System.out.println(this.y + " " + delta);
		
		
		if(this.y >= Joc.ALTURA - ALTURA / 2)
			this.y = Joc.ALTURA - ALTURA / 2;

		if(this.y <= 0 - ALTURA / 2)
			this.y = -ALTURA / 2;
	}

If you want I can post the full code.
Thanks for the help and attention.

You using delta timing.
Getting it right is quite hard. So this is expected when you use delta.

Either learn really about gameloops and delta timesteps, or dont use delta - it depends on what you target

am kinda having the same problem, my game looks a little bit flickering even in 60FPS and am using Delta (same code i found in the LWJGL wiki ) so i want to ask you, what do you mean by it depends on what you target ? and is it possible to use a different game loop ?

Yes I know, I spend a lot of time trying to understand how delta works because all the good tutorials are in english and I’m spanish so it’s a bit difficult. But I want my game to work with it, and all the others I can make in the future, because it’s FPS independent, so it can run in almost any computer. But anyways, thanks for your answer.

Yes absolutely. You can just do your game frame-based.
Time/Delta vs Frame based game loops are, at least in the indie area a holy war…
The frame based approach is simply: Make sure your game runs a rock solid framerate, eg 60fps and dont use delta. Or have too modes 30 and 60.
Many many games are like this, since you dont have to use delta if you are sure that your framerate is constant, which is a good thing anyway.

However it kinda depends what platform you target and what your game is like.
If you are using a platform like say a console, you can easily use frame-based, since it will run the same anywhere.
And it also depends on what is going on in your game… If there are really busy sections and really idle sections you may have to use some delta.

Of our 4 games, 3 use frame-based and one uses some delta by applying a low pass filter over the delta values and stuff… Its really hard to get it right.
But if your game has like a minimum system requirement and you cap the fps, the game will only run slower on hardware that is simply too slow anyway.

So yeah I’m kinda frame-based.

To me, the problems you encounter with using delta far exceed the benefits in most cases.

Why not use both? You could run your logic framebased while only updating at 60 fps.