I am planning a 2-D science fiction game involving spaceships. A major thing that I am having trouble figuring out is how to create a 2-d array of smaller maps that the player can explore.

My inspiration is the Flash game Starfighter: Disputed Galaxy:

Map example

The map here is composed of a 2-D array containing smaller maps called sectors. Each sector is connected to surrounding sectors, such that when the player moves to the edge of a sector, they go to the next.

For example, if I was in sector [05][01] and I move up until I cross the edge, I am taken to sector [06][01], then I go to the right, crossing the right edge of the sector, I am now taken to sector [06][02].

However, if I am at a sector like [0][5] and attempt to go down, It will not allow me to cross the edge line of the sector. In other words, a huge map made out of smaller maps.

I'd like to know how to implement those transitions. How do I programmatically determine which sector to move to (or not allow movement) when crossing over a boundary?

  • 1
    \$\begingroup\$ Create a MapRegion class. Use it to hold an Array of Tile class instances. This way you can do GameInstance.getInstance().getRegions(i).getProvince(p); This way you can check to ensure i and p are in bounds before moving to them and if they're not you can [not] do something. \$\endgroup\$ May 13 '16 at 19:20
  • \$\begingroup\$ Possible duplicate of Creating a seamlessly looping 2D multiplayer level? - the situation is different but the solution may be the same; for seamless looping levels, it is simply creating a large map by connecting a smaller map with itself, end to end. \$\endgroup\$ May 26 '16 at 4:04

Your Answer

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

Browse other questions tagged or ask your own question.