Exemple #1
0
  // CONSTANT METHODS
  public void draw(Graphics g, ImageObserver o) {

    boolean transparent =
        invulerable && (invulerableTime < 3000 / 15 || System.currentTimeMillis() % 60 > 30);
    if (transparent)
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
    int x = Wuigi.scaleW(Wuigi.screenWidth / 2.0 + xOffset - 4);
    int y = Wuigi.scaleH(Wuigi.screenHeight - yOffset);
    if (cape) {
      if (facingRight)
        g.drawImage(
            TCape.IMAGE.getBuffer(),
            x - 5,
            y,
            Wuigi.scaleW(WIDTH + 8),
            Wuigi.scaleH(HEIGHT + 2),
            o);
      else
        g.drawImage(
            TCape.IMAGE.flipX(), x + 5, y, Wuigi.scaleW(WIDTH + 8), Wuigi.scaleH(HEIGHT + 2), o);
    }

    drawAWP(g, x, y);

    g.drawImage(
        figureOutDrawImage(IMAGE),
        x,
        // (int)(Global.H-H-pos.y-Global.GROUND_LEVEL),
        y,
        Wuigi.scaleW(WIDTH + 8),
        Wuigi.scaleH(HEIGHT + 2),
        o);
    if (transparent)
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));

    // g.setColor(Color.WHITE);
    // g.drawRect((int)(Wuigi.W/2 - X_OFFSET), (int)(Wuigi.H - Y_OFFSET), (int)X_OFFSET*2 + width,
    // (int)(Y_OFFSET*2) - Wuigi.H);
  }
Exemple #2
0
  /**
   * draws the backdrop to the screen
   *
   * @param g
   * @param o
   * @param hero to be used to check against for parallax scrolling
   */
  public void draw(Graphics g, java.awt.image.ImageObserver o, Hero hero) {
    double viewX = hero.viewX();
    double viewY = hero.viewY();
    if (underground) g.setColor(UNDERGROUND_COLOR);
    else g.setColor(Backdrop.SKY_COLOR);
    g.fillRect(0, 0, Wuigi.screenWidth, Wuigi.screenHeight);
    Image ground;
    int groundHeight, groundWidth;
    // g.setColor(SKY_COLOR);
    if (!underground) {
      ground = GRASS;
      groundHeight = ground.getHeight(o);
      groundWidth = ground.getWidth(o);
      int skyHeight = SKY.getHeight(o) * 3, skyWidth = SKY.getWidth(o) * 3;

      double x = -viewX * SKY_MULTI;
      double y = (viewY - (Wuigi.screenHeight - Wuigi.GROUND_LEVEL)) * SKY_MULTI;
      while (x > 0) x -= skyWidth;
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
      for (; x < Wuigi.screenWidth; x += skyWidth) {
        g.drawImage(
            SKY,
            Wuigi.scaleW(x),
            Wuigi.scaleH(y),
            Wuigi.scaleW(skyWidth),
            Wuigi.scaleH(skyHeight),
            o);
      }
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));

      /*((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));

        	x = -viewX*BUILDINGS_MULTI;
        	y = viewY - buildingHeight;
        	while(x > 0)
        		x -= buildingWidth;
        	for(; x < Wuigi.W; x+=buildingWidth){
        		g.drawImage(BUILDINGS, Wuigi.scaleW(x),Wuigi.scaleH(y),Wuigi.scaleW(buildingWidth),Wuigi.scaleH(buildingHeight),o);
        	}


      ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.00f));
      */
    } else {
      ground = BRICK;
      groundHeight = ground.getHeight(o) * 2;
      groundWidth = ground.getWidth(o) * 2;
    }

    for (double y = viewY; y < Wuigi.screenHeight; y += groundHeight) {
      double x = viewX;
      x *= -GROUND_MULTI;
      while (x > 0) x -= groundWidth;

      for (; x < Wuigi.screenWidth; x += groundWidth) {
        g.drawImage(
            ground,
            Wuigi.scaleW(x),
            Wuigi.scaleH(y),
            Wuigi.scaleW(groundWidth),
            Wuigi.scaleH(groundHeight),
            o);
      }
    }
  }