Ok, I'd like to start off by saying that I know I'm not actually moving the camera, but it's easier to explain that way.
My problem is that I'm trying to move the camera with my character in a top down 2d rpg, and I can't find the correct way to do it. I know about glTranslate() but then I can only use a speed instead of an x and y coordinate. I'm not sure how to move the camera keeping the delta in mind. I don't even know if glTranslate() is even the method I should be using.
In case I'm not making any sense (which is very likely), here's some of my code.
My test while loop:
while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)&&!Display.isCloseRequested())
{
glClear(GL11.GL_COLOR_BUFFER_BIT);
delta=getDelta();
update(delta);
glTranslatef(speedx, speedy, 0);
level1.checkCurrent(x, y);
level1.draw();
Display.update();
Display.sync(60);
}
Here is where I set the speed:
if(Keyboard.isKeyDown(Keyboard.KEY_DOWN))
{
y+=0.5*delta;
screenY+=0.5*delta;
speedy=(int) (-0.5*delta);
direction=2;
}
else if(Keyboard.isKeyDown(Keyboard.KEY_UP))
{
y-=0.5*delta;
screenY-=0.5*delta;
speedy=(int) (0.5*delta);
direction=8;
}
else
speedy=0;