package game.util;
import game.core.Collidable;
import game.entity.Player;
import game.game.levels.Levels;
import java.util.HashMap;
import org.newdawn.slick.openal.Audio;
public class Colssion {
private static HashMap<Integer, Collidable> colissionMap = new HashMap<Integer, Collidable>();
public static void addColission(Collidable colissionObject) {
int id = colissionMap.size() + 1;
// add texture to texture map
colissionMap.put(id, colissionObject);
}
public static void updateColission() {
for (int i = 0; i < colissionMap.size(); i++) {
Collidable colissionI = colissionMap.get(i);
int playerX = (int) Levels.test.getX();
int playerY = (int) Levels.test.getY();
int playerSizeX = (int) Levels.test.getTexture().getWidth();
int playerSizeY = (int) Levels.test.getTexture().getHeight();
/*
*
*
* COLLISSION WORK ON IT
*
*
*
*/
if(playerX > colissionI.x && playerX < (colissionI.x + colissionI.xScalse))
{
if(playerX > colissionI.y && playerX < (colissionI.y + colissionI.yScalse))
{
Levels.test.left = false;
}
}
if((playerX + playerSizeX) > colissionI.x && (playerX + playerSizeX) < (colissionI.x + colissionI.xScalse))
{
if((playerX + playerSizeX) > colissionI.y && (playerX + playerSizeX) < (colissionI.y + colissionI.yScalse))
{
Levels.test.right = false;
}
}
if(playerY > colissionI.y && playerY < (colissionI.y + colissionI.yScalse))
{
Levels.test.up = false;
}
if((playerX + playerSizeX) > colissionI.x && (playerX + playerSizeX) < (colissionI.x + colissionI.xScalse))
{
Levels.test.down = false;
}
}
}
}