0
\$\begingroup\$

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. ^^

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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