Hi! I´m working with a tile based game,
and although I{m making good progress, I hit a brick walk:
I´m calculating movement using a variable AngleOfMovment for Each Unit(0,90,180,270)
So if i want a unit to move left(the player samurai for example) I use a tween like this:
AngleOfMovment: 180
End X: Self.X + round(cos(Samurai.AngleOfMovement) * TileSize)
End Y: Self.Y + round(sin(Samurai.AngleOfMovement) * TileSize)
and for basic movement and collision detection it works great!
But I´m implementing a lot of push and knockback mechanics, and that means that I sometimes need to get the opposite angle, and that is giving me a lot of trouble, because depending on the situation sometimes
Self.X - round(cos(Samurai.AngleOfMovement) * TileSize)
works, on others
Self.X + round(cos(-Samurai.AngleOfMovement) * TileSize)
this does, and I can figure out why, because both should add the opposite value right?
If anyone has a more elegant solution, or a better way to get the opposite angle, I would be grateful.