I’m creating a tile level editor, and I wan’t to add a line tool. Basically you click on one tile, then hold shift and click on another and it should create a line of tiles on the grid.
If it helps I’ve got a 2d array for the tiles.
Thanks in advance!
A simply pseudocode
if (shift pressed and clicked)
Draw a line of tiles from (lastClickPos to newClickPos)
That’s pretty much what I have so far. The problem is figuring out where to actually add them.
I think you have your grind into a table variable.
//if you're adding horizontally
for(int i = 0; i < lengthOfLine; i++)
addToGrid(lastClickedPos.x + i, lastClickedPos.y, tile[currectTile]);
I should probably implement horizontal and vertical lines first. Then I’ll worry about diagonal and every other case
I figured out a solution that involves interpolating between the two points in increments, and adding a tile at that position rounded to the nearest integer.