Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Creating a little LoZ inspired game in Java here just to get into the feeling of things (learning CS at my school but the only teacher who's willing to help is travelling for 6-months, so I'm teaching myself in the meantime). Thing is, I've run into a little snag with the functionality of the "camera".

I've so far been able to successfully limit where the camera goes in terms of the level size (stopping the camera when it gets to top, bottom, left, and right edges of the level), and keep the camera centered on the player as he moves around the level. The issue I'm having is that once my camera stops moving, I can't figure out how to wait until the player is in the center of the screen again for the camera to move again.

So if my player starts out in the center of the map and then moves all the way to the top left, if I move down or right then my sprite isn't in the center of the camera anymore.

Anyone have any suggestions? And sorry if this blatantly obvious, I'm still new to game development.

Thanks. ^^

share|improve this question
up vote 0 down vote accepted

Just add some extra if statement that will prevent camera movement until the sprite is in the middle. Like:

If player is below middle and camera is at the bottom of the map don't move

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.