Package com.tankz.components

Examples of com.tankz.components.Ammo


  public void initialize() {
    ammoMapper = world.getMapper(Ammo.class);
  }
 
  protected void process(Entity e) {
    Ammo ammo = ammoMapper.get(e);
    ammo.addAmmo(1);
  }
View Full Code Here


    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

    }
    g.translate(-35, -container.getHeight()+45);
  }

  private void renderAmmo() {
    Ammo ammo = ammoMapper.get(player);
    g.translate(container.getWidth()-64, container.getHeight()-45);
    {
      font.drawString(-16, 8, "Ammo");
      g.rotate(0, 0, -90);
      float ammoStatus = ammo.getAmmoStatus();
      g.setDrawMode(Graphics.MODE_ADD);
      statusBar.draw(0,0,statusBar.getWidth()*ammoStatus, statusBar.getHeight(), 0,0,statusBar.getWidth()*ammoStatus, statusBar.getHeight(), ammoStatus<0.25?Color.red:ammoStatus<0.6?Color.yellow:Color.green);
      statusBar.draw(statusBar.getWidth()*ammoStatus,0,statusBar.getWidth(), statusBar.getHeight(), statusBar.getWidth()*ammoStatus,0,statusBar.getWidth(), statusBar.getHeight(), new Color(0.15f,0.15f,0.15f));
      g.setDrawMode(Graphics.MODE_NORMAL);
      g.rotate(0, 0, 90);
View Full Code Here

    e.addComponent(new SpatialForm("mammothTank"));
    e.addComponent(new Velocity());
    e.addComponent(new TurnFactor());
    e.addComponent(new Tower());
    e.addComponent(new Health(110, 150));
    e.addComponent(new Ammo(78, 150));

    Body b = new Body(new Box(125, 104), 1f);
    b.setUserData(e);
    b.setPosition(x, y);
    b.setDamping(0.1f);
View Full Code Here

TOP

Related Classes of com.tankz.components.Ammo

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.