Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED]TileMap How to scale the map  (Read 778 times)
0 Members and 1 Guest are viewing this topic.
Offline supaFool

Junior Devvie


Projects: 2



« Posted 2013-08-03 17:41:44 »

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 Smiley

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
@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.
Offline Jeremy
« Reply #1 - Posted 2013-08-04 11:31:13 »

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.

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #2 - Posted 2013-08-04 12:19:31 »

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

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeremy
« Reply #3 - Posted 2013-08-04 12:34:13 »

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

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #4 - Posted 2013-08-04 14:37:03 »

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

Offline Jeremy
« Reply #5 - Posted 2013-08-04 14:43:49 »

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.

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline supaFool

Junior Devvie


Projects: 2



« Reply #6 - Posted 2013-08-05 02:45:31 »

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.
Offline supaFool

Junior Devvie


Projects: 2



« Reply #7 - Posted 2013-08-05 02:59:11 »

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

Junior Devvie


Projects: 2



« Reply #8 - Posted 2013-08-05 03:25:16 »



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

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
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!