Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void update(int delta) {
- super.update(delta);
- if (MoveLocation != null) {
- MoveTo();
- }
- if (getDeltaTick() > speed) {
- if (collide != null) {
- //System.out.println("X: " + collide.getBoundingBox().getLeft() + " Y: " + collide.getBoundingBox().getTop() + " BX:" + collide.getBoundingBox().getRight() + " BY:" + collide.getBoundingBox().getBottom());
- // INSERT COLLISION DETECTION HERE!!!!!
- // TEST CODE
- ArrayList<Entity> ent = this.getEntity().getWorld().getEntityManager().getEntities();
- ent.forEach((e) -> {
- if (e.hasComponent(Component.COLLIDABLE) && e.getID() != this.getEntity().getID()) {
- Collidable test = (Collidable)e.getComponent(Component.COLLIDABLE);
- if (collide.willCollide(test.getBoundingBox(),move_X,move_Y)) {
- //System.out.println("collide! entity:" + e.getID() + " " + test.getBoundingBox().getLeft() + "player:" + collide.getBoundingBox().getRight());
- move_X = 0;
- move_Y = 0;
- };
- }
- });
- collide.getBoundingBox().moveLocation(move_X, move_Y);
- }
- location.move(move_X, move_Y);
- resetDeltaTick();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement