I'm making a top-down rogue with dungeon generation similar to the binding of Isaac. I'm trying to make a system to be able to tell which room the players in, I create doors on each side of a room and give each a direction, I have it, so it increments the pos_x or pos_y by 1/-1 depending on the direction of the door the player enters (1 is to the right, 2 is down, etc). I want it so for example if pos_x = 4 and you were to enter a door with direction = 3 it would -1 from pos_x making it 3, but as of now it just sets pos_x to -1. each door can increment fine, so if I keep entering a door with direction = 1 it will continue to increase pos_x by 1, but it messes up if I try to go the opposite direction.
I feel like my math is right, but I could be making a dumb mistake, any help appreciated.