0

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.

  • Duplicates: http://gamedev.stackexchange.com/questions/70403/how-do-i-ensure-that-my-2d-side-scroller-camera-stays-within-the-world-bounds http://gamedev.stackexchange.com/questions/59188/camera-scrolling-and-game-boundaries – House Mar 16 '14 at 17:20

1 Answers1

0

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

awsumpwner27
  • 465
  • 2
  • 12