Home Game Development tilemap – How to draw a tile placement grid in a 2d isometric place/world?

tilemap – How to draw a tile placement grid in a 2d isometric place/world?

0
tilemap – How to draw a tile placement grid in a 2d isometric place/world?

[ad_1]

I’m working on a isometric 2d tile based game in ruby using SLD 2. The tiles are 40px wide and 20px tall. I’m trying to figure out how to draw the grid (where each cell of the grid is a potential tile, and a tile will be able to be placed there in the map editor).

Normally when making a tile based game, to draw the grid, I would first draw the vertical lines, iterating from 0 to the screen width, in multiples of the tile width. Then I would iterate from 0 to the screen height, in multiples of the tile height, drawing horizontal lines at each iteration along the y axis.

I’m lost as to how I should draw this in an isometric world. I have a function to convert cartesian coordinates to isometric coordinates, and vice versa.

The first thing I tried was to draw the grid as if it was a normal top-down cartesian grid, and right before drawing it, I converted the starting position of the line, and the ending position of the line, to isometric coordinates. This actually worked, however the grid is shifted significantly, and doesn’t cover much of the screen:

My current attempt of drawing a grid

I’m thinking there are two things I could do. The first thing would be to calculate how far off these lines are from [0, 0], and then shift each line by that difference, and do the same with the horizontal lines. That might help cover more of the screen, and then I’d probably also need to keep drawing additional lines (roughly twice the screen width and height respectively?).

The second idea I have, would be to simply calculate the angle at which this isometric projection happens at (basically two pixels of horizontal movement for every single pixel of vertical movement), and then just draw a bunch of these lines at an angle. However I think it would be really hard doing it this way to figure out where to place the tiles.

However, I’m sure there is a correct way to do this, and that’s why I’ve come here, I’d really like to do this the correct way, and would appreciate any help.

Thanks.

[ad_2]

Previous article Outcast – A New Beginning On Its Way to PS5
Next article Nothing Xbox Does Matters If The Games Aren’t Good
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!