コード例 #1
1
ファイル: THA.java プロジェクト: tlulu/Tetris-Platformer
 /** Checks the timers and start actions according to it */
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == buttonTimer) {
     // From the Btns class
     if (Btns.startB) {
       unPause();
       this.requestFocus();
     }
     if (Btns.pauseB) {
       pause();
       this.requestFocus();
     }
   }
   if (e.getSource() == fallTime) {
     shapes.get(0).fall(map, character);
     repaint();
     if (shapes.get(0).hitGround()) {
       map.addShape(shapes.get(0));
       map.clearLines();
       shapes.remove(0);
       addShape();
     }
   }
   if (e.getSource() == aiMove) {
     if (aiCommand.size() > 0) {
       shapes.get(0).aiCommand(map, aiCommand.get(0), shapeTrack);
       if (aiCommand.get(0) != 0) {
         shapeTrack.add(aiCommand.get(0));
       }
       aiCommand.remove(0);
       repaint();
     }
   }
   if (e.getSource() == moveTime) {
     character.checkUnderWater(water.getY());
     character.checkDeath(shapes.get(0).getShape());
     character.move(map, shapes.get(0));
     if (character.checkExit() == true) {
       MyFrame.screen = "gameover";
       pause();
       character.setDeath(false);
     }
     if (character.getDeath() == true) {
       pause();
       MyFrame.screen = "gameover";
       character.setDeath(false);
     }
   }
   if (e.getSource() == bulletMoveTime) {
     for (int i = 0; i < weaponList.size(); i++) {
       weaponList.get(i).move((int) character.getX(), (int) character.getY());
       if (!weaponList.get(i).getWeapon().equalsIgnoreCase("laser")) {
         int[] col = weaponList.get(i).collide(shapes.get(0), map);
         if (col[2] == 0) {
           map.change(
               weaponList
                   .get(i)
                   .damage(
                       map.getMap(),
                       col[1] / Square.SIZE,
                       col[0] / Square.SIZE,
                       THA.HEIGHT / Square.SIZE,
                       THA.WIDTH / Square.SIZE));
         } else if (col[2] == 1) {
           shapes
               .get(0)
               .change(
                   weaponList
                       .get(i)
                       .damage(
                           shapes.get(0).getShape(),
                           shapes.get(0).getIndex(col[0], col[1])[0],
                           shapes.get(0).getIndex(col[0], col[1])[1],
                           4,
                           4));
         }
         i = removeBullet(i);
         if (shapes.get(0).shapeGone()) {
           shapes.remove(0);
           addShape();
         }
       } else {
         map.change(
             weaponList
                 .get(i)
                 .damage(
                     map.getMap(),
                     (int) (character.getX() / Square.SIZE),
                     (int) (character.getY() / Square.SIZE),
                     THA.HEIGHT / Square.SIZE,
                     THA.WIDTH / Square.SIZE));
       }
       if (weaponList.get(i).getRemove() == true) {
         weaponList.remove(i);
       }
     }
   }
   if (System.currentTimeMillis() - startWater > 100 * 500 && startWater != 0) {
     if (e.getSource() == waterTime) {
       water.move();
     }
   }
   // delays for weapons
   if (e.getSource() == bulletTime) {
     bshoot = true;
   }
   if (e.getSource() == grenadeTime) {
     gshoot = true;
   }
   if (e.getSource() == laserTime) {
     lshoot = true;
   }
   if (e.getSource() == shotgunTime) {
     sgshoot = true;
   }
   repaint();
 }
コード例 #2
0
  public void loadWater() {
    System.out.println("Load water");

    water = Loader.load(assetManager, map, "water", false, Water.class);
    if (water == null) {
      water = new Water();
    }
    water.init(this, terrain, null, reflectNode);
  }
コード例 #3
0
ファイル: Pva.java プロジェクト: Gumtree/gumtree
  // Returns the refractive index of pva solutions as a function of g/l pva concentration
  // Data		Poly(vinyl alcohol): basic properties and uses by J G Pritchard (1970)
  //			pva refractive index increment fitted to modified Cauchy equation:
  //				dn = 1 + a1*(1 + b1/(lambda*lambda))
  // concn	g/l concentration of pva
  // temp     temperature (degree Celsius) (t = 30C for original pva increment calculation)
  // wavl     wavelength in metres
  public static double refractIndex(double concn, double wavl, double temp) {
    double refind, rfwater, rfincr;
    double a1 = -0.998419, b1 = -1.87778e-17;

    rfwater = Water.refractIndex(wavl, temp);
    rfincr = 1.0 + a1 * (1.0 + b1 / Math.pow(wavl, 2));
    refind = rfwater + rfincr * concn / 10.0;

    return refind;
  }
コード例 #4
0
ファイル: Pva.java プロジェクト: Gumtree/gumtree
  // METHODS
  // Returns the viscosity (Pa s) of aqueous pva solutions as a function of the
  // g/l pva concentration (concn), the temperature [Celsius](temp) and the
  // molecualr weight of the pva (molwt).
  // Empirical equation from Poly(vinyl alcohol): basic properties and uses by J G Pritchard (1970)
  public static double viscosity(double concn, double molwt, double temp) {

    double intVisc30, intVisc20, intViscT, spViscT, waterViscT, viscosity, concndlpg;

    intVisc30 = 4.53e-4 * Math.pow(molwt, 0.64);
    intVisc20 = intVisc30 * 1.07;
    intViscT = intVisc20 * Math.pow(1.07, -(temp - 20) / 10);
    concndlpg = concn / 10.0;
    spViscT = concndlpg * (intViscT + 0.201 * concndlpg * Math.pow(intViscT, 2.28));
    waterViscT = Water.viscosity(temp);
    viscosity = (spViscT + 1.0) * waterViscT;

    return viscosity;
  }
コード例 #5
0
ファイル: THA.java プロジェクト: tlulu/Tetris-Platformer
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   map.drawMap(g);
   gs.imitate(shapes.get(0), map);
   gs.draw(g);
   if (shapes.size() > 0) shapes.get(0).draw(g);
   character.putCharacter(g); // draws the character
   for (int i = 0; i < weaponList.size(); i++) {
     weaponList.get(i).draw(g); // draws each weapon object
   }
   water.draw(g); // draws the water image
   g.setColor(Color.black);
   g.drawString("score: ", 300, 350);
 }
コード例 #6
0
  public MouseStatus getMouseCollision() {
    if (gui.isMouseOver()) {
      return null;
    }

    Vector3f origin = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);
    Vector3f direction = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);
    direction.subtractLocal(origin).normalizeLocal();

    Ray ray = new Ray(origin, direction);
    CollisionResults results = new CollisionResults();
    clickableNode.collideWith(ray, results);

    Vector3f v3f = null;
    Model m = null;

    if (results.size() > 0) {

      CollisionResult closest = results.getClosestCollision();
      Geometry g = closest.getGeometry();

      v3f = closest.getContactPoint();
      m = Model.Geometry2Model(g);

      // return new
      // MouseStatus(m,closest.getContactPoint().getX(),closest.getContactPoint().getZ());
    }

    if (water != null) {
      Vector3f waterv = water.collision(ray);
      if (waterv != null && (v3f == null || waterv.distance(origin) < v3f.distance(origin))) {
        v3f = waterv;
      }
    }

    if (v3f != null) return new MouseStatus(m, v3f.getX(), v3f.getZ());

    return null;
  }