Package com.tankz.components

Examples of com.tankz.components.Tower


  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");
View Full Code Here


    world.getManager(GroupManager.class).add(e, "tanks");

    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);
View Full Code Here

TOP

Related Classes of com.tankz.components.Tower

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.