Rendering an Object (Tile) in-game (MonoGame)

Hello guys,
So was creating a basic level for prototyping and came across an issue I’m having. I wanted to add a door tile(sprite) and this had to be done without the use of the grid system (I basically needed to manually and freely position it).

I achieved this by making a new Object layer and adding a Tile to it.

But, the door does not render in-game. I suspect this is supposed to work like that. Is there a way to render it? Or another process of getting the same result?

Thanks :slight_smile:

I don’t see why this would be “supposed to work like that”. Your game should render at least as much as Tiled does, and probably more.

Make sure your TMX importer supports objects, and that you’re rendering the objects (and in the right order - make sure the door’s not being rendered under other layers).

Thanks for the reply! So, it turns out that the library I’m using does not support the rendering of Objects. I have attempted to create my own Object renderer, but when using the Objects’ position, it does not align correctly.

Here is how it looks in Tiled (ignore door to the left)

and this is how it looks in my game (using MonoGame & MonoGame Extended):

I’m not sure how Tiled object positioning system works; I assume I have to do some sort of conversion, but I am unsure as to what or how.

Objects are positioned a little weirdly in Tiled. You can get their screen-space coordinates by doing the same conversion Tiled does:

(If this isn’t the function you need, scroll up to look at the other conversion functions there. I don’t remember how exactly object coordinates are stored in isometric objects, but it’ll be one of these.)

thanks for the info!
But, unfortunetly, none of these functions seem to work for me :frowning:, some of them will render the object in the top right of the map, to not render at all (or just outside the map).

I’ve tried plugging in loads of different values but to no avail.

I’m not sure if this is due to my Tiled setup, my map is 100x100 width and height, tile width is 400 and height is 200. Each tile is 512px x 512px. I thought that this might be due to an alignment issue, so I decided to make a map without the use of any tiled layers, and simply drawing all of my tiles in an object layer. but when rendering, I get the following (without using conversion):

Curious, is this JavaScript rendering?

I ended up writing my own JavaScript renderer that support layers. So, things like your door, was really on another layer. I had layers like ground, rocks, trees, housing and so on.

The experiment was for learning, If this is JS i can share the code. Have a look:

no, no JavaScript here. It’s all done in C#. But thanks for the reply! :wink:

@SilenceOfTheLambdas The numbers stored in the TMX / JSON formats are what is internally called the “pixel” coordinate of the object. To determine the position of the object in “screen” coordinates, you’ll at least need to apply the pixelToScreenCoords conversion. Note the way in which it divides both x and y by the tile height, which is probably what @eishiya refers to when she says it’s a little weird.

1 Like