Well you can use simple
bounding box collision detection, if you´re making a tetris game, every piece of tetris is made of rects
for example a
Determining Intersections with Bounding BoxesThe easiest way to determine if two sprites intersect is by comparing their bounding boxes. A bounding box is the smallest rectangle, with edges parallel to the x and y coordinates, that contains the entire sprite.
Here’s a simple formula for determining if two sprites intersect. Let’s say that the smallest pair of coordinates of box 1 is (x1,y1), and the largest pair is (x2,y2). Similarly, box 2’s smallest coordinates are (x3,y3), and the largest are (x4,y4). Figure 5-11 shows these two boxes in the applet coordinate system. Box 1 intersects with box 2 if and only if the following condition is true:
(x2 >= x3) && (x4 >= x1) && // x-extents overlap
(y2 >= y3) && (y4 >= y1) // y-extents overlap
Here’s another way of describing this equation. The x extent of a box is the range of x coordinates that the box occupies; y extents are defined analogously for y coordinates. The two boxes intersect if both their x extents and their y extents overlap. You can extend this intersection formula to three dimensions by testing whether the z extents also overlap
So this is the boolean you need 
// compare bounding boxes
1 2 3 4 5 6
| public boolean intersect(int x1,int y1,int x2,int y2) {
return (x2 >= locx) && (locx+width >= x1) && (y2 >= locy) && (locy+height >= y1);
} |
This routine checks if the sprite at (locx,locy), with the given width and height, intersects the bounding box between the coordinates (x1,y1) and (x2,y2).
so as example you can add a inspection rutine in the update method
1 2 3 4 5 6 7 8 9 10 11
| public void update (Graphics g){
if(intersect(objective_x,objective_y, objective_x+objective_h,objective_y+objective_w)){
Puntos++; objective_x = Rndm_num(applet_width - objective_w); objective_y = Rndm_num(applet_height - objective_h); } . . . . } |
Now the only thing you have to do is implementing this boolean in your code and defining sets of Rects to each piece of tetris
