Exemplo n.º 1
0
  public void move() throws SuicideException {
    this.prevDir = this.curDir;
    if (this.extend) {
      this.extend = false;
      /* If the snake should grow,
       * simply add a new part in the front of the tail,
       * where the head currently is. */
      Tail newTail =
          new Tail(
              this.snakehead,
              this.TailTextureRegion,
              this.snakehead.getVertexBufferObjectManager());
      this.attachChild(newTail);
      this.tail.addFirst(newTail);
    } else {
      if (this.tail.isEmpty() == false) {
        /* First move the end of the tail to where the head currently is. */
        Tail tailEnd = this.tail.removeLast();
        tailEnd.setCell(this.snakehead);
        this.tail.addFirst(tailEnd);
      }
    }

    /* The move the head into the direction of the snake. */
    this.snakehead.setCell(this.getNextX(), this.getNextY());

    /* Check if head collides with tail. */
    for (int i = 0; i < this.tail.size(); i++) {
      if (this.snakehead.sameCell(this.tail.get(i))) {
        throw new SuicideException();
      }
    }
  }
  private void start(final Id id) {
    if (id == null) {
      throw new IllegalArgumentException("id is null");
    }
    final Pattern waitForPattern = compileWaitForPattern(id);

    logger.info("Starting " + id);

    try {
      if (!imageExists(id)) {
        logger.info("Image does not exist, so building it");
        build(id);
      }
    } catch (DockerException e) {
      throw new OrchestrationException(e);
    }

    try {
      Container existingContainer = findContainer(id);

      if (existingContainer == null) {
        logger.info("No existing container so creating and starting new one");
        startContainer(createNewContainer(id));

      } else if (!isImageIdFromContainerMatchingProvidedImageId(existingContainer.getId(), id)) {
        logger.info("Image IDs do not match, removing container and creating new one from image");
        removeContainer(existingContainer);
        startContainer(createNewContainer(id));

      } else if (isRunning(id)) {
        logger.info("Container already running");

      } else {
        logger.info("Starting existing container " + existingContainer.getId());
        startContainer(existingContainer.getId());
      }

      try (Tail tail = tailFactory.newTail(docker, findContainer(id), logger)) {
        tail.start();

        for (Plugin plugin : plugins) {
          plugin.started(id, conf(id));
        }

        healthCheck(id);

        sleep(id);

        tail.setMaxLines(conf(id).getMaxLogLines());
      }
      waitFor(id, waitForPattern);
    } catch (DockerException e) {
      throw new OrchestrationException(e);
    }
  }
Exemplo n.º 3
0
 /* draw the character and the tail */
 public void Draw(GL10 gl) {
   gl.glPushMatrix();
   gl.glTranslatef(x_pos, y_pos, z_pos);
   m_sphere.draw(gl);
   gl.glPopMatrix();
   gl.glPushMatrix();
   m_tail.draw(gl);
   gl.glPopMatrix();
 }
Exemplo n.º 4
0
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {

    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    GL11.glPushMatrix();
    {
      GL11.glTranslatef(offsetX * f5, offsetY * f5, offsetZ * f5);

      GL11.glPushMatrix();
      {
        GL11.glTranslatef(
            WolfHead.rotationPointX * f5,
            WolfHead.rotationPointY * f5,
            WolfHead.rotationPointZ * f5);
        GL11.glRotatef((float) (headRotY * 180f / Math.PI), 0f, 1f, 0f);
        GL11.glRotatef((float) (headRotX * 180f / Math.PI), 1f, 0f, 0f);
        GL11.glRotatef((float) (headRotZ * 180f / Math.PI), 0f, 0f, 1f);

        GL11.glPushMatrix();
        {
          GL11.glTranslatef(
              -WolfHead.rotationPointX * f5,
              -WolfHead.rotationPointY * f5,
              -WolfHead.rotationPointZ * f5);

          WolfHead.render(f5);
          Ear1.render(f5);
          Ear2.render(f5);
          Nose.render(f5);
        }
        GL11.glPopMatrix();
      }
      GL11.glPopMatrix();
      Body.render(f5);
      Leg1.render(f5);
      Leg2.render(f5);
      Leg3.render(f5);
      Leg4.render(f5);
      GL11.glPushMatrix();
      {
        GL11.glTranslatef(
            Tail.rotationPointX * f5, Tail.rotationPointY * f5, Tail.rotationPointZ * f5);
        GL11.glRotatef((float) (tailRotY * 180f / Math.PI), 0f, 1f, 0f);
        GL11.glRotatef((float) (tailRotX * 180f / Math.PI), 1f, 0f, 0f);
        GL11.glRotatef((float) (tailRotZ * 180f / Math.PI), 0f, 0f, 1f);

        GL11.glPushMatrix();
        GL11.glTranslatef(
            -Tail.rotationPointX * f5, -Tail.rotationPointY * f5, -Tail.rotationPointZ * f5);

        Tail.render(f5);
        GL11.glPopMatrix();
      }
      GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
  }
Exemplo n.º 5
0
  public ModelYorkshire() {

    super("yorkshire");
    textureWidth = 64;
    textureHeight = 32;

    WolfHead = new ModelRenderer(this, 0, 0);
    WolfHead.addBox(-3F, -3F, -2F, 4, 4, 3);
    WolfHead.setRotationPoint(0F, 19F, -6F);
    WolfHead.setTextureSize(64, 32);
    WolfHead.mirror = true;
    setRotation(WolfHead, 0F, 0F, 0F);
    Body = new ModelRenderer(this, 15, 0);
    Body.addBox(-4F, -2F, -3F, 3, 6, 4);
    Body.setRotationPoint(1.5F, 19F, -4F);
    Body.setTextureSize(64, 32);
    Body.mirror = true;
    setRotation(Body, 1.570796F, 0F, 0F);
    Leg1 = new ModelRenderer(this, 0, 12);
    Leg1.addBox(-1F, 0F, -1F, 1, 2, 1);
    Leg1.setRotationPoint(-1.5F, 22F, -1F);
    Leg1.setTextureSize(64, 32);
    Leg1.mirror = true;
    setRotation(Leg1, 0F, 0F, 0F);
    Leg2 = new ModelRenderer(this, 0, 12);
    Leg2.addBox(-1F, 0F, -1F, 1, 2, 1);
    Leg2.setRotationPoint(0.5F, 22F, -1F);
    Leg2.setTextureSize(64, 32);
    Leg2.mirror = true;
    setRotation(Leg2, 0F, 0F, 0F);
    Leg3 = new ModelRenderer(this, 0, 12);
    Leg3.addBox(-1F, 0F, -1F, 1, 2, 1);
    Leg3.setRotationPoint(-1.5F, 22F, -4F);
    Leg3.setTextureSize(64, 32);
    Leg3.mirror = true;
    setRotation(Leg3, 0F, 0F, 0F);
    Leg4 = new ModelRenderer(this, 0, 12);
    Leg4.addBox(-1F, 0F, -1F, 1, 2, 1);
    Leg4.setRotationPoint(0.5F, 22F, -4F);
    Leg4.setTextureSize(64, 32);
    Leg4.mirror = true;
    setRotation(Leg4, 0F, 0F, 0F);
    Tail = new ModelRenderer(this, 5, 12);
    Tail.addBox(-1F, 0F, -1F, 1, 4, 1);
    Tail.setRotationPoint(-0.5F, 18.6F, -1F);
    Tail.setTextureSize(64, 32);
    Tail.mirror = true;
    setRotation(Tail, 2.046006F, 0F, 0F);
    Ear1 = new ModelRenderer(this, 7, 8);
    Ear1.addBox(-3F, -5F, 0F, 2, 2, 1);
    Ear1.setRotationPoint(1F, 18.5F, -7F);
    Ear1.setTextureSize(64, 32);
    Ear1.mirror = true;
    setRotation(Ear1, 0F, 0F, -0.4833219F);
    Ear2 = new ModelRenderer(this, 7, 8);
    Ear2.addBox(1F, -5F, 0F, 2, 2, 1);
    Ear2.setRotationPoint(-3F, 18.5F, -7F);
    Ear2.setTextureSize(64, 32);
    Ear2.mirror = true;
    setRotation(Ear2, 0F, 0F, 0.4712389F);
    Nose = new ModelRenderer(this, 0, 8);
    Nose.addBox(-2F, 0F, -5F, 2, 2, 1);
    Nose.setRotationPoint(0F, 18F, -4F);
    Nose.setTextureSize(64, 32);
    Nose.mirror = true;
    setRotation(Nose, 0F, 0F, 0F);
  }
Exemplo n.º 6
0
 public void removeTail() {
   m_tail.removeTail();
 }