Examples of Physics


Examples of com.heatonresearch.aifh.examples.ca.mergelife.physics.Physics

     *
     * @param row The row of the universe to generate mutations from.
     * @param col The column of the universe to generate mutations from.
     */
    public synchronized void mutateAcross(final int row, final int col) {
        final Physics sourcePhysics = this.grid[row][col].getUniverseRunner()
                .getPhysics();
        for (int currentRow = 0; currentRow < this.rows; currentRow++) {
            for (int currentCol = 0; currentCol < this.cols; currentCol++) {
                if (currentRow != row || currentCol != col) {
                    this.grid[currentRow][currentCol].getUniverseRunner()
View Full Code Here

Examples of com.heatonresearch.aifh.examples.ca.mergelife.physics.Physics

     * @param row The row.
     * @param col The column.
     */
    public void runSingular(final int row, final int col) {
        this.owner.performStop();
        final Physics sourcePhysics = this.grid[row][col].getUniverseRunner()
                .getPhysics();
        final SingularUniverseViewer v = new SingularUniverseViewer(
                sourcePhysics, 2);
        v.setVisible(true);
    }
View Full Code Here

Examples of com.heatonresearch.aifh.examples.ca.mergelife.physics.Physics

                / MultiverseViewer.getConfig().getZoom();
        final int height = MultiverseViewer.getConfig().getPaneHeight()
                / MultiverseViewer.getConfig().getZoom();

        final Universe universe = new Universe(height, width, 3);
        final Physics physics = new MergePhysics(universe);

        universe.randomize(rnd);
        physics.randomize();

        this.universeRunner = new UniverseRunner(universe, physics);
        this.visualizer = new UniverseVisualizer(universe,
                MultiverseViewer.getConfig().getZoom());
    }
View Full Code Here

Examples of com.heatonresearch.aifh.examples.ca.mergelife.physics.Physics

    public void componentResized(final ComponentEvent e) {
        final int width = getWidth() / this.zoom;
        final int height = getHeight() / this.zoom;

        final Universe universe = new Universe(height, width, 3);
        final Physics physics = new MergePhysics(universe);
        physics.copyData(this.sourceData);
        universe.randomize(this.rnd);
        this.runner = new UniverseRunner(universe, physics);
        this.visual = new UniverseVisualizer(universe, this.zoom);

        if (!this.running) {
View Full Code Here

Examples of com.tankz.components.Physics

  }

  protected void updatePlayer(Entity e) {
    Velocity v = velocityMapper.get(e);
    TurnFactor tf = turnFactorMapper.get(e);
    Physics c = collidableMapper.get(e);
   
    updateMoving(e);
    //updateRotating(e);

    //updateMoving(t, v, world.getDelta());
View Full Code Here

Examples of com.tankz.components.Physics

    //wc.getBody().setRotation(t.getRotation());
  }
 

  private void updateMoving(Entity e) {
    Physics physics = collidableMapper.get(e);
   
    if(forward) {
      float ax = (TrigLUT.cosDeg(physics.getRotation()) * world.getDelta());
      float ay = (TrigLUT.sinDeg(physics.getRotation()) * world.getDelta());
     
      velocity += world.getDelta() * 0.005f;
      if(velocity > 1.25f) {
        velocity = 1.25f;
      }
     
      physics.getBody().adjustVelocity(new Vector2f(velocity*ax, velocity*ay));
    } else if(velocity > 0) {
      velocity = 0;
    }
   
    if(reverse) {
      float ax = (TrigLUT.cosDeg(physics.getRotation()) * world.getDelta());
      float ay = (TrigLUT.sinDeg(physics.getRotation()) * world.getDelta());
     
      velocity -= world.getDelta() * 0.0025f;
      if(velocity < -1) {
        velocity = -1;
      }
     
      physics.getBody().adjustVelocity(new Vector2f(velocity*ax, velocity*ay));
    } else if(velocity < 0) {
      velocity += world.getDelta() * 1f;
      if(velocity > 0) {
        velocity = 0;
      }
View Full Code Here

Examples of com.tankz.components.Physics

    physicsMapper = world.getMapper(Physics.class);
  }

  @Override
  protected void process(Entity e) {
    Physics physics = physicsMapper.get(e);
   
    if(physics.getX() < boundsStartX)
      physics.setLocation(boundsStartX, physics.getY());//physics.applyForce(world.getDelta() * 300, 0);
    else if(physics.getX() > boundsEndX)
      physics.setLocation(boundsEndX, physics.getY());//physics.applyForce(world.getDelta() * -300, 0);
   
    if(physics.getY() < boundsStartY)
      physics.setLocation(physics.getX(), boundsStartY);//physics.applyForce(0, world.getDelta() * 300);
    else if(physics.getY() > boundsEndY)
      physics.setLocation(physics.getX(), boundsEndY);//physics.applyForce(0, world.getDelta() * -300);

  }
 
View Full Code Here

Examples of com.tankz.components.Physics

    tf.setFactor(turnFactor);
  }

 
  private void updateRotating(Entity e) {
    Physics physics = collidableMapper.get(e);
   
    TurnFactor turnFactor = turnFactorMapper.get(e);

    if(turnRight) {
      physics.getBody().adjustRotation(turnFactor.getFactor() * (reverse?-1:1));
    }
    else if(turnLeft) {
      physics.getBody().adjustRotation(turnFactor.getFactor() * (reverse?-1:1));
    }
  }
 
View Full Code Here

Examples of com.tankz.components.Physics

  }

  protected void updatePlayer(Entity e) {
    Velocity v = velocityMapper.get(e);
    TurnFactor tf = turnFactorMapper.get(e);
    Physics physics = physicsMapper.get(e);

    Tower tower = towerMapper.get(e);
    Ammo ammo = ammoMapper.get(e);

    updateTowerRotation(tower, physics);

    updateRecoil(tower);

    if (shoot && ammo.hasAmmo(10)) {
      shoot = false;
      recoil = true;

      // Create bullets for both barrels.
      {
        float x = Utils.getRotatedX(physics.getX() + 75, physics.getY() - 10, physics.getX(), physics.getY(), tower.getRotation());
        float y = Utils.getRotatedY(physics.getX() + 75, physics.getY() - 10, physics.getX(), physics.getY(), tower.getRotation());
        EntityFactory.createBullet(world, x, y, tower.getRotation(), e);
      }
      {
        float x = Utils.getRotatedX(physics.getX() + 75, physics.getY() + 10, physics.getX(), physics.getY(), tower.getRotation());
        float y = Utils.getRotatedY(physics.getX() + 75, physics.getY() + 10, physics.getX(), physics.getY(), tower.getRotation());
        EntityFactory.createBullet(world, x, y, tower.getRotation(), e);
      }

      // apply force to moving tank.
      float counterRotation = tower.getRotation()+180;
      float force = 2000f;
      physics.setForce(force*TrigLUT.cosDeg(counterRotation), force*TrigLUT.sinDeg(counterRotation));

      // add sound.
      EntityFactory.createSound(world, "sounds/shoot.wav");

      ammo.reduceBy(10);
View Full Code Here

Examples of com.tankz.components.Physics

      g.drawRect(offsetX*scaleX, offsetY*scaleY, scaleX*cameraSystem.getWidth(), scaleY*cameraSystem.getHeight());
     
      ImmutableBag<Entity> entities = world.getManager(GroupManager.class).getEntities("crates");
      for(int i = 0; entities.size() > i; i++) {
        Entity crate = entities.get(i);
        Physics cratePhysics = physicsMapper.get(crate);
        float crateX = cratePhysics.getX()*scaleX;
        float crateY = cratePhysics.getY()*scaleY;
        g.fillRect(crateX-1, crateY-1, 2, 2);
      }
     
      ImmutableBag<Entity> tanks = world.getManager(GroupManager.class).getEntities("tanks");
      for(int i = 0; tanks.size() > i; i++) {
        Entity t = tanks.get(i);
        String tp = world.getManager(PlayerManager.class).getPlayer(t);
        Physics physics = physicsMapper.get(t);
        g.setColor(Color.green);
        float tx = physics.getX()*scaleX;
        float ty = physics.getY()*scaleY;
        g.fillRect(tx-3, ty-3, 6, 6);
      }
     
    }
    g.translate(-container.getWidth()+minimapWidth+20,-20);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.