Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
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  
  Invisible Map [LibGDX]  (Read 1184 times)
0 Members and 1 Guest are viewing this topic.
Offline CelesEternal

Senior Newbie





« Posted 2013-04-04 17:48:57 »

Hello,

Sorry to ask you that, but this problem make me crazy xD
Because all that i did is useless if ... my map can't appear..

I don't think that the code is the problem, because it works with a downloaded map.
But i show it :

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  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
package Module;

import Base.Tile.TileType;
import Launcher.FurtherShade;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.tiled.TileAtlas;
import com.badlogic.gdx.graphics.g2d.tiled.TileMapRenderer;
import com.badlogic.gdx.graphics.g2d.tiled.TiledLoader;
import com.badlogic.gdx.graphics.g2d.tiled.TiledMap;

/**
 *
 * @author Celes Eternal
 *
 */


public class Map {

   /*
    * Data
    *
    */

   
   //Block size
   static final int BLOCK_WIDTH = 32;
   static final int BLOCK_HEIGHT = 32;
   
   //class data
   private TileMapRenderer tileMapRenderer;
    private TiledMap map;
    private TileAtlas atlas;
    private OrthographicCamera cam;
   private SpriteBatch batch;
 

    public Map(){
       // Load the tmx file into map
       map = TiledLoader.createMap(Gdx.files.internal("maps/tutoMap.tmx"));

       // Load the tiles into atlas
       atlas = new TileAtlas(map, Gdx.files.internal("tileSets/"));
       
       // Create the renderer
       tileMapRenderer = new TileMapRenderer(map, atlas, 10, 10, 32, 32);
       
       //initialize
       
       cam = new OrthographicCamera(Gdx.graphics.getWidth() ,
            Gdx.graphics.getHeight() );
      cam.translate(Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
     
      batch = new SpriteBatch();
      this.initVirtualMap();
       
    }
   
    public void initVirtualMap(){
       
   
       TileType [][] virtualMap = new TileType[map.width][map.height];
       
       
       for (int x = 0; x < map.width; x++)
       {
             for (int y = 0; y < map.height; y++)
             {
                   for (int l = 0; l < map.layers.size() ; l++)
                   {
                       int id = map.layers.get(l).tiles[y][x];                      
                     
                       if(id!=0){
                       String b = map.getTileProperty(id, "Type");
                      Gdx.app.log(FurtherShade.LOG, b);
                         if (b!=null)
                             virtualMap[x][y] = TileType.Wall;
                   }
                   }}}
       }
       
       
       
   
   
   public void render() {
     
      cam.zoom = 0.5f;
     
      cam.update();
     
      tileMapRenderer.render(cam);
   }
}


I tried some differents zooms but it did nothing.

So i think that the problem result from my files.

tutoMap.tmx:

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  
29  
30  
31  
32  
33  
34  
35  
36  
<?xml version="1.0" encoding="UTF-8" standalone="no"?><map height="25" orientation="orthogonal" tileheight="32" tilewidth="32" version="1.0" width="50"><properties><property name="blended tiles" value="242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,369,370,371,372,373,374,375,376,377,379,380,381,382,383,384,385,390,391,392,393,395,399,400,401,402,403,404,405,406,407,408,411,412,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,473,474,475,476,477,478,479,480,484,485,486,487,488,489,490,491,492,493,494,495,496,505,506,507,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,530,531,532,533,534,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,553,554,555,556,557,558,559,560,561,562,563,564,565,566,568,571,572,573,574,575,576,577,578,579,580,581,582,583,584,589,590,591,592,593,597,598,600,603,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,621,622,623,624"/></properties>
 <tileset firstgid="1" name="Dungeon_A4" tileheight="32" tilewidth="32">
  <image height="480" source="../tileSets/Dungeon_A4.png" width="512"/>
 </tileset>
 <tileset firstgid="241" name="Dungeon_A5" tileheight="32" tilewidth="32">
  <image height="512" source="../tileSets/Dungeon_A5.png" width="256"/>
 </tileset>
 <tileset firstgid="369" name="Inside_B" tileheight="32" tilewidth="32">
  <image height="512" source="../tileSets/Inside_B.png" width="512"/>
 </tileset>
 <layer height="25" name="Background" width="50">
  <data compression="gzip" encoding="base64">
   H4sIAAAAAAAAC+3Ruw2AMBAD0LBE9gF2oOfT8Nm/xpGoIpAShIjhXDxda/t85ZwXERER87pD6RxPdSmd4e8bW8b+x5xszF1Yc+Vuybzxm7t/aYM7f5ZzI0zRfuH2MBDkS7XCFnUIZlgI8qWqobnQEuSz0mMHywpx0ogTAAA=
  </data>
 </layer>
 <layer height="25" name="Wall" width="50">
  <data compression="gzip" encoding="base64">
   H4sIAAAAAAAAC+1YwQ2EMAzrttwGsAG3AYxLP/1UimKbNHAcliJ/itPENFI7lVI+NaYf57nG8gBu9aw1vgCj69W+ovvo87R6tho7wOh6ta/oPqw8KFr96DqWWajfo3WrfrB4/fgvP9S5x/o02g917rE+qX6o/vew+mf55+mwfni6KKx+WP55Omx/PV0U6nyydKL02HxR/+fZeXc2X/Q5i/bXAnt+UUT3xdNhzy+KbD9GIduPUXiKH6PmXzb6e62Hq98R0HcGtO67MjrH2ft/NqNznL3/Z/MBvpVIfogTAAA=
  </data>
 </layer>
 <layer height="25" name="Decor (visuel)" width="50">
  <data compression="gzip" encoding="base64">
   H4sIAAAAAAAAC+3W3Q2AIAxGUXQvfxZAHckRHFl5bTB+hqQBcs9zKRa0NgTUbBu1uNnELeK6L+eg5VrF/WwudV2p66ljd9oLQJnUz2Lme7V9LhdTI/ucb329lXpUuTrVf9ofk9O5edzP0dk7gHal+czOaF4zGwAAvbsBSjgXcYgTAAA=
  </data>
 </layer>
 <layer height="25" name="Decor (like wall)" width="50">
  <data compression="gzip" encoding="base64">
   H4sIAAAAAAAAC+3VsQ0AIAhEUcJauoFu4Aju3yu9iYk2iP+VVEBxJwKPkopk3c+8K3PfqvsZAJx6MRtXyMY7LcjvepA7EAs5ix9Yj0ToEusRugTwbQAnAYbxiBMAAA==
  </data>
 </layer>
 <layer height="25" name="Decor (vision)" width="50">
  <data compression="gzip" encoding="base64">
   H4sIAAAAAAAAC+3OMQqAQBAEwWEfevoCz/9HbrqJoSBUQcOEkwC8W5Uc3Vlz/83Vn3d319wAAADwhQc5g2PbiBMAAA==
  </data>
 </layer>
</map>


and a tileSet:
Dungeon_A4 packfile

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  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
Dungeon_A4.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
Dungeon
  rotate: false
  xy: 2, 2
  size: 32, 32
  orig: 32, 32
  offset: 0, 0
  index: 239
Dungeon
  rotate: false
  xy: 36, 2
  size: 32, 32
  orig: 32, 32
  offset: 0, 0
  index: 238
Dungeon
  rotate: false
  xy: 70, 2
  size: 32, 32
  orig: 32, 32
  offset: 0, 0
  index: 237
.......
.......
.......
Dungeon
  rotate: false
  xy: 444, 512
  size: 32, 32
  orig: 32, 32
  offset: 0, 0
  index: 1
Dungeon
  rotate: false
  xy: 478, 512
  size: 32, 32
  orig: 32, 32
  offset: 0, 0
  index: 0


And one last thing, when i make the packfile, my tileSet was blended... It's possible to make a pake file with my current image?

Sorry to bore you,
See you
Offline Axeman

Senior Devvie


Medals: 7



« Reply #1 - Posted 2013-04-04 20:14:36 »

I took a quick look and I can´t see that you´re setting projectionmatrix anywhere. What if you try adding

1  
tileMapRenderer.getProjectionMatrix().set(cam.combined);


in your render method?
Offline CelesEternal

Senior Newbie





« Reply #2 - Posted 2013-04-05 13:52:45 »

oh yeah i forget this.
but no it do nothing ^^ but i  think that  if a map can render but not an other then the problem isn't the code
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 138
Projects: 4
Exp: 3 years



« Reply #3 - Posted 2013-04-05 16:26:07 »

If you have a camera, shouldn't it be in your main class, not your map class?
Offline CelesEternal

Senior Newbie





« Reply #4 - Posted 2013-04-07 10:31:31 »

Yes it will be done, but for now i just need camera for the map
But why did you tell that?
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 138
Projects: 4
Exp: 3 years



« Reply #5 - Posted 2013-04-07 22:12:09 »

Yes it will be done, but for now i just need camera for the map
But why did you tell that?
Just thought it a bit odd that your game camera was in your map class.
Offline CelesEternal

Senior Newbie





« Reply #6 - Posted 2013-04-08 09:20:38 »

^^
So anyone can help me? =/
Offline marcuiulian13

Senior Devvie


Medals: 5
Exp: 3 years



« Reply #7 - Posted 2013-04-08 10:14:11 »

Here is how i did my rendering (notice i'm not using tiled map):
https://github.com/marcuiulian13/rpg/blob/master/RPG/src/ro/enoor/rpg/world/WorldRenderer.java

I think that the camera.translate(width / 2, height / 2); isn't needed.

Getting a project done is by far the most hard thing in game development.
Offline CelesEternal

Senior Newbie





« Reply #8 - Posted 2013-04-08 15:40:42 »

yes because you use the player to control the camera, in this code i just put the camera on the middle screen.
i have an idea, someone can put or send me at Eternal.Celes@gmail.com , some packfile and map(.tmx) created by himself?
i don't really think that i can thought the solution like this, but why not
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.

xFryIx (58 views)
2014-11-13 12:34:49

digdugdiggy (37 views)
2014-11-12 21:11:50

digdugdiggy (30 views)
2014-11-12 21:10:15

digdugdiggy (24 views)
2014-11-12 21:09:33

kovacsa (48 views)
2014-11-07 19:57:14

TehJavaDev (51 views)
2014-11-03 22:04:50

BurntPizza (51 views)
2014-11-03 18:54:52

moogie (66 views)
2014-11-03 06:22:04

CopyableCougar4 (64 views)
2014-11-01 23:36:41

DarkCart (150 views)
2014-11-01 14:51:03
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

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