Loading...
Logo
Processing Forum

collision detection or mapping

in General Discussion  •  Other  •  1 year ago  
Hey all!

I am currently in the process of writing a "mouse maze", where the player guides their mouse pointer through a course without touching any of the edges.  My main issue seems to be with the wall collision, and I have been wondering on how to go about doing it most efficiently.  
I have heard whispers here and there of "collision mapping", and this popped into my head:
Is there a way to load a (predrawn) maze map as a background, and then have processing detect the colors (black walls) of the map and use that to define the borders of the maze? Rather than using tons of "if" statements declaring where the mouse can and can't be, it would seem less tedious to detect the pixel colors, and base collision off the map.
Provided that this is not a reasonable option, are there any "shortcuts" to use in collision detection?

Replies(3)

" have processing detect the colors (black walls) of the map"
See get()
Hmm, looks very helpful. I'm not sure I completely understand how it works though.  Would I be able to have get() read the pixels in a very small radius directly around the mouse, and then if black is found, end the game? Or read the entire map at once and end the game if mouseX crosses a black line?

Thanks!
This topic discusses a similar theme and might give you some ideas.