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

📄 cgameplay.java

📁 一个3D的保龄球的源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        }
        else {
          if (m_isStrike == false) {
            gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.scores[
                                            i *
                                            2]),
                           20 + (i * SCORE_BOARD_WIDTH) + 2, height,
                           Graphics.LEFT | Graphics.TOP);
            if (m_isSecondBall == true) {
              drawSecondScore(i, height, gfx, true, 0);
            }
          }
          else { //draw strike score board
            gfx.setColor(255, 128, 128);
            gfx.drawLine(20 + (i * SCORE_BOARD_WIDTH), height,
                         20 + (i * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 2,
                         height + SCORE_BOARD_HEIGHT / 2);
            gfx.drawLine(20 + (i * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 2,
                         height, 20 + (i * SCORE_BOARD_WIDTH),
                         height + SCORE_BOARD_HEIGHT / 2);
          }
        }
      }
      else { //scrolling
        m_offSet = i - 5;
        drawScorlling(gfx, i - 5, false, isFinalStage);
      }
    }
    gfx = saved;
    gfx.drawImage(m_scoreImage, 0, 0, 0);
  }

  private void drawSecondScore(int number, int height, Graphics gfx,
                               boolean isFirstShow, int offStep) {
    if ( (m_scene.m_player.m_scoreInfo.scores[ (number + offStep) * 2] +
          m_scene.m_player.m_scoreInfo.scores[ (number + offStep) * 2 + 1]) ==
        10) {
      gfx.setColor(255, 128, 128);
      gfx.drawLine(20 + (number * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH,
                   height,
                   20 + SCORE_BOARD_WIDTH / 2 + (number * SCORE_BOARD_WIDTH),
                   height + SCORE_BOARD_HEIGHT / 2);
      gfx.setColor(255, 255, 255);

      if (isFirstShow == false) {
        gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.
                                        totalScores[
                                        (number + offStep)]),
                       20 + (number * SCORE_BOARD_WIDTH) +
                       SCORE_BOARD_WIDTH / 2 -
                       6, height + SCORE_BOARD_HEIGHT / 2,
                       Graphics.LEFT | Graphics.TOP);

      }
    }
    else {
      gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.scores[
                                      (number + offStep) *
                                      2 + 1]),
                     20 + SCORE_BOARD_WIDTH / 2 + (number * SCORE_BOARD_WIDTH) +
                     2, height,
                     Graphics.LEFT | Graphics.TOP);

      gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.
                                      totalScores[
                                      (number + offStep)]),
                     20 + (number * SCORE_BOARD_WIDTH) +
                     SCORE_BOARD_WIDTH / 2 -
                     5, height + SCORE_BOARD_HEIGHT / 2,
                     Graphics.LEFT | Graphics.TOP);
    }
  }

  private void drawScorlling(Graphics gfx, int scorllingPage,
                             boolean isRespondKey, boolean isFinalStage) {
    gfx.drawImage(m_offImage, 0, 0, 0);

    gfx.setColor(255, 128, 128);

    int height = m_offImage.getHeight() / 3;
    int count = 6;

    if (m_roundNumber == MAX_ROUND_NUMBER && m_offSet == (m_roundNumber - 5)) {
      count = 5;
      gfx.drawRect(20 + (count * SCORE_BOARD_WIDTH), height, SCORE_BOARD_WIDTH,
                   SCORE_BOARD_HEIGHT);

      gfx.drawRect(20 + (count * SCORE_BOARD_WIDTH),
                   height,
                   SCORE_BOARD_WIDTH / 3, SCORE_BOARD_HEIGHT / 2);

      gfx.drawRect(20 + SCORE_BOARD_WIDTH / 3 + (count * SCORE_BOARD_WIDTH),
                   height,
                   SCORE_BOARD_WIDTH / 3, SCORE_BOARD_HEIGHT / 2);

      gfx.drawRect(20 + (SCORE_BOARD_WIDTH * 2) / 3 +
                   (count * SCORE_BOARD_WIDTH),
                   height,
                   SCORE_BOARD_WIDTH / 3, SCORE_BOARD_HEIGHT / 2);
    }

    for (int i = 0; i < count; ++i) {
      gfx.drawRect(20 + (i * SCORE_BOARD_WIDTH), height, SCORE_BOARD_WIDTH,
                   SCORE_BOARD_HEIGHT);
      gfx.drawRect(20 + SCORE_BOARD_WIDTH / 2 + (i * SCORE_BOARD_WIDTH),
                   height,
                   SCORE_BOARD_WIDTH / 2, SCORE_BOARD_HEIGHT / 2);
    }

    int flag = 5;
    if (isRespondKey == true)
      flag = 6;

    for (int i = 0; i < 6; ++i) {
      gfx.setColor(255, 255, 255);
      if (i < flag) {
        if (i == 5 && m_roundNumber == MAX_ROUND_NUMBER &&
            m_offSet == (m_roundNumber - 5)) {
          drawLastShotScoreBoard(gfx, isFinalStage);
        }
        else {
          if ( (m_scene.m_player.m_scoreInfo.scores[ (i + scorllingPage) * 2] ==
                10) &&
              (m_scene.m_player.m_scoreInfo.scores[ (i + scorllingPage) * 2 + 1] ==
               0)) {
            //draw strike score board
            gfx.setColor(255, 128, 128);
            gfx.drawLine(20 + (i * SCORE_BOARD_WIDTH), height,
                         20 + (i * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 2,
                         height + SCORE_BOARD_HEIGHT / 2);
            gfx.drawLine(20 + (i * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 2,
                         height, 20 + (i * SCORE_BOARD_WIDTH),
                         height + SCORE_BOARD_HEIGHT / 2);
            if (m_scene.m_player.m_scoreInfo.totalScores[i + scorllingPage] !=
                -1) {
              gfx.setColor(255, 255, 255);
              gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.
                                              totalScores[ (i + scorllingPage)]),
                             20 + (i * SCORE_BOARD_WIDTH) +
                             SCORE_BOARD_WIDTH / 2 -
                             6, height + SCORE_BOARD_HEIGHT / 2,
                             Graphics.LEFT | Graphics.TOP);
              gfx.setColor(255, 128, 128);
            }
          }
          else {
            gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.
                                            scores[
                                            (i + scorllingPage) *
                                            2]),
                           20 + (i * SCORE_BOARD_WIDTH) + 2, height,
                           Graphics.LEFT | Graphics.TOP);
            if (m_offSet == m_roundNumber - 5 && i == 5 &&
                m_isSecondBall == false) {
              ;
            }
            else {
              drawSecondScore(i, height, gfx, false, scorllingPage);
            }
            gfx.setColor(255, 128, 128);
          }
        }
      }
      else {
        if (m_roundNumber == MAX_ROUND_NUMBER && m_offSet == (m_roundNumber - 5)) {
          drawLastShotScoreBoard(gfx, isFinalStage);
        }
        else {
          if (m_isStrike == false) {
            gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.scores[
                                            (i + scorllingPage) *
                                            2]),
                           20 + (i * SCORE_BOARD_WIDTH) + 2, height,
                           Graphics.LEFT | Graphics.TOP);
            if (m_isSecondBall == true) {
              drawSecondScore(i, height, gfx, true, scorllingPage);
            }
          }
          else { //draw strike score board
            gfx.setColor(255, 128, 128);
            gfx.drawLine(20 + (i * SCORE_BOARD_WIDTH), height,
                         20 + (i * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 2,
                         height + SCORE_BOARD_HEIGHT / 2);
            gfx.drawLine(20 + (i * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 2,
                         height, 20 + (i * SCORE_BOARD_WIDTH),
                         height + SCORE_BOARD_HEIGHT / 2);
          }
        }
      }
    }
  }

  private void drawLastShotScoreBoard(Graphics gfx, boolean isFinalShow) {
    int height = m_offImage.getHeight() / 3;

    if (!m_isBonusShot) {
      if (m_isStrike) {
        gfx.setColor(255, 128, 128);
        gfx.drawLine(20 + (5 * SCORE_BOARD_WIDTH),
                     height,
                     20 + SCORE_BOARD_WIDTH / 3 + (5 * SCORE_BOARD_WIDTH),
                     height + SCORE_BOARD_HEIGHT / 2);
        gfx.drawLine(20 + (5 * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 3,
                     height,
                     20 + (5 * SCORE_BOARD_WIDTH),
                     height + SCORE_BOARD_HEIGHT / 2);
      }
      else {
        gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.scores[18]),
                       20 + (5 * SCORE_BOARD_WIDTH) + 2, height,
                       Graphics.LEFT | Graphics.TOP);

        if (m_isSecondBall == true) {
          drawLastElementScoreBoard(gfx, 0, height);

        }
      }
    }
    else {
      gfx.setColor(255, 128, 128);
      gfx.drawLine(20 + (5 * SCORE_BOARD_WIDTH),
                   height,
                   20 + SCORE_BOARD_WIDTH / 3 + (5 * SCORE_BOARD_WIDTH),
                   height + SCORE_BOARD_HEIGHT / 2);
      gfx.drawLine(20 + (5 * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 3,
                   height,
                   20 + (5 * SCORE_BOARD_WIDTH),
                   height + SCORE_BOARD_HEIGHT / 2);

      if (m_isStrike) {
        gfx.drawLine(20 + (5 * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 3,
                     height,
                     20 + (SCORE_BOARD_WIDTH * 2) / 3 + (5 * SCORE_BOARD_WIDTH),
                     height + SCORE_BOARD_HEIGHT / 2);
        gfx.drawLine(20 + (5 * SCORE_BOARD_WIDTH) + (SCORE_BOARD_WIDTH * 2) / 3,
                     height,
                     20 + (5 * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 3,
                     height + SCORE_BOARD_HEIGHT / 2);
        int count = 9;
        if (isFinalShow == true) {
          count = 10;
        }
        if (m_scene.m_player.m_scoreInfo.totalScores[count] != -1) {
          gfx.setColor(255, 255, 255);
          gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.
                                          totalScores[count]),
                         20 + (5 * SCORE_BOARD_WIDTH) +
                         SCORE_BOARD_WIDTH / 2 -
                         6, height + SCORE_BOARD_HEIGHT / 2,
                         Graphics.LEFT | Graphics.TOP);
          gfx.setColor(255, 128, 128);
        }
      }
      else {
        gfx.setColor(255, 255, 255);
        gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.scores[19]),
                       20 + (5 * SCORE_BOARD_WIDTH) + SCORE_BOARD_WIDTH / 3 + 2,
                       height,
                       Graphics.LEFT | Graphics.TOP);
      }
      if (m_isSecondBall == true) {
        drawLastElementScoreBoard(gfx, 1, height);
      }

    }
  }

  private void drawLastElementScoreBoard(Graphics gfx, int number, int height) {
    if ( (m_scene.m_player.m_scoreInfo.scores[18 + number] +
          m_scene.m_player.m_scoreInfo.scores[18 + 1 + number]) == 10) {
      gfx.setColor(255, 128, 128);
      gfx.drawLine(20 + (5 * SCORE_BOARD_WIDTH) +
                   (SCORE_BOARD_WIDTH * (number + 2)) / 3,
                   height,
                   20 + (SCORE_BOARD_WIDTH * (number + 1)) / 3 +
                   (5 * SCORE_BOARD_WIDTH),
                   height + SCORE_BOARD_HEIGHT / 2);
      gfx.setColor(255, 255, 255);

      //if (isFirstShow == false) {
      gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.
                                      totalScores[9]),
                     20 + (5 * SCORE_BOARD_WIDTH) +
                     SCORE_BOARD_WIDTH / 2 -
                     6, height + SCORE_BOARD_HEIGHT / 2,
                     Graphics.LEFT | Graphics.TOP);
      //}
    }
    else {
      gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.scores[
                                      18 + 1 + number]),
                     20 + (SCORE_BOARD_WIDTH * (number + 1)) / 3 +
                     (5 * SCORE_BOARD_WIDTH) + 2, height,
                     Graphics.LEFT | Graphics.TOP);

      gfx.drawString(Integer.toString(m_scene.m_player.m_scoreInfo.
                                      totalScores[9]),
                     20 + (5 * SCORE_BOARD_WIDTH) +
                     (SCORE_BOARD_WIDTH) / 2 -
                     5, height + SCORE_BOARD_HEIGHT / 2,
                     Graphics.LEFT | Graphics.TOP);
    }
  }

  private void setCamera() {
      //8/19 Milo;forRender3D Start
    if (m_keyCode == CGameMain.gk_UPLEFT & m_isRollingScene == false)
      m_isZooming = !m_isZooming;
    if (m_keyCode == CGameMain.gk_UPRIGHT & m_isZooming == false)
      m_isRollingScene = !m_isRollingScene;

    if (m_isRollingScene == true) {
      if (m_keyCode == CGameMain.gk_LEFT) {
        //m_rotationSceneY -= 10;
        m_scene.m_render3D.m_lookat[0] -= 10;
      }
      else if (m_keyCode == CGameMain.gk_RIGHT) {
        //m_rotationSceneY += 10;
        m_scene.m_render3D.m_lookat[0] += 10;
      }
      else if (m_keyCode == CGameMain.gk_UP) {
        //m_rotationSceneX -= 10;
        m_scene.m_render3D.m_lookat[2] -= 10;
      }
      else if (m_keyCode == CGameMain.gk_DOWN) {
        //m_rotationSceneX += 10;
        m_scene.m_render3D.m_lookat[2] += 10;
      }

      m_isZooming = false;
    }
    else if (m_isZooming == true) {
      if (m_keyCode == CGameMain.gk_UP) {
        m_scene.m_render3D.m_eye[1] -= 50;
      }
      else if (m_keyCode == CGameMain.gk_DOWN) {
        m_scene.m_render3D.m_eye[1] += 50;
      }
      else if (m_keyCode == CGameMain.gk_LEFT) {
        m_scene.m_render3D.m_eye[0] -= 10;
        m_scene.m_render3D.m_lookat[0] += 10;
      }
      else if (m_keyCode == CGameMain.gk_RIGHT) {
        m_scene.m_render3D.m_eye[0] += 10;
        m_scene.m_render3D.m_lookat[0] -= 10;
      }

      m_isRollingScene = false;
    }

//CGameMain.iKeyCode = def.KEYNOTPRESSED;
//keyCode = def.KEYNOTPRESSED;

    if (m_isRollingScene | m_isZooming) {

      m_scene.UpdateCamera();

      /*AffineTrans trans = new AffineTrans();
       trans.setIdentity();
       AffineTrans trans2 = new AffineTrans();
       trans2.setIdentity();
       if (m_rotationSceneX != 0) trans.setRotationX(m_rotationSceneX);
       if (m_rotationSceneY != 0) {
       trans2.setRotationY(m_rotationSceneY);
       trans.mul(trans2);
       }
       m_scene.m_render3D.m_ViewTrans.mul(trans);*/

      //8/19 Milo;forRender3D End
    }
  }
}

⌨️ 快捷键说明

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