Dungeon game

Hi,

I’ve created a randomly generated dungeon - rooms are interlinked via corridors, scrolling is 8-way. Using LibGdx to render the ‘cruddy’ gfx.

The rooms at the moment are just carved out of the map as can be seen in this link : https://sites.google.com/site/dungeonplanetlite/home (the green is the whole map zoomed out)

Rooms are stored in a dynamic structure but no real information about them - was wondering what would be best way to store rooms and to have designs in them (tables, bricks etc)?

My map is stored in a 2d array of type Tiles:


	Tile[][] tilesArray = new Tile[(MyGdxGame.AMOUNTSCREENSX * MyGdxGame.SCREENWIDTH)/MyGdxGame.TILEWIDTH]
					       [(MyGdxGame.AMOUNTSCREENSY * MyGdxGame.SCREENHEIGHT)/MyGdxGame.TILEHEIGHT];


and Tile is:


abstract class AbstractTile {
	protected String name;   // type of tile - corridor for instance, wall
	protected float x, y;
	protected boolean visible;

	protected Texture texture;

	abstract void loadTexture();
}

class Tile extends AbstractTile {
	public Tile(String name) {
		this.name = name;
		visible = true;
	}
}

Loop to draw the map:


	public void drawMap(SpriteBatch batch, Texture img, Texture corridorImg,
			float width, float height) {

		int camX = (int) camera.position.x - MyGdxGame.SCREENWIDTH / 2;
		camX /= MyGdxGame.TILEWIDTH;
		int endX = MyGdxGame.SCREENWIDTH / MyGdxGame.TILEWIDTH + camX;

		int camY = (int) camera.position.y - MyGdxGame.SCREENHEIGHT / 2;
		camY /= MyGdxGame.TILEHEIGHT;
		int endY = MyGdxGame.SCREENHEIGHT / MyGdxGame.TILEHEIGHT + camY;

		if (!MyGdxGame.bDebug) {

			// Optimized loop - we only draw what we can see, that is just one
			// screen
			for (int y = camY; y < endY + 1; y++) {
				for (int x = camX; x < endX + 1; x++) {
					if (tilesArray[x][y].visible) {
						// batch.setColor(1, 0, 0, 1);

						batch.draw(img, tilesArray[x][y].x, tilesArray[x][y].y,
								width, height);
					} else {
						// this a corridor - horrible way of doing this, needs
						// to change!
						if (tilesArray[x][y].name.contains("orridor")) {
							batch.draw(corridorImg, tilesArray[x][y].x,
									tilesArray[x][y].y, width, height);
						}
					}
				}
			}
		} else {  // draw the whole map! Only used when debug is turned on
			for (int y = 0; y < MyGdxGame.ROWS; y++) {
				for (int x = 0; x < MyGdxGame.COLS; x++) {
					if (tilesArray[x][y].visible) {
						// batch.setColor(1, 0, 0, 1);
						batch.draw(img, tilesArray[x][y].x, tilesArray[x][y].y,
								width, height);
					}
				}
			}

		}
	}


If visible is false, a tile is not drawn - this is what makes up a room.

I need a way of now drawing rooms where the invisible tiles are, any good advice on this? I was thinking of having another structure which had the room positions, width, height
and the type of room it is.

Thanks,
Steve