I am working on a very small project, and I've run into an issue.
In the game, the character is a 32x32px sprite, that moves 32 pixels in what ever direction you choose, in a grid. W goes up by 32 Pixels, S goes down, etc. However, in this game, walls will be included. As such, there needs to be a check in place, so the player character does not phase through walls.
I thought I could implement this by creating the wall as a sprite, and adding a boolean to the player character, that will get set to 1, should the player co-ordinates be the same as co-ordinates for a wall sprite. There would also be a check on the player movement, that checks if the boolean is set to 1. If it is set to 1, the player character would then be sent 32 pixels back the way, and then set the boolean to 0.
I'm not entirely sure how to go about this, and was wondering how I would do so. Or even if there was a much more light-weight way to do this. e.g. not having the walls be individual sprites, as there could be thousands per in-game level.
EDIT:I accidentally posted this, originally, in the wrong place. I've moved it here, and I also figured out how to do it.
Basically, there are 4 unique, pink, sprites that move alongside the player. When they intersect the wall sprite, they set the value to the corresponding detection variable to 1. Whilst this variable is set to 1, the player can't move in that direction. If the player moves in any other direction, all the wall detection variables are set to 0.