How do you use Tiled object layer? - java

I'm not really sure if this is the place to be asking this but I was trying to use the program Tiled but I'm not sure where to start. I have looked at its documentations but it's not that useful as I already have some experience in using a tiled editor in a game engine (GameMaker), but I'm working straight up Java for this project.
How does the Tiled object layer work? Does it allow me to place enemies in the tiled editor that would show up and actually move in the game or are they just static images like a tile?
Also if it does allow what I programed for the enemy how do I use it?

Tiled allows you to edit layers of tiles and items. There's tile layers which represent a 2D grid of images, and item layers which are just polygons with properties.
After you create a map, its up to you to do something with that data. Tiled is not like GameMaker. All Tiled does is allow you to read, write, and edit data.
I recommend you use LIBGDX as a game engine, and Tiled to create your maps. LIBGDX has support for loading and rendering tiled maps.
To create enemies, you'd place some polygons, add attributes to these polygons, and create enemies based on these properties when parsing the Tiled map in your game.

Related

LibGDX AStar Pathfinding on a Tiled Map

I want to have pathfinding in my .tmx file that created by tiled tool for libgdx but I am very biginner in libgdx. can you show me a complete pathfinding example in tiled maps with libgdx?
I use tiled for build my game map. in this grid map , I want to add node to every grid and connect with other nodes that it make us a graph to pathfinding .
like this image
How can I add nodes to tiles and connect them, and how can I run pathfinding on such a graph in libgdx?
I want some thing like this : libgdx pathfinding
Dont know if it fits your needs, but have you seen this?
https://github.com/xaguzman/pathfinding
Its well documented. Also check bridge inside it.

Semi-transparent objects in tile based rpg game

I am currently working on a simple, tile based rpg for android devices. I have stumbled across an error which I cannot solve efficiently.
Rendering Mechanics
I am currently using android's Canvas implementation to render everything in my game. I load the tile map into a bitmap using an open source TMX loader I found (not really relevant which one). The TMX loader loads the map file and produces a bitmap of the data stored in the tmx file. I am using Tiled to create my maps. The game first draws this bitmap produced by the tmx loader and then all other objects (including the player) on top of the map.
The Problem
As suggested in the title, this causes problems for semi-transparent tiles such as in this map:
The gray box is where entities collide with the well in the center of the map.
This map would be rendered like this:
The arrow is the player - part of the player should be drawn under the wooden beams of the well but still over the grass
I am struggling to find a way draw the player under the wooden beams of the well and over the grass. If anyone could give me some advice on how to do this, it would be greatly appreciated.
What I have tried
In another game I was developing, I created an object layer on tiled which would contain rectangles where the map should be drawn over the player. This worked although it caused the frame rate to drop quite a lot and it is difficult to precisely plot the rectangles over the required areas.

Draw a large background in libgdx

What is the best way to get around the max texture size in Libgdx? I currently have a 2048x2048 texture with an ortho cam zoomed in at 2x which serves as the "map" for my top down shooter. The problem is that 2048x2048 just isn't enough space for the player to move around in, so I need to expand the map without creating a huge texture. Am I going about this wrong? should I not just use a giant texture for the background?
Only some phones will support textures bigger than 2048x2048. This is a GPU hardware/OpenGL driver limitation and not the fault of LibGDX.
The most common solution is to build a map out of several smaller textures that can be repeated to create the illusion of a giant map. You don't just take the map of the world and divide it into 2048x2048 chunks, you instead have a bunch of tiles that are 32x32 pixels and represent things like grass, dirt, grass meeting dirt, etc.
This is why LibGDX has a maps package. See https://github.com/libgdx/libgdx/wiki/Tile-maps
Instead of trying to create the map programmatically you record the map in a text file and use a map loader at runtime. There are a couple of supported map formats. The best way to create the map files is to use a map editor like http://www.mapeditor.org/

libgdx & tiled how to render specific tiles?

I have a large tmx map which I made in Tiled. I am using libgdx to render the tmx map. I would like to know how can I render specific tiles. For example I have a 100x100 tile/tmx map. Player entity spawns in 10,30 (x,y) I only want to render around the location of the player entity (or for any entity, and control the seeing distance within the respective entity class). How can I use libgdx to selectively render like this? I tried setting rendering bounds to camera but not working like I want.
I want to be able to zoom in/out of overall map (which would look dark/completely blacked out) except for the parts where an entity sprite is located. Looking to maintain the fog of war around the entity sprite.. and multiple entities.
Should I pass renderer into the entity constructor? multiple cameras? How can I do a layered effect where i have another 100x100 blacked out tilemap on top of the actual map and have it so the alpha around entities is 0? (bear in mind im using tmx maps)

Multi-tile objects on tiled map

I'm trying to write rts-like-tile-based game using Tiled and slick2d.
I don't know how to handle a multi-tile objects, like buildings, how to create, keep and e.g. move them.
One solution would be to create a layer in tiled where the tiles are used as "markers" for your game code. These "markers" are never drawn. Instead, when you initialize your game, go through the the tiled map and every time a corresponding marker is found add a "new Building()" to some kind of EntityManager class. This way you can write the code for the class Building yourself, and instead of it being completely static tile you can move it around like you would any other entity. This also lets you make these buildings any arbitrary size independently of any tile sizes.

Categories