Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (748)
Games in Android Showcase (226)
games submitted by our members
Games in WIP (834)
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]
xxMrPHDxx (306 views)
2017-12-31 17:17:51

xxMrPHDxx (94 views)
2017-12-31 17:15:51

xxMrPHDxx (146 views)
2017-12-28 18:11:33

Ecumene (310 views)
2017-09-30 02:57:34

theagentd (492 views)
2017-09-26 18:23:31

cybrmynd (528 views)
2017-08-02 12:28:51

cybrmynd (463 views)
2017-08-02 12:19:43

cybrmynd (446 views)
2017-08-02 12:18:09

Sralse (405 views)
2017-07-25 17:13:48

Archive (1312 views)
2017-04-27 17:45:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!