[ad_1]

I am engaged on an isometric second tile based mostly recreation in ruby utilizing SLD 2. The tiles are 40px broad and 20px tall. I am making an attempt to determine how to attract the grid (the place every cell of the grid is a possible tile, and a tile will be capable to be positioned there within the map editor).

Usually when making a tile based mostly recreation, to attract the grid, I might first draw the vertical traces, iterating from 0 to the display screen width, in multiples of the tile width. Then I might iterate from 0 to the display screen top, in multiples of the tile top, drawing horizontal traces at every iteration alongside the y axis.

I am misplaced as to how I ought to draw this in an isometric world. I’ve a perform to transform cartesian coordinates to isometric coordinates, and vice versa.

The very first thing I attempted was to attract the grid as if it was a traditional top-down cartesian grid, and proper earlier than drawing it, I transformed the beginning place of the road, and the ending place of the road, to isometric coordinates. This really labored, nonetheless the grid is shifted considerably, and does not cowl a lot of the display screen:

My current attempt of drawing a grid

I am considering there are two issues I may do. The very first thing can be to calculate how far off these traces are from [0, 0], after which shift every line by that distinction, and do the identical with the horizontal traces. Which may assist cowl extra of the display screen, after which I might in all probability additionally must maintain drawing extra traces (roughly twice the display screen width and top respectively?).

The second thought I’ve, can be to easily calculate the angle at which this isometric projection occurs at (principally two pixels of horizontal motion for each single pixel of vertical motion), after which simply draw a bunch of those traces at an angle. Nevertheless I believe it will be actually laborious doing it this manner to determine the place to put the tiles.

Nevertheless, I am certain there’s a appropriate manner to do that, and that is why I’ve come right here, I might actually like to do that the right manner, and would admire any assist.

Thanks.

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *