0
\$\begingroup\$

I want to create a simple space game, like Asteroids. Unlike Asteroids, the map is supposed to be larger than what the player can see: enter image description here

The grey part is what the player can see in the game window, to see the rest of the level he needs to move his spaceship. When his spaceship reaches the borders eventually, the camera is supposed to stop and not move any further. Thus, the spaceship wouldn't be central anymore.enter image description here

I am using libgdx and have no idea how to do this.

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

Well, it's rather like how you'd perform simple collision detections. You could consider the viewport and the edges of the world "axis aligned bounding boxes" (AABB). So, you'd just need to do checks like this: "Has the right edge of the viewport moved past the right edge of the world? If so, then change the viewport's postion on the X-axis so that the two edges are just against each other." enter image description here

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Did you have something to add that isn't already contained in the duplicates? \$\endgroup\$ – MichaelHouse Mar 17 '14 at 4:41
  • \$\begingroup\$ @Byte56 Actually, the duplicates answer this question very well, so not really. \$\endgroup\$ – awsumpwner27 Mar 17 '14 at 4:50

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