Android Open Source - Tetris-Evolution Collision






From Project

Back to project page Tetris-Evolution.

License

The source code is released under:

GNU General Public License

If you think the Android project Tetris-Evolution listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mygdx.util;
/*from w w  w.  j a va  2s .  com*/
public class Collision {
  
  public final static boolean checkCollisionWithPoint(float x, float y, float width, float height, float x1, float y1, float width1, float height1){
    width = width - 1;
    x = x + 1;
    
    width1 = width1 - 1;
    x1 = x1 + 1;
    
    if (x >= x1 && x <= x1 + width1 && y >= y1 && y <= y1 + height) return true; // Left bottom 
    if (x + width >= x1 && x + width <= x1 + width1 && y >= y1 && y <= y1 + height) return true; // Right bottom 
    if (x >= x1 && x <= x1 + width1 && y + height >= y1 && y + height <= y1 + height1) return true; // Left up
    if (x + width >= x1 && x + width <= x1 + width1 && y + height >= y1 && y + height <= y1 + height1) return true; // Right up
    
    if (x1 >= x && x1 <= x + width && y1 >= y && y1 <= y + height1) return true; // Left bottom 
    if (x1 + width1 >= x && x1 + width1 <= x + width && y1 >= y && y1 <= y + height1) return true; // Right bottom 
    if (x1 >= x && x1 <= x + width && y1 + height1 >= y && y1 + height1 <= y + height) return true; // Left up
    if (x1 + width1 >= x && x1 + width1 <= x + width && y1 + height1 >= y && y1 + height1 <= y + height) return true; // Right up
    
    return false;
  }
  
  public final static boolean checkCollisionWithBorder(float x, float y, float wigth, float height, float widthScreen, float heightScreen){
    if (x < 0) return true;
    if (y < 0) return true;
    
    if (x + wigth > widthScreen) return true;
    if (y + height > heightScreen) return true;
    
    return false;
  }
}




Java Source Code List

com.mygdx.TetrisEvolution.android.AndroidLauncher.java
com.mygdx.TetrisEvolution.client.HtmlLauncher.java
com.mygdx.TetrisEvolution.desktop.DesktopLauncher.java
com.mygdx.blocks.Block.java
com.mygdx.blocks.BlocksBox.java
com.mygdx.blocks.Connect.java
com.mygdx.blocks.Level.java
com.mygdx.blocks.LogicScheme.java
com.mygdx.game.Game.java
com.mygdx.main.TetrisEvolution.java
com.mygdx.modes.DarwinMode.java
com.mygdx.modes.Mode.java
com.mygdx.renderer.ModeRenderer.java
com.mygdx.states.Info.java
com.mygdx.states.MainMenu.java
com.mygdx.states.ModeMenu.java
com.mygdx.states.Play.java
com.mygdx.states.Splash.java
com.mygdx.tools.GifDecoder.java
com.mygdx.tools.InvertXY.java
com.mygdx.tools.Resources.java
com.mygdx.util.Collision.java