Is this possible?
To elaborate, I am making a PacMan offshoot. Essentially it is a "zoomed in" version of the game, but the board is randomly generated. I have 11 .png files each to be used as a background for different hallway shapes. You have your straightaways, corners T junctions and cross intersection. They are very simple, each has a black background and the walls are blue. What I am looking for is a way to stop the player from walking on the blue parts of each image. Is that possible?
My current set-up is that I have a Piece
class that holds the image, Entry points
as bools (up down left right) for when I randomly select the image to be used so that a path can be created, size, etc. I then have a Board
class that holds a list of Pieces (size 11 (One for each image))) and then 2D an array "board" (currently 9x9) that randomly but intelligently generates the map. When it comes to player pathing, I was manually going to add to the Piece
class code that adds invisible rectangles over the blue walls and then have the Player
class, or some other class, check for collision. This would take a ton of extra code because each image is different so each would need to be manually done.
I was just thinking there must be an easier way to do this, and the whole color idea occurred to me. If i could just check if it intersects the blue and then change its position back that would be much easier.
I am at work currently, but if there is any code you would need to see, or any other helpful information let me know and I will add it as soon as I get home!
TL;DR Is there a way to check collision via color, or add rectangle automatically over a specific color.