[SOLVED]TileMap How to scale the map

I’m trying to scale the map to cover the whole screen, without adding more tiles, I would like to have it scaled 3x, I’m using slick library, extending StateBasedGame, I couldn’t find anything in the docs, and im not to sure as to how to write the method, THX :slight_smile:

@Override
	public void init(GameContainer container, StateBasedGame game)
			throws SlickException {
		currentRoom = HouseMap.ROOM_1;
		map = new TiledMap(Utils.getMapFile(currentMap));
	}

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g)
			throws SlickException {
		map.render(xMargin, yMargin, bgLayer);
		map.render(xMargin, yMargin, lowerFringeLayer);
		map.render(xMargin, yMargin, fringLayer);
		map.render(xMargin, yMargin, upperFringLayer);
	}

	@Override
	public void update(GameContainer container, StateBasedGame game, int delta)
			throws SlickException {
		switch (currentRoom) {
		case ROOM_1:
			currentMap = "Room1";
			break;

		default:
			break;
		}
	}

the map has 16x16 tiles, and is 25 tiles wide and high, my Screen is 800x600, and i would like to stretch it so about 7 tiles are rendered stretched to cover the screen.

You can use the scale method of the Graphics2D class. You can safely assume the instance of Graphics you are passed in your render function is also a instance of Graphics2D and type-cast it to a Graphics2D object as is encouraged in the Java 2D rendering guide. http://docs.oracle.com/javase/tutorial/2d/overview/rendering.html

The scale method takes two arguments, both are self-explanatory.

If you have a height of y and you want a height of y1, just scale y1/y.

Ahem, do you see anywhere in his code anything that indicates hes using java2d? He’s using slick.

There isn’t enough code there to infer from which package he is importing Graphics from. Acknowledging he is using a library named Slick - presumably infer-able from the names of the exceptions being thrown in his code and from the text in his post - does not exclude the most widely used & standard java 2d rendering API to someone who has not used Slick before.

So the question should be - what indicates that he doesn’t use Java2D?

That said, Slick’s graphics object contains a scale method that performs exactly as I described above.
http://slick.ninjacave.com/javadoc/org/newdawn/slick/Graphics.html

Hes passing is parameters for a statebasedgame and other slick2d objects so we can infer that he is using slick2d.

You missed the point - there is no indication that Java2D is not being used to someone who is unfamiliar with Slick or what it is. But lets not carry this discussion on, the initial question has been answered.

There was a Class in The Slick class Graphics, that lets you scale everything you Rendered to a given float, I used it, I tried saving my .tmx as a ping, but then i lose the benifits of using the tilemap, so to answer my question, Using Slick, there is a method in the Graphics class, that lets you scale everything you are rendering.

Hook it in with the ScrollWheel on Mouse, and BAM, WOW eat you heart out…lol

Jeremy, You Rock, I was reading back thru this, and saw this…lol would’ve saved a lot of time if i would have checked back in, huh…Wink