Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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 23: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:

1  
2  
3  
4  
5  
6  
7  
    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.

Thanks!

[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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org 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‑gaming.org
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!