Package net.sf.fysix.world

Examples of net.sf.fysix.world.WorldObject


        Body body2 = cp.shape2.getBody();
        float mass1 = body1.getMass();
        float mass2 = body2.getMass();

       
        WorldObject wo1 = null;
        WorldObject wo2 = null;
       
      ObjectHistory oh = objectHist.get(currentHistory);
      for (WorldObjectState wos : oh.stateobjs){
        if(wos.getBody().equals(body1) || wos.getBody().equals(body2)){
          System.out.println("Velocity : " + wos.getVelocity().length());
          System.out.println("Mass : " + wos.getMass());
          System.out.println("Type : " + wos.getType());
          if(wo1 == null){
            wo1 = wos.getWOPtr();
          } else if(wo2 == null){
            wo2= wos.getWOPtr();
            break;
          }
        }
      }
       
      // Give damage to each other depending on the opposite velocity and mass
      // TODO: USCH!
      if(wo1 != null && wo2 != null){
        if(wo1.getType().compareTo(TypeE.GAME_MAP) != 0){
          wo1.doDamage(1000);
        }
        if(wo1.isDestroyed()){
          removeBodyLst.add(body1);
        }
     
        if(wo2.getType().compareTo(TypeE.GAME_MAP) != 0){
          wo2.doDamage(1000);
        }
        if(wo2.isDestroyed()){
          removeBodyLst.add(body2);
        }
      }
    }
    contacts.clear(); // TODO: DON'T USE CONTACTS, MAKE A COPY!
View Full Code Here


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

TOP

Related Classes of net.sf.fysix.world.WorldObject

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.