I am looking for some advice, please, about the doors in my game.
It is a sidescroller. The idea is simple: Player walks up to a door, door opens. once player walks away from the door, door closes again.
i do this with player.x and door.x but here is the thing: it should work from both sides, so i figure i have to use lerp but i have no idea how that works. also, the door must always open fuly and close fully, preferably until it hits a solid tile.
so the code should be something like
if door.x is less than player.x+80 then use 8 direction up until you hit a solid tile. then switch on instance variable to "open" and stay there. if player is away more than 80 then close until you hit a solid tile and then switch to instance variable "closed"
i can do most of that but i have a problem with the range. how exactly do i tell the door that it should only move if player is closer than 80 in both directions, left and right? and only that particular door?