Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1.   public void collisionCheck() {
  2.     for (GeometricObject geo : geos) {
  3.         // Das hier sieht gut aus, beide Faelle abgedeck
  4.       if (geo.corner.x + geo.width >= getWidth() || geo.corner.x <= 0) {
  5.         geo.velocity.x = geo.velocity.x * -1;
  6.       }
  7.         // Das hier sieht auch gut aus, auch beide Faelle abgedeck
  8.       if (geo.corner.y + geo.height >= getHeight() || geo.corner.y <= 0) {
  9.         geo.velocity.y = geo.velocity.y * -1;
  10.       }
  11.  
  12.       for (GeometricObject geox : geos) {
  13.         // Das hier ist komisch? Die klammern sind falsch? in deinem equals body befindet sich nichts.
  14.         if (!geo.equals(geox)) {
  15.         }
  16.  
  17.         // Der swap an sich seht aber gut aus
  18.         if (geo.touches(geox)) {
  19.           Vertex tmp = geo.velocity;
  20.           geo.velocity = geox.velocity;
  21.           geox.velocity = tmp;
  22.         }
  23.       }
  24.     }
  25.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement