-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|209|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Collisions and Physics


 
melmantheman
Created : 04 April 2012
Edited : 04 April 2012
System : Cross Platform
Language : Ruby

Pixel Perfect Collision

Helps to make pixel perfect(accurate down to a pixel) collisions using image RGB values and



Were as:
*collide is image for collision
*clr is int value for pixel;
*pX is player's x coordinate
*bgx is the backgrounds location relative to the player or (0,0)
*pY is player's y coordinate


How it works:
You have a background Image that is a picture of the landscape your going to be playing on, Then you have a near identical picture that is all the collide-able spots on the level colored red. clr is the pixel at the players location (shifted to a side of the player [u/d/l/r]). If that pixel the player is touching is -65536 (the color red) than the player cannot move any further in that direction.

 

Comments