private Position checkPixelCollision(Position a, Position[][] b) { for (Position[] p : b) { for (Position q : p) { if (q.isValidPosition() && a.isValidPosition() && a.getX() != -1 && q.getX() != -1) { // a.getX() == q.getX() && a.getY() == q.getY() if (a.getX() == q.getX() && a.getY() == q.getY()) { return new Position(a.getX(), a.getY()); } } } } return new Position(); }
private CollisionInformation checkBitMapCollision(Article b, Article a) { CollisionFinder finder = new CollisionFinder(a.getBitMap().getByteArray()); while (finder.hasNext()) { Position p = finder.next(); if (p.getX() != -1 && p.getY() != -1) { CollisionFinder secondArticle = new CollisionFinder(b.getBitMap().getByteArray()); while (secondArticle.hasNext()) { Position q = secondArticle.next(); if (q.isValidPosition()) { if (p.getX() == q.getX() && p.getY() == q.getY()) { return new CollisionInformation("Left", true); } } } // for (Position[] q: b.getBitMap().getByteArray()) { // for (Position r: q) { // if (r.getX() != -1 && r.getY() != -1) { // // if (p.getX() == r.getX() && p.getY() == r.getY()) { //// if (Math.floor(p.getX()) == Math.floor( r.getX()) && Math.floor(p.getY()) == // Math.floor(r.getY())) { // return new CollisionInformation(getIncidenceDirection(a, r), true); // } // } // } // } } else { } } return new CollisionInformation("", false); // for (Position[] p : a.getBitMap().getByteArray()) { // for (Position q : p) { // Position temp = checkPixelCollision(q, b.getBitMap().getByteArray()); // if (temp.isValidPosition()) { // return new CollisionInformation(getIncidenceDirection(a, temp), true); // } // // } // } // return new CollisionInformation("", false); }