Example #1
0
 // calculate the y-direction on collision
 public void bounceY() {
   double tx = vel * Math.cos(theta);
   double ty = vel * Math.sin(theta);
   theta = Math.atan2(-ty, tx);
   if (y < 0) {
     y = -y;
   }
   if (y > Engine.getGameHeight()) {
     y = Engine.getGameHeight() * 2 - y;
   }
   if (y < 0 || y > Engine.getGameHeight()) {
     y = Math.random() * Engine.getGameHeight();
   }
 }
Example #2
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;
 }