Examples of PhysicsComponent


Examples of com.sertaogames.cactus2d.components.PhysicsComponent

  }


  private static void addDinamicPhysicBySprite(GameObject gameObject) {
   
    PhysicsComponent p = new PhysicsComponent(1, BodyType.KinematicBody, false);
    gameObject.AddComponent(p);

    Vector2 offset = new Vector2(
        gameObject.spriteRenderer.spriteRegion.getRegionWidth()/2,
        gameObject.spriteRenderer.spriteRegion.getRegionHeight()/2);
View Full Code Here

Examples of com.sertaogames.cactus2d.components.PhysicsComponent

  }

  private static void addStaticPolignPhysic(GameObject go, Vector2 dimensions, Vector2 location) {
    GameObject side = new GameObject("side");

    PhysicsComponent p = new PhysicsComponent(1, false, false);
    side.AddComponent(p);
   
    side.transform.getLocalPosition().set(location);
    Vector2 offset = new Vector2(dimensions).mul(0.5f);
    BoxCollider coll = new BoxCollider(dimensions, offset);
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

    if (material.equals(this.material)) {
      return;
    }
    this.material = material;
    //Physics
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(material.getMass(), material.getShape(), false, true);
    physics.setFriction(material.getFriction());
    physics.setRestitution(material.getRestitution());
  }
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

      getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.MINECART, 1));
      // Set the displayed block
      setDisplayedBlock(getType().getDefaultDisplayedBlock());
    }

    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(1f, new BoxShape(0.98f, 0.49f, 0.7f), false, true);

    // Add metadata for the shaking of the Minecart and the displayed Block
    MetadataComponent metadata = getOwner().add(MetadataComponent.class);
    metadata.addMeta(Metadata.TYPE_INT, 17, VanillaData.MINECART_SHAKE_FORCE);
    metadata.addMeta(Metadata.TYPE_INT, 18, VanillaData.MINECART_SHAKE_DIR);
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

  public void onAttached() {
    super.onAttached();
    setEntityProtocol(new CreatureProtocol(CreatureType.ENDERMAN));

    //Physics
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);

    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(40);
    }
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

  @Override
  public void onAttached() {
    super.onAttached();
    setEntityProtocol(new ItemEntityProtocol());
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(1f, new BoxShape(0.27f, 0.27f, 0.27f), false, true);
    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(20);
    }

    // Add metadata for ItemStack contained
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

  @Override
  public void onAttached() {
    super.onAttached();
    setEntityProtocol(new CreatureProtocol(CreatureType.CREEPER));
    getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.GUNPOWDER, getRandom().nextInt(2))).addXpDrop((short) 5);
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);
    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(20);
    }

    NearbyComponentsSensor humanSensor = new NearbyComponentsSensor(getAI(), Human.class);
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

    setEntityProtocol(new CreatureProtocol(CreatureType.SKELETON));
    getOwner().add(EntityInventory.class);
    getOwner().add(EntityItemCollector.class);

    //Physics
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);

    DeathDrops dropComponent = getOwner().add(DeathDrops.class);
    dropComponent.addDrop(new ItemStack(VanillaMaterials.ARROW, random.nextInt(2)));
    dropComponent.addDrop(new ItemStack(VanillaMaterials.BONE, random.nextInt(2)));
    dropComponent.addXpDrop((short) 5);
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

    setEntityProtocol(new CreatureProtocol(CreatureType.ZOMBIE));
    getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.ROTTEN_FLESH, getRandom().nextInt(2))).addXpDrop((short) 5);
    getOwner().add(EntityInventory.class);
    getOwner().add(EntityItemCollector.class);

    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);

    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(20);
    }
View Full Code Here

Examples of org.spout.api.component.entity.PhysicsComponent

  @Override
  public void onTick(float dt) {
    Player player = (Player) getOwner();
    Transform ts = player.getPhysics().getTransform();
    PlayerInputState inputState = player.input();
    PhysicsComponent sc = player.getPhysics();

    Vector3f offset = Vector3f.ZERO;
    float speed = 50;
    if (inputState.getForward()) {
      offset = offset.sub(ts.forwardVector().mul(speed * dt));
 
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.