Package org.spout.api.math

Examples of org.spout.api.math.Rectangle


    final RenderPartPacksComponent quickbarRect = widget.add(RenderPartPacksComponent.class);
    quickbarRect.add(quickbarPack);

    final RenderPart quickbarBgRect = new RenderPart();
    quickbarBgRect.setColor(Color.WHITE);
    quickbarBgRect.setSprite(new Rectangle(START_X, -1f, 1.42f * SCALE, 0.17f));
    quickbarBgRect.setSource(new Rectangle(0, 0, 0.71f, 0.085f));
    quickbarPack.add(quickbarBgRect, 1);

    final RenderPart quickbarSlotRect = new RenderPart();
    quickbarSlotRect.setColor(Color.WHITE);
    quickbarSlotRect.setSource(new Rectangle(0, 22f / 256f, 30f / 256f, 24f / 256f));
    quickbarSlotRect.setSprite(new Rectangle(-0.72f * SCALE + (0 * .1175f), -1.005f, 0.24f * SCALE, 0.24f * SCALE));
    quickbarPack.add(quickbarSlotRect, 0);

    attach();
  }
View Full Code Here


    if (slot < 0 || slot > 8) {
      throw new IllegalArgumentException("Slot must be between 0 and 8");
    }

    final RenderPart rect = quickbarPack.get(1);
    rect.setSprite(new Rectangle(-0.72f * SCALE + (slot * .1175f), -1.005f, 0.24f * SCALE, 0.24f * SCALE));
    widget.update();
  }
 
View Full Code Here

    float x = 0.09f * SCALE;
    float dx = 0.06f * SCALE;
    for (int i = 0; i < 10; i++) {
      final RenderPart hunger = new RenderPart();
      hunger.setColor(Color.WHITE);
      hunger.setSprite(new Rectangle(x, -0.77f, 0.075f * SCALE, 0.07f));
      hunger.setSource(new Rectangle(52f / 256f, 27f / 256f, 9f / 256f, 9f / 256f));
      hungerPack.add(hunger);
      x += dx;
    }

    x = 0.09f * SCALE;
    for (int i = 0; i < 10; i++) {
      final RenderPart hungerBg = new RenderPart();
      hungerBg.setColor(Color.WHITE);
      hungerBg.setSprite(new Rectangle(x, -0.77f, 0.075f * SCALE, 0.07f));
      hungerBg.setSource(new Rectangle(16f / 256f, 27f / 256f, 9f / 256f, 9f / 256f));
      hungerPack.add(hungerBg);
      x += dx;
    }

    attach();
View Full Code Here

            y = -0.765f; // Twitch up
          } else if (rand == 1) {
            y = -0.775f; // Twitch down
          }

          part.setSprite(new Rectangle(x, y, 0.075f * SCALE, 0.07f));
          partBg.setSprite(new Rectangle(x, y, 0.075f * SCALE, 0.07f));
          x += dx;
        }
        hungerTicks++;
        widget.update();
      } else if (hungerTicks == 100) {
        // Reset hunger bar to normal
        x = 0.09f * SCALE;
        for (int i = 0; i < 10; i++) {
          parts.get(i).setSprite(new Rectangle(x, -0.77f, 0.075f * SCALE, 0.07f));
          parts.get(i + 10).setSprite(new Rectangle(x, -0.77f, 0.075f * SCALE, 0.07f));
          x += dx;
        }
        hungerTicks = 0;
      } else {
        hungerTicks++;
View Full Code Here

    //Widget testWidget = getOwner().get(HUD.class).getHungerMeter().getWidget();

    if (hunger == 0) {

      for (int i = 0; i < 10; i++) {
        hungerPack.get(i).setSource(new Rectangle(142f / 256f, 27f / 256f, 9f / 256f, 9f / 256f)); // Foreground
      }

      for (int i = 10; i < 20; i++) {
        hungerPack.get(i).setSource(new Rectangle(bx / 256f, 27f / 256f, 9f / 256f, 9f / 256f)); // Background
      }
    } else {

      for (int i = 9; i >= 0; i--) {
        if (hunger == 0) {
          fx = 142f; // Empty
        } else if (hunger == 1) {
          fx += 9f; // Half
          hunger = 0;
        } else {
          hunger -= 2; // Full
        }
        hungerPack.get(i).setSource(new Rectangle(fx / 256f, 27f / 256f, 9f / 256f, 9f / 256f));
      }

      for (int i = 19; i >= 10; i--) {
        hungerPack.get(i).setSource(new Rectangle(bx / 256f, 27f / 256f, 9f / 256f, 9f / 256f));
      }
    }

    widget.update();
  }
View Full Code Here

TOP

Related Classes of org.spout.api.math.Rectangle

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.