Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Map Storage Suggestions on: 2012-03-08 22:53:11
So I've lurked around here for a while, but the time has come for me to reveal myself and ask a question.

I'm currently developing a game with a 2D tiled map, similart to the 2D Final Fantasy games and their ilk.  I plan on handling tiled maps through instances of a Map class.

Here's a very simple overview of how I plan to handle the Map class:

    private Image tileSet = null;
    private Image[][] tiles = null;
    private int[][] solidTiles;
    private int[][] eventTiles;
    private int[][] mapGroundLayer;
    private int[][] mapWallLayer;
    private int[][] mapOverheadLayer;

So each Map class has its own tileSet PNG and a 2D matrix of Images that serve as tiles for the map.

I plan to use five 2D integer matrices to handle collision, event activation, and draw order:
  • The solidTiles matrix is filled with 1s and 0s, where a 1 is a solid tile
  • The eventTiles matrix is filled with 0s, 1s, 2s, and 3s, where 0 is a tile with no attached event, 1 is a tile that activates an event upon entering the tile, 2 is a tile that activates an event when the player "interacts" with the tile, and 3 is a tile that has both "enter" and "interact" events.
  • The map____Layer matrices will be filled with integers that each correspond to an entry in the tiles[][] Image matrix.  The draw hierarchy is mapGroundLayer<mapWallLayer<entities on screen such as NPCs and the player<mapOverheadLayer

Now we get to my actual question: how should I store these matrices?  I'd rather not define a subclass of Map for every single map in my game; the only reasonable alternative I see is a text file, but that could get very cumbersome very fast, especially if I have maps with hundreds of tiles.

So! If you have suggestions, let me hear them!  And if you think my way of handling maps is ass-backwards for some reason, then tell me that, too!  I've never tried to make a game before, and I'm quite sure that my inexperience shows.


[Edited to explain the map____Layer matrices a bit better.]
[Edit 2: Obviously my Map class will have more variables/methods than what I put here; I just showed these because they're relevant to my question.]
Pages: [1]
EgonOlsen (1260 views)
2018-06-10 19:43:48

EgonOlsen (1129 views)
2018-06-10 19:43:44

EgonOlsen (864 views)
2018-06-10 19:43:20

DesertCoockie (1273 views)
2018-05-13 18:23:11

nelsongames (1105 views)
2018-04-24 18:15:36

nelsongames (1336 views)
2018-04-24 18:14:32

ivj94 (2076 views)
2018-03-24 14:47:39

ivj94 (1229 views)
2018-03-24 14:46:31

ivj94 (2171 views)
2018-03-24 14:43:53

Solater (795 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!