Beispiel #1
0
 // calculate the x-direction on collision
 public void bounceX() {
   double tx = vel * Math.cos(theta);
   double ty = vel * Math.sin(theta);
   theta = Math.atan2(ty, -tx);
   if (x < 0) {
     x = -x;
   }
   if (x > Engine.getGameWidth()) {
     x = Engine.getGameWidth() * 2 - x;
   }
   if (x < 0 || x > Engine.getGameWidth()) {
     x = Math.random() * Engine.getGameWidth();
   }
 }
Beispiel #2
0
 public Entity(boolean left) {
   this();
   theta = (Math.random() - .5) * Math.PI;
   vel = Math.random() * 3;
   if (left) x = 1;
   else x = Engine.getGameWidth() - 1;
   theta += Math.PI;
 }
Beispiel #3
0
 public Entity() {
   x = Math.random() * Engine.getGameWidth();
   y = Math.random() * Engine.getGameHeight();
   fTheta = Math.random() * Math.PI * 2;
   pTheta = Math.random() * Math.PI * 2;
   dFTheta = (Math.random() * 2 - 1) * Math.PI / 50;
   dPTheta = (Math.random() * 2 - 1) * Math.PI / 50;
   mass = 100;
 }