⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 photopuzzlecanvas.java

📁 一款拼图戏
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      scroll_8();
      break;
    case '5':
      scroll_5();
      break;
    case '3':
    case '7':
    default:
      return false;
    }
    return true;
  }

  void drawBackground(Graphics paramGraphics)
  {
    paramGraphics.setColor(204, 255, 204);
    paramGraphics.fillRect(0, 0, this.w, this.h);
  }

  void drawHeader2(Graphics paramGraphics, String paramString)
  {
    paramGraphics.drawString(paramString, this.w2, this.yTextHeader2, 0x1 | 0x10);
  }

  void drawHeader1(Graphics paramGraphics, String paramString)
  {
    paramGraphics.drawString(paramString, this.w2, this.yTextHeader1, 0x1 | 0x10);
  }

  void drawLine1(Graphics paramGraphics, String paramString)
  {
    paramGraphics.drawString(paramString, this.w2, this.yTextLine1, 0x1 | 0x10);
  }

  void drawLine2(Graphics paramGraphics, String paramString)
  {
    paramGraphics.drawString(paramString, this.w2, this.yTextLine2, 0x1 | 0x10);
  }

  void drawLine3(Graphics paramGraphics, String paramString)
  {
    paramGraphics.drawString(paramString, this.w2, this.yTextLine3, 0x1 | 0x10);
  }

  void drawLine4(Graphics paramGraphics, String paramString)
  {
    paramGraphics.drawString(paramString, this.w2, this.yTextLine4, 0x1 | 0x10);
  }

  void drawLine5(Graphics paramGraphics, String paramString)
  {
    paramGraphics.drawString(paramString, this.w2, this.yTextLine5, 0x1 | 0x10);
  }

  protected void paint(Graphics paramGraphics)
  {
    int i;
    this.painting = true;
    Graphics localGraphics = paramGraphics;
    paramGraphics = this.offscreen.getGraphics();
    paramGraphics.setColor(255, 255, 255);
    paramGraphics.fillRect(0, 0, this.w, this.h);
    paramGraphics.setFont(this.gameFont);
    paramGraphics.setColor(0, 0, 0);
    if (this.showMenu)
    {
      paramGraphics.setColor(180, 80, 180);
      drawLine1(paramGraphics, this.apple4you);
      paramGraphics.setColor(0, 0, 255);
      drawLine2(paramGraphics, this.gameTitle);
      i = this.xBoardOffset + 10;
      paramGraphics.setColor(0, 0, 0);
      paramGraphics.drawString("1. Photo A", i, this.yTextLine3, 0x4 | 0x10);
      paramGraphics.drawString("2. Photo B", i, this.yTextLine4, 0x4 | 0x10);
      paramGraphics.drawString("3. Customize", i, this.yTextLine5, 0x4 | 0x10);
    }
    else if (this.showAbout)
    {
      paramGraphics.setColor(180, 80, 180);
      drawLine1(paramGraphics, this.gameTitle);
      paramGraphics.setColor(0, 0, 255);
      drawLine2(paramGraphics, "Use your own");
      drawLine3(paramGraphics, "photograph");
      paramGraphics.setColor(0, 0, 0);
      drawLine4(paramGraphics, "Info at");
      drawLine5(paramGraphics, this.apple4you);
    }
    else if (this.showIntro)
    {
      this.puzzleSolved = false;
      this.showTileImage = false;
      if (this.showIntroCount++ >= 12)
      {
        doneWith_anyActiveTextScreen();
        shuffle_last();
        for (i = 0; i < 16; ++i)
          this.tiles[i].draw(paramGraphics);
      }
      else if (this.showIntroCount >= 5)
      {
        this.showIntroShuffle = true;
        shuffle();
        usePhotoImage();
        for (i = 0; i < 16; ++i)
          this.tiles[i].draw(paramGraphics);
      }
      else if (this.showIntroCount % 2 == 1)
      {
        usePhotoImage();
        for (i = 0; i < 16; ++i)
          this.tiles[i].draw(paramGraphics);
      }
      else
      {
        useTileImage();
        for (i = 0; i < 16; ++i)
          this.tiles[i].draw(paramGraphics);
      }
    }
    else
    {
      drawBackground(paramGraphics);
      for (i = 0; i < 16; ++i)
        this.tiles[i].draw(paramGraphics);
      if ((!(this.showIntro)) && (this.show_infoKey) && (this.blink))
        paramGraphics.drawImage(this.image_key5, this.tiles[this.indexCenter].xCenter, this.tiles[this.indexCenter].yCenter, 0x2 | 0x1);
      if (this.showTileImage)
        useTileImage();
      else
        usePhotoImage();
    }
    localGraphics.drawImage(this.offscreen, 0, 0, 20);
    this.painting = false;
  }

  public void clockTick()
  {
    if (this.painting)
      return;
    local_clockTick();
    super.repaint();
  }

  public void local_clockTick()
  {
    if (++this.blinkCount > 2)
    {
      this.blinkCount = 0;
      this.blink = (!(this.blink));
    }
    if (this.apple4you.length() != 13)
      this.licenseFail = true;
  }

  void useTileImage()
  {
    if (this.showTileImage_isCurrentState)
      return;
    this.showTileImage_isCurrentState = true;
    for (int i = 0; i < 16; ++i)
      this.tiles[i].initTileImage();
  }

  void usePhotoImage()
  {
    if (!(this.showTileImage_isCurrentState))
      return;
    usePhotoImage_force();
  }

  void usePhotoImage_force()
  {
    this.showTileImage_isCurrentState = false;
    for (int i = 0; i < 16; ++i)
      this.tiles[i].initPhotoImage();
  }

  void shuffle()
  {
    for (int i1 = 0; i1 < 100; ++i1)
    {
      int i = myRandomNumber(16);
      int j = myRandomNumber(16);
      int k = this.tiles[i].myShuffledIndex;
      int l = this.tiles[j].myShuffledIndex;
      this.tiles[i].myShuffledIndex = l;
      this.tiles[j].myShuffledIndex = k;
    }
  }

  void shuffle_last()
  {
    shuffle();
    int i = this.tiles[this.indexBlankTile].myShuffledIndex;
    for (int k = 0; k < 16; ++k)
    {
      int j = this.tiles[k].myShuffledIndex;
      if ((j == 5) || (j == 6) || (j == 9) || (j == 10))
      {
        if (i == j)
          break;
        this.tiles[this.indexBlankTile].myShuffledIndex = j;
        this.tiles[k].myShuffledIndex = i;
        break;
      }
    }
    this.show_infoKey = true;
    readCompass();
  }

  void readCompass()
  {
    this.indexCenter = this.tiles[this.indexBlankTile].myShuffledIndex;
    this.indexAbove = (this.indexCenter - 4);
    this.indexBelow = (this.indexCenter + 4);
    this.indexLeft = (this.indexCenter - 1);
    this.indexRight = (this.indexCenter + 1);
    if (this.indexCenter % 4 == 0)
      this.indexLeft = -1;
    if (this.indexCenter % 4 == 3)
      this.indexRight = -1;
    if (this.indexCenter < 4)
      this.indexAbove = -1;
    if (this.indexCenter > 11)
      this.indexBelow = -1;
    this.puzzleSolved = true;
    for (int i = 0; i < 16; ++i)
      if (this.tiles[i].tileIndex != this.tiles[i].myShuffledIndex)
      {
        this.puzzleSolved = false;
        break;
      }
    if (this.puzzleSolved)
      this.showTileImage = false;
  }

  void scroll_2()
  {
    if (-1 == this.indexAbove)
      return;
    int i = 0;
    for (int j = 0; j < 16; ++j)
      if (this.tiles[j].myShuffledIndex == this.indexAbove)
      {
        i = this.tiles[j].tileIndex;
        break;
      }
    int k = this.tiles[i].myShuffledIndex;
    this.tiles[i].myShuffledIndex = this.tiles[this.indexBlankTile].myShuffledIndex;
    this.tiles[this.indexBlankTile].myShuffledIndex = k;
    readCompass();
  }

  void scroll_4()
  {
    if (-1 == this.indexLeft)
      return;
    int i = 0;
    for (int j = 0; j < 16; ++j)
      if (this.tiles[j].myShuffledIndex == this.indexLeft)
      {
        i = this.tiles[j].tileIndex;
        break;
      }
    int k = this.tiles[i].myShuffledIndex;
    this.tiles[i].myShuffledIndex = this.tiles[this.indexBlankTile].myShuffledIndex;
    this.tiles[this.indexBlankTile].myShuffledIndex = k;
    readCompass();
  }

  void scroll_6()
  {
    if (-1 == this.indexRight)
      return;
    int i = 0;
    for (int j = 0; j < 16; ++j)
      if (this.tiles[j].myShuffledIndex == this.indexRight)
      {
        i = this.tiles[j].tileIndex;
        break;
      }
    int k = this.tiles[i].myShuffledIndex;
    this.tiles[i].myShuffledIndex = this.tiles[this.indexBlankTile].myShuffledIndex;
    this.tiles[this.indexBlankTile].myShuffledIndex = k;
    readCompass();
  }

  void scroll_8()
  {
    if (-1 == this.indexBelow)
      return;
    int i = 0;
    for (int j = 0; j < 16; ++j)
      if (this.tiles[j].myShuffledIndex == this.indexBelow)
      {
        i = this.tiles[j].tileIndex;
        break;
      }
    int k = this.tiles[i].myShuffledIndex;
    this.tiles[i].myShuffledIndex = this.tiles[this.indexBlankTile].myShuffledIndex;
    this.tiles[this.indexBlankTile].myShuffledIndex = k;
    readCompass();
  }

  void scroll_5()
  {
    if (this.show_infoKey)
      this.show_infoKey = false;
    this.showTileImage = (!(this.showTileImage));
  }

  class Tile extends MyBox
  {
    int tileIndex;
    int myShuffledIndex;
    Image currentImage;
    Image imageTile;
    private final PhotoPuzzleCanvas this$0;

    public Tile(, int paramInt)
    {
      this.this$0 = paramPhotoPuzzleCanvas;
      this.currentImage = this.imageTile;
      this.myShuffledIndex = paramInt;
      this.tileIndex = paramInt;
      this.currentImage = Image.createImage(30, 30);
      initPhotoImage();
    }

    public void initPhotoImage()
    {
      this.left = (this.tileIndex % 4 * 30);
      this.top = (this.tileIndex / 4 * 30);
      Graphics localGraphics = this.currentImage.getGraphics();
      localGraphics.drawImage(this.this$0.topCurrentImage, -this.left, -this.top, 0x10 | 0x4);
      this.left = (this.this$0.xBoardOffset + this.left);
      this.top = (this.this$0.yBoardOffset + this.top);
      super.setWidthHeight(30, 30);
    }

    public void initTileImage()
    {
      this.left = 0;
      this.top = 0;
      super.setWidthHeight(30, 30);
      Graphics localGraphics = this.currentImage.getGraphics();
      localGraphics.drawImage(this.imageTile, this.xCenter, this.yCenter, 0x2 | 0x1);
      this.left = (this.this$0.xBoardOffset + this.tileIndex % 4 * 30);
      this.top = (this.this$0.yBoardOffset + this.tileIndex / 4 * 30);
      super.setWidthHeight(30, 30);
    }

    public void draw()
    {
      int i = this.this$0.tiles[this.myShuffledIndex].left;
      int j = this.this$0.tiles[this.myShuffledIndex].top;
      if ((this.this$0.showIntro) && (!(this.this$0.showIntroShuffle)))
      {
        i = this.this$0.tiles[this.tileIndex].left;
        j = this.this$0.tiles[this.tileIndex].top;
        paramGraphics.drawImage(this.currentImage, i, j, 0x10 | 0x4);
        return;
      }
      if (this.this$0.puzzleSolved)
      {
        paramGraphics.drawImage(this.currentImage, i, j, 0x10 | 0x4);
        return;
      }
      if (this.tileIndex == this.this$0.indexBlankTile)
      {
        paramGraphics.setColor(0, 0, 255);
        paramGraphics.fillRect(i, j, 30, 30);
      }
      else
      {
        paramGraphics.drawImage(this.currentImage, i, j, 0x10 | 0x4);
      }
      paramGraphics.setColor(0, 0, 0);
      paramGraphics.drawRect(i, j, 30, 30);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -