60 likes | 208 Views
Collision Detection. Barclays Apps Teaching Course - 2013. Collisions. Collision detection typically refers to the computational problem of detecting the intersection of – from two or more objects Interactive games use collision detection Can be done by Objects or Using Images.
E N D
Collision Detection Barclays Apps Teaching Course - 2013
Collisions • Collision detection typically refers to the computational problem of detecting the intersection of – from two or more objects • Interactive games use collision detection • Can be done by Objects or Using Images
Collision Detection • Point and Rectangle • If you want to know if a point is in a rectangle – say a button w (x,y) h (px,py)
Point in Rectangle • You know the X and Y of the point = px and py • You know the Location X and Y of the Rectangle and also the Width and Height = x,y ,w,h • Inside =((px>=x)And(px<=(x+w-1))And(py>=y)And(py<=(y+h-1)))
Images • Images are a series of numbers in a file • Each number is a pixel value – colour 1100, 1222,22112,22112,3443,222322,444,3223,21222,4332
Images Detect if point is in Image • Similar approach – but search through the image and detect what the colour is w (x,y) (px,py)