Advertisement
Guest User

Untitled

a guest
Jun 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. public void update(int delta) {
  2.  
  3. super.update(delta);
  4.  
  5. if (MoveLocation != null) {
  6. MoveTo();
  7. }
  8. if (getDeltaTick() > speed) {
  9.  
  10. if (collide != null) {
  11. //System.out.println("X: " + collide.getBoundingBox().getLeft() + " Y: " + collide.getBoundingBox().getTop() + " BX:" + collide.getBoundingBox().getRight() + " BY:" + collide.getBoundingBox().getBottom());
  12. // INSERT COLLISION DETECTION HERE!!!!!
  13. // TEST CODE
  14. ArrayList<Entity> ent = this.getEntity().getWorld().getEntityManager().getEntities();
  15. ent.forEach((e) -> {
  16. if (e.hasComponent(Component.COLLIDABLE) && e.getID() != this.getEntity().getID()) {
  17.  
  18. Collidable test = (Collidable)e.getComponent(Component.COLLIDABLE);
  19. if (collide.willCollide(test.getBoundingBox(),move_X,move_Y)) {
  20. //System.out.println("collide! entity:" + e.getID() + " " + test.getBoundingBox().getLeft() + "player:" + collide.getBoundingBox().getRight());
  21. move_X = 0;
  22. move_Y = 0;
  23. };
  24. }
  25. });
  26. collide.getBoundingBox().moveLocation(move_X, move_Y);
  27. }
  28.  
  29. location.move(move_X, move_Y);
  30.  
  31. resetDeltaTick();
  32. }
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement