Guest User

Untitled

a guest
Oct 20th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. public void checkCollision() {
  2. for (int i = 0; i < objects.size(); i++) {
  3. for (int j = i + 1; j < objects.size(); j++) {
  4.  
  5. // the code does get here!
  6.  
  7. Object_Shell o1 = objects.get(i);
  8. Object_Shell o2 = objects.get(j);
  9. if ((o1.collisionArea.intersects(o2.collisionArea))
  10. || (o2.collisionArea.intersects(o1.collisionArea))) {
  11. System.out.println("checkcollision");
  12. // LINE ABOVE DOESN'T DETECT ANY COLLISIONS
  13. // THE ISSUE HAS TO BE HERE, BECAUSE I HAVE CREATED A FEW GAMES WITH THE SAME
  14. // CODE YOU DO NOT SEE AND ALL THE INTERSECT STUFF IS THE SAME
  15. if ((o1 instanceof Protagonist && o2 instanceof Block)
  16. || (o2 instanceof Protagonist && o1 instanceof Block)) {
  17. System.out.println("Protagonist & Block");
  18. Protagonist charlie = (o1 instanceof Protagonist) ? (Protagonist) o1 : (Protagonist) o2;
  19. Block cubicon = (o1 instanceof Block) ? (Block) o1 : (Block) o2;
  20. // if (cubicon.hardness == 0) {
  21. //
  22. // }
  23. charlie.speedThroughBlock = 10 - cubicon.hardness;
  24. // charlie.yspeed = charlie.speedThroughBlock;
  25. if (charlie.xspeed != 0) {
  26. if (charlie.xspeed > 0) {
  27. charlie.xspeed -= charlie.speedThroughBlock;
  28. } else if (charlie.xspeed < 0) {
  29. charlie.xspeed += charlie.speedThroughBlock;
  30. }
  31. }
  32. if (charlie.yspeed != 0) {
  33. if (charlie.yspeed > 0) {
  34. charlie.yspeed -= charlie.speedThroughBlock;
  35. } else if (charlie.yspeed < 0) {
  36. charlie.yspeed += charlie.speedThroughBlock;
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment