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

📄 photopuzzlecanvas.java

📁 一款拼图戏
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
import java.io.IOException;
import java.io.PrintStream;
import java.util.Random;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class PhotoPuzzleCanvas extends Canvas
{
  public int randomNum;
  public boolean b;
  public String str;
  public String gameTitle = "PhotoPuzzle";
  public boolean licenseDemo = false;
  public boolean licenseCheck = false;
  public static final int CHECK_LICENSE_AFTER_THIS_SCORE = 4;
  public static final int LICENSE_EXPIRE_YEAR_TAIL = 3;
  public static final int LICENSE_EXPIRE_MONTH = 4;
  public String noLicenseCheck_revision = "rev 000";
  public String tapAndStart = "tap & start";
  public String tapAndResume = "tap & resume";
  public String tapAndPlay = "tap & play";
  public String userGuideAt = "User guide at";
  public String Beginner = "Beginner";
  public String Normal = "Normal";
  public String Expert = "Expert";
  public String Speed = "Speed";
  public String apple4you = "apple4you.com";
  public static final int apple4you_len = 13;
  public static final int apple4you_hashcode = 1307033048;
  public int apple4you_hashcodeOnTheFly = 0;
  public static final int LICENSE_EXPIRE_YEAR_HEAD = 20;
  public String Revision;
  public boolean licenseFail_demo = false;
  public int license_evaluateCounter = 0;
  public boolean licenseFail = false;
  public int licenseYear = 1000;
  public int licenseMonth = 0;
  public Random randomGenerator = new Random();
  public boolean painting = false;
  public boolean needToPaint = true;
  public boolean myScreen_isColor = true;
  public int w;
  public int h;
  public int w2;
  public int h2;
  public int xDelta = 1;
  public int yDelta = 1;
  public boolean displayHeader = false;
  public boolean displayScore = false;
  public int x1;
  public int y1;
  public int x2;
  public int y2;
  public int x3;
  public int y3;
  public int x4;
  public int y4;
  public int x5;
  public int y5;
  public int xBoardOrigin;
  public int yBoardOrigin;
  public int xBoardPt2;
  public int yBoardPt2;
  public int yTextHeader1;
  public int yTextHeader2;
  public int yTextLine1;
  public int yTextLine2;
  public int yTextLine3;
  public int yTextLine4;
  public int yTextLine5;
  public boolean gameOver = false;
  public Image offscreen;
  Font gameFont = Font.getFont(0, 0, 0);
  int fontHeight = 15;
  public static final int UNUSED = -1;
  public static final int MAX_TILES = 16;
  public static final int MAX_TILES_MINUS_ONE = 15;
  public static final int IMAGES_PER_ROW = 4;
  public static final int IMAGES_PER_COLUMN = 4;
  public static final int BOARD_WIDTH = 120;
  public static final int BOARD_HEIGHT = 120;
  public static final int IMAGE_WIDTH = 30;
  public static final int IMAGE_HEIGHT = 30;
  int aScore = 0;
  int bScore = 0;
  String scoreStr = "score: 0-0";
  public Image image_photo_A;
  public Image image_photo_B;
  public Image image_tile0;
  public Image image_tile1;
  public Image image_tile2;
  public Image image_tile3;
  public Image image_tile4;
  public Image image_tile5;
  public Image image_tile6;
  public Image image_tile7;
  public Image image_tile8;
  public Image image_tile9;
  public Image image_tile10;
  public Image image_tile11;
  public Image image_tile12;
  public Image image_tile13;
  public Image image_tile14;
  public Image image_tile15;
  public Image image_key5;
  public Image topCurrentImage;
  int xBoardOffset;
  int yBoardOffset;
  int indexBlankTile = 15;
  int indexCenter;
  int indexAbove;
  int indexBelow;
  int indexRight;
  int indexLeft;
  public PhotoPuzzleCanvas.Tile[] tiles;
  boolean show_infoKey = true;
  boolean puzzleSolved = false;
  boolean showTileImage = false;
  boolean showTileImage_isCurrentState = false;
  boolean showMenu = true;
  boolean showAbout = false;
  boolean showIntro = false;
  boolean showIntroShuffle = false;
  int showIntroCount = 0;
  boolean blink = false;
  int blinkCount = 0;
  int swapIndex_2;
  int swapIndex_4;
  int swapIndex_5;
  int swapIndex_6;
  int swapIndex_8;

  public void processMenuCmd_NEXT()
  {
    if (this.showMenu)
    {
      doneWith_anyActiveTextScreen();
      goto_nextPhoto();
      return;
    }
    doneWith_anyActiveTextScreen();
    this.showMenu = true;
  }

  public PhotoPuzzleCanvas()
  {
    if (!(this.licenseCheck))
    {
      this.Revision = this.noLicenseCheck_revision;
    }
    else if (this.licenseDemo)
    {
      this.Revision = "Demo Copy";
    }
    else
    {
      this.Revision = "rev ";
      this.Revision += "03";
      this.Revision += "04";
    }
    try
    {
      this.image_photo_A = Image.createImage("/A.png");
      this.image_photo_B = Image.createImage("/B.png");
      this.image_key5 = Image.createImage("/key_5.png");
      this.image_tile0 = Image.createImage("/tile0.png");
      this.image_tile1 = Image.createImage("/tile1.png");
      this.image_tile2 = Image.createImage("/tile2.png");
      this.image_tile3 = Image.createImage("/tile3.png");
      this.image_tile4 = Image.createImage("/tile4.png");
      this.image_tile5 = Image.createImage("/tile5.png");
      this.image_tile6 = Image.createImage("/tile6.png");
      this.image_tile7 = Image.createImage("/tile7.png");
      this.image_tile8 = Image.createImage("/tile8.png");
      this.image_tile9 = Image.createImage("/tile9.png");
      this.image_tile10 = Image.createImage("/tile10.png");
      this.image_tile11 = Image.createImage("/tile11.png");
      this.image_tile12 = Image.createImage("/tile12.png");
      this.image_tile13 = Image.createImage("/tile13.png");
      this.image_tile14 = Image.createImage("/tile14.png");
      this.image_tile15 = Image.createImage("/tile15.png");
    }
    catch (IOException localIOException)
    {
      System.err.println("Failed loading images!");
    }
    this.w = super.getWidth();
    this.w2 = (this.w / 2);
    this.h = super.getHeight();
    this.h2 = (this.h / 2);
    this.offscreen = Image.createImage(this.w, this.h);
    this.fontHeight = this.gameFont.getHeight();
    this.yTextLine3 = (this.h2 - this.fontHeight / 2);
    this.yTextLine4 = (this.yTextLine3 + this.fontHeight);
    this.yTextLine5 = (this.yTextLine4 + this.fontHeight);
    this.yTextLine2 = (this.yTextLine3 - this.fontHeight);
    this.yTextLine1 = (this.yTextLine2 - this.fontHeight);
    this.yTextHeader1 = (this.yTextLine1 - this.fontHeight);
    this.yTextHeader2 -= this.fontHeight;
    this.apple4you_hashcodeOnTheFly = this.apple4you.hashCode();
    this.xBoardOffset = (this.w2 - 60);
    this.yBoardOffset = (this.h2 - 60);
    this.topCurrentImage = this.image_photo_A;
    this.tiles = new PhotoPuzzleCanvas.Tile[16];
    for (int i = 0; i < 16; ++i)
      this.tiles[i] = new PhotoPuzzleCanvas.Tile(this, i);
    this.tiles[0].imageTile = this.image_tile0;
    this.tiles[1].imageTile = this.image_tile1;
    this.tiles[2].imageTile = this.image_tile2;
    this.tiles[3].imageTile = this.image_tile3;
    this.tiles[4].imageTile = this.image_tile4;
    this.tiles[5].imageTile = this.image_tile5;
    this.tiles[6].imageTile = this.image_tile6;
    this.tiles[7].imageTile = this.image_tile7;
    this.tiles[8].imageTile = this.image_tile8;
    this.tiles[9].imageTile = this.image_tile9;
    this.tiles[10].imageTile = this.image_tile10;
    this.tiles[11].imageTile = this.image_tile11;
    this.tiles[12].imageTile = this.image_tile12;
    this.tiles[13].imageTile = this.image_tile13;
    this.tiles[14].imageTile = this.image_tile14;
    this.tiles[15].imageTile = this.image_tile15;
  }

  protected int myRandomNumber(int paramInt)
  {
    int i = this.randomGenerator.nextInt() % paramInt;
    if (i < 0)
      i *= -1;
    return i;
  }

  void doneWith_anyActiveTextScreen()
  {
    this.showMenu = false;
    this.showAbout = false;
    this.showIntro = false;
    this.showIntroShuffle = false;
    this.showIntroCount = 0;
  }

  public void goto_photo_A()
  {
    this.topCurrentImage = this.image_photo_A;
    usePhotoImage_force();
    this.showIntro = true;
  }

  public void goto_photo_B()
  {
    this.topCurrentImage = this.image_photo_B;
    usePhotoImage_force();
    this.showIntro = true;
  }

  public void goto_nextPhoto()
  {
    if (this.topCurrentImage == this.image_photo_A)
      goto_photo_B();
    else
      goto_photo_A();
  }

  public boolean userInput_preProcess()
  {
    if (this.showIntro)
      return true;
    if (this.showAbout)
    {
      doneWith_anyActiveTextScreen();
      goto_nextPhoto();
      return true;
    }
    return false;
  }

  public void pointerPressed(int paramInt1, int paramInt2)
  {
    if (userInput_preProcess())
      return;
    if (this.showMenu)
    {
      doneWith_anyActiveTextScreen();
      if (paramInt2 < this.yTextLine4)
        goto_photo_A();
      else if (paramInt2 > this.yTextLine5)
        this.showAbout = true;
      else
        goto_photo_B();
      return;
    }
    if ((-1 != this.indexCenter) && (this.tiles[this.indexCenter].isInTheBox(paramInt1, paramInt2)))
    {
      scroll_5();
      return;
    }
    if ((-1 != this.indexAbove) && (this.tiles[this.indexAbove].isInTheBox(paramInt1, paramInt2)))
    {
      scroll_2();
      return;
    }
    if ((-1 != this.indexLeft) && (this.tiles[this.indexLeft].isInTheBox(paramInt1, paramInt2)))
    {
      scroll_4();
      return;
    }
    if ((-1 != this.indexRight) && (this.tiles[this.indexRight].isInTheBox(paramInt1, paramInt2)))
    {
      scroll_6();
      return;
    }
    if ((-1 != this.indexBelow) && (this.tiles[this.indexBelow].isInTheBox(paramInt1, paramInt2)))
    {
      scroll_8();
      return;
    }
  }

  public void keyPressed(int paramInt)
  {
    if (userInput_preProcess())
      return;
    if (userAction_keyPress((char)paramInt))
      return;
    userAction_scroll(super.getGameAction(paramInt));
  }

  void userAction_scroll(int paramInt)
  {
    switch (paramInt)
    {
    case 2:
      scroll_6();
      break;
    case 1:
      scroll_8();
      break;
    case 5:
      scroll_4();
      break;
    case 6:
      scroll_2();
      break;
    case 8:
      scroll_5();
    case 3:
    case 4:
    case 7:
    }
  }

  public boolean userAction_keyPress(char paramChar)
  {
    if (this.showMenu)
    {
      doneWith_anyActiveTextScreen();
      switch (paramChar)
      {
      case '1':
        goto_photo_A();
        break;
      case '2':
        goto_photo_B();
        break;
      default:
        this.showAbout = true;
      }
      return true;
    }
    switch (paramChar)
    {
    case '2':
      scroll_2();
      break;
    case '4':
      scroll_4();
      break;
    case '6':
      scroll_6();
      break;
    case '8':

⌨️ 快捷键说明

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