Package net.sf.fysix.math

Examples of net.sf.fysix.math.Vector2d


      // PLAYER 1
      //
      int shots = input1.checkEvent(InputAction.SHOOT);
      if (shots > 0) {
        WorldObject bullet = new Planet(2,50, TypeE.WEAPON_SHOT_MINE);
        Vector2d dir = new Vector2d(Math.cos(player1.getWorldObject().getRotation()), Math.sin(player1.getWorldObject().getRotation()));
        Vector2d pos = player1.getWorldObject().getPosition();
        pos.addScaled(16, dir);
        bullet.setPosition(pos);
        dir.scale(1000000);
        //bullet.setVelocity(dir);
        world.addObject(bullet, true);
        bullet.applyImpulse(dir);
        //dir.scale(-1);
        //playerShip.applyImpulse(dir);
      }
     
      //
      // PLAYER 2
      //
      shots = input2.checkEvent(InputAction.SHOOT);
      if (shots > 0) {
        WorldObject bullet = new Planet(2,50, TypeE.WEAPON_SHOT_MINE);
        Vector2d dir = new Vector2d(Math.cos(player2.getWorldObject().getRotation()), Math.sin(player2.getWorldObject().getRotation()));
        Vector2d pos = player2.getWorldObject().getPosition();
        pos.addScaled(16, dir);
        bullet.setPosition(pos);
        dir.scale(1000000);
        //bullet.setVelocity(dir);
        world.addObject(bullet, true);
        bullet.applyImpulse(dir);
      }
     
      // Advance the game time by one tick
      engine.tick(1.0 / tickRate);
      nextTick += NANOS_PER_SEC / tickRate;
     
      if(levelEditor == false){
        worldDisplay1.scrollTo(player1.getWorldObject().getPosition(), 1.0 / tickRate);
        worldDisplay2.scrollTo(player2.getWorldObject().getPosition(), 1.0 / tickRate);
      } else {
        worldDisplay1.scrollTo(new Vector2d(panX, panY), 1.0 / tickRate);
      }
     
      // InputControl
      if(ctrlInput.checkEvent(InputAction.QUIT) > 0){
        System.exit(0);
View Full Code Here


  public void setWorld(World world) {
    this.world = world;
  }

  public void scrollTo(Vector2d v, double dt) {
    Vector2d tmp = new Vector2d(v);
    tmp.sub(center);
    double dist = tmp.length();
    center.addScaled(dist * dt / 1000, tmp);
  }
View Full Code Here

    renderStars(g2d, top * range + center.getY(), bottom * range + center.getY(), left * range + center.getX(), right * range + center.getX());
   
    AffineTransform oldTrans = g2d.getTransform();
    for (WorldObject wo : world.getObjects()) {
      Vector2d pos = wo.getPosition();
      g2d.translate(pos.getX(), pos.getY());
      g2d.rotate(wo.getRotation());
      View view = wo.getView();
      view.render(g2d);
      g2d.setTransform(oldTrans);
    }
View Full Code Here

TOP

Related Classes of net.sf.fysix.math.Vector2d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.