I’m trying to implement a system where I can draw a line of objects (an earth wall) the player can interact with. The player clicks, drags, and releases to create the objects, but I only know how to implement the first and last objects since the player clicks there.
I want it to do something like this: every x pixels along the line, create the object. But I don’t know the math or formulas for that.
To the blocks you want to draw, add a boolean instance variable called IsTemp, and set it to false.
In pseudo-code :
set variable numBlocks = firstObject.DistanceTo(secondObject)/firstObject.width()
set variable count = 0
create normal event:
. condition is block.Variable(IsTemp) = true
. action is delete block
create a while event :
. condition = variable count < variable numBlocks
. first action is create block at x = lerp(firstBlock.X(), secondBlock.X(), Variable(count) / Variable(numBlocks)), y = lerp(firstBlock.Y(), secondBlock.Y(), Variable(count) / Variable(numBlocks))
. second action is to set block.Variable(IsTemp) = true
. add third action to increase variable count by 1
finally create another new event :
. conditions are mouse is released and trigger once
. action is set blocks.Variable(IsTemp) = false