kaboom
kaboom copied to clipboard
Grid Movement resolve always moves left
The grid movement methods, moveLeft, moveRight, ... alway place the object in the center of the next grid, when resolving the position, the minimum overlap is equidistant in all directions, and when entering the switch to adjust the position the first case is always matched for right and the object is moved left.
As a workaround, I can resolve on movement and check for the presence of targets occupying the grid position
keyPress(["left", "a"], () => {
player.moveLeft()
const targets = player.resolve()
if (targets.length
&& targets.find(t => t.obj.gridPos.x === player.gridPos.x && t.obj.gridPos.y === player.gridPos.y)
) {
player.moveRight()
}
})
If the object is being moved using the grid movement method, perhaps a last position could be stored that resolve could look to when the object has a gridPos property, and in the event of a collision with another gridPos containing object, if they are occupying the same position, the last position could be restored?
I believe the assumption here is that an object is exclusively moved with grid movement or regular movement and not a mix of both.
In grid-based games you shouldn't need resolve()
(which is expensive) and only need array index lookup based collision detection, currently still in the process of figuring out how the interface would look like, and stuff like moveLeft()
are still sketches, I'm working on this today, so stay tuned!
That makes sense, thanks. I can't wait to see it!