package com.fuzzywave.tetribattle.util;

import com.fuzzywave.tetribattle.TetriBattle;

public class Util {

    public static int getPosition(int x, int y) {
        return x + y * TetriBattle.BLOCKS_WIDTH;
    }

    /**
     * @return whether the first rectangle overlaps the second rectangle.
     */
    public static boolean overlaps(int x1, int y1, int width1, int height1, int x2, int y2,
                                   int width2, int height2) {
        return x1 < x2 + width2 && x1 + width1 > x2 && y1 < y2 + height2 && y1 + height1 > y2;
    }

    /**
     * @return whether the first rectangle contains the second one.
     */
    public static boolean contains(int x1, int y1, int width1, int height1, int x2, int y2,
                                   int width2, int height2) {

        float xmin = x2;
        float xmax = xmin + width2;

        float ymin = y2;
        float ymax = ymin + height2;

        return ((xmin > x1 && xmin < x1 + width1) && (xmax > x1 && xmax < x1 + width1))
                && ((ymin > y1 && ymin < y1 + height1) && (ymax > y1 && ymax < y1 + height1));
    }


}

@@ -941,16 +941,17 @@
 ((xmin %3E
+=
  x1 && x
@@ -955,16 +955,17 @@
 & xmin %3C
+=
  x1 + wi
@@ -980,16 +980,17 @@
  (xmax %3E
+=
  x1 && x
@@ -994,16 +994,17 @@
 & xmax %3C
+=
  x1 + wi
@@ -1037,16 +1037,17 @@
 ((ymin %3E
+=
  y1 && y
@@ -1051,16 +1051,17 @@
 & ymin %3C
+=
  y1 + he
@@ -1077,16 +1077,17 @@
  (ymax %3E
+=
  y1 && y
@@ -1091,16 +1091,17 @@
 & ymax %3C
+=
  y1 + he

fix util.containts