Creating a Map

Hi, I’m currently making a top down shooter with Java 2D (I just ordered a Slick2D book so I’ll start learning the better libraries soon). I need to make a map that moves with the player once the player gets too far away from the center position, I was wondering how I should go about doing this?

Keep in mind I have yet to program collision detection into my game, but I also want my map to eventually have destructible walls. Do I want to…

  • Create a map using a tile system?
  • Draw a really big image and move it around?
  • Or some other form of making a map?

Sorry for spamming this section of the forum x), all help is greatly appreciated! (I’ve gotten a lot done thanks to the help from this forum, so an additional thanks for the help I’ve already gotten).

You should go with a tile system. As (if you want to use it later) using OpenGL, will only allow you up to 4096x4096 pixel Images. Also, loading these Images can cost a lot of VRAM.

Just create a class “Tile” and a class “Map”, holding a 2D-Array of "Tile"s. Then just render all tiles visible :slight_smile:

Why wait for the book? Slick is very easy to jump into, probably much easier than writing your own game loop, tiled map loader, and so forth in Java2D. You’ll generally find it more efficient at rendering, and using an OpenGL-based library will force you to learn various game development standards (i.e. thinking about textures in power-of-two, using texture atlases, etc).

There are examples of map loading and scrolling like this one:
https://bitbucket.org/kevglass/slick/src/tip/trunk/Slick/examples/org/newdawn/slick/examples/scroller/Scroller.java

And there’s lots of resources in the wiki and on the forum.