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

📄 gamelogic.java.bak

📁 一个类似炸弹人的游戏(city hunter)
💻 BAK
📖 第 1 页 / 共 5 页
字号:
          int temp4 = M_iHPlay[2] - (M_detonation_spot[k][2] << 4);

          if (M_iHPlay[0] > 0)
          {
            if ( (Math.abs(temp3) < 13 && Math.abs(temp4) < 3) ||
                (Math.abs(temp3) < 3 && Math.abs(temp4) < 13))
            {
              M_iHPlay[0] = -36;
            }
          }

          if (M_iCPlay[i][0] > 0)
          {
            if ( (Math.abs(temp1) < 14 && Math.abs(temp2) < 3) ||
                (Math.abs(temp1) < 3 && Math.abs(temp2) < 14))
            {
              m_iScore += M_iCPlay[i][0] * 30;
              M_iCPlay[i][0] = -30;
            }
          }
        }

      }
      if (M_detonation_spot[k][0] >= 20 && M_detonation_spot[k][0] <= 24 &&
          M_iHPlay[0] > 0)
      {
        int temp3 = M_iHPlay[1] - (M_detonation_spot[k][1] << 4);
        int temp4 = M_iHPlay[2] - (M_detonation_spot[k][2] << 4);
        byte a = M_detonation_spot[k][0];
        if ( (Math.abs(temp3) < 8 && Math.abs(temp4) < 3) ||
            (Math.abs(temp3) < 3 && Math.abs(temp4) < 8))
        {
          M_imapno[M_detonation_spot[k][2]][M_detonation_spot[k][1]] = 1;
          M_detonation_spot[k][0] = 0;

          if (m_bSound == true)
         {
            m_pEffect.StopSound();
           m_pEffect.PlaySound( (byte)1);
       //     m_pEffect.PlaySound("/key.mid");
         }

          switch (a)
          {
            case 20:
              m_iScore += 50;
              break;
            case 21:
              if (M_iHPlay[5] < 5)
              {
                M_iHPlay[5] += 1;
              }
              break;
            case 22:
              if (M_iHPlay[4] < 4)
              {
                M_iHPlay[4] += 1;
              }
              break;
            case 23:
              if (M_iHPlay[6] < 4)
              {
                M_iHPlay[6] += 1;
              }
            case 24:
              m_iLive++;
              break;
          }
        }
      }
    }

  }

  private  final void DisposalBomb() { /////////处理炸弹
    int i, k;
    for (i = 0; i < m_bombtotal; i++)
    {

      if (M_Bomb[i][0] >= 1)
      {
        M_Bomb[i][3]--; /////////////炸弹时间减1
        if (M_Bomb[i][3] == 0)
        {
          M_Bomb[i][0] = 0; /////////////消亡
            if (m_bSound == true)
            {
              m_pEffect.StopSound();
              m_pEffect.PlaySound((byte)2);

            }
            if (m_bVibrate == true)
            {
              m_pEffect.Vibrate();
            }

          M_imapno[M_Bomb[i][2]][M_Bomb[i][1]] = 1; ////////改地图
          findBombpath(i); //////////设置暴炸点.
        }
      }
    } ////////////////////////////////////

    for (i = 0; i < m_bombtotal; i++)
    { ////////处理连暴
      if (M_Bomb[i][0] >= 1)
      {
        int j = M_detonation_spot.length;
        for (k = j -1 ; k >= 0 ; k--)
        {

          if (M_detonation_spot[k][0] >= 1 && M_detonation_spot[k][0] <= 7 &&
              M_detonation_spot[k][1] == M_Bomb[i][1] &&
              M_detonation_spot[k][2] == M_Bomb[i][2])
          { //////在暴炸点上
            M_Bomb[i][3] = 1; //////设置下一次暴.
          }
        }
      }
    }

    /*   for (k = 0; k < M_detonation_spot.length; k++)
       {
         if (M_detonation_spot[k][0] == 0)
            break;
          for (i = 0; i < m_bombtotal; i++)
          {
            if (M_detonation_spot[k][0] >= 1 && M_detonation_spot[k][0] <= 7 &&
                M_detonation_spot[k][1] == M_Bomb[i][1] &&
                M_detonation_spot[k][2] == M_Bomb[i][2])
            { //////在暴炸点上
              M_Bomb[i][3] = 1; //////设置下一次暴.
            }
          }
       }  */

  }

  private  final void Disposaldetonation_spot(Graphics g) { /////////////处理暴炸点.-1
    int k = 0;
    int j = M_detonation_spot.length;
    for (k = j -1 ; k >= 0 ; k--)
    {

      if (M_detonation_spot[k][0] != 0)
      {
        M_detonation_spot[k][3]--;

        if (M_detonation_spot[k][0] > 7)
        {
          g.drawImage(M_imgmedal[M_detonation_spot[k][0] - 20],
                      (M_detonation_spot[k][1] << 4) - m_movex,
                      (M_detonation_spot[k][2] << 4) - m_movey, 0);
        }
        else
        {
          g.drawImage(m_Bombing[M_detonation_spot[k][0] - 1],
                      (M_detonation_spot[k][1] << 4) - m_movex,
                      (M_detonation_spot[k][2] << 4) - m_movey, 0);

        }
        if (M_detonation_spot[k][3] == 0)
        {
          M_detonation_spot[k][0] = 0;
        }
      }
    }
  }

  private  final void DisposalCPUplay() { //////////////////////////处理CPU玩家.没有处理特殊小怪.(穿插墙,放蛋可在这处理)
    for (int icpu = m_iCPUPlayNo-1; icpu >= 0; icpu--) //cpu个数要改过来
    { // 测试用
      if (M_iCPlay[icpu][0] > 0)
      {
        int x, y, i, j = 0, k, rr[] =
            {
            0, 0, 0, 0};
        x = M_iCPlay[icpu][1];
        y = M_iCPlay[icpu][2];
        i = M_iCPlay[icpu][3];
        //   m_pathW=16-M_iCPlay[icpu][5];  // 修改行走
        m_pathW = 16 - 4;
        /////////////////////////////////原方向先做.
        if (i == 0)
        { //<<----------
          x = x - M_iCPlay[icpu][5];
          if (M_imapno[ (y) >> 4][ (x + 1) >> 4] == 1 &&
              M_imapno[ (y + 16) >> 4][ (x + 1) >> 4] == 1)
          { // 修改
            M_iCPlay[icpu][1] = x;
            M_iCPlay[icpu][2] = y;
            rr[0] = 1;
          }
          else if (M_imapno[ (y + M_iCPlay[icpu][5]) >> 4][x >> 4] == 1 &&
                   M_imapno[ (y + m_pathW) >> 4][x >> 4] == 1)
          { //修改
            M_iCPlay[icpu][1] = x;
            if ( (y & 0xf) <= 5)
            {
              k = 0;
            }
            else
            {
              k = 16;
            }
            M_iCPlay[icpu][2] = ( (y >> 4) << 4) + k;
            rr[0] = 1;
          }
          i = 0;
        }
        else if (i == 1)
        { //  up
          y = y - M_iCPlay[icpu][5];
          if (M_imapno[y >> 4][ (x) >> 4] == 1 &&
              M_imapno[y >> 4][ (x + 16) >> 4] == 1)
          {
            M_iCPlay[icpu][1] = x;
            M_iCPlay[icpu][2] = y;
            rr[1] = 1;
          }
          else if (M_imapno[y >> 4][ (x + M_iCPlay[icpu][5]) >> 4] == 1 &&
                   M_imapno[y >> 4][ (x + m_pathW) >> 4] == 1)
          { //修改
            if ( (x & 0xf) <= 5)
            {
              k = 0;
            }
            else
            {
              k = 16;
            }
            M_iCPlay[icpu][1] = ( (x >> 4) << 4) + k;
            M_iCPlay[icpu][2] = y;
            rr[1] = 1;
          }
          i = 1;
        }
        else if (i == 2)
        { ///---->
          x = x + M_iCPlay[icpu][5];
          if (M_imapno[ (y) >> 4][ (x + m_pathW) >> 4] == 1 &&
              M_imapno[ (y + 16) >> 4][ (x + m_pathW) >> 4] == 1)
          {
            M_iCPlay[icpu][1] = x;
            M_iCPlay[icpu][2] = y;
            rr[2] = 1;
          }
          else if (M_imapno[ (y + M_iCPlay[icpu][5]) >> 4][ (x + m_pathW) >> 4] ==
                   1 && M_imapno[ (y + m_pathW) >> 4][ (x + m_pathW) >> 4] == 1)
          {
            if ( (y & 0xf) <= 5)
            {
              k = 0;
            }
            else
            {
              k = 16;
            }
            M_iCPlay[icpu][1] = x;
            M_iCPlay[icpu][2] = ( (y >> 4) << 4) + k;
            rr[2] = 1;
          }
          i = 2;
        }
        else if (i == 3)
        { ////down
          y = y + M_iCPlay[icpu][5];
          if (M_imapno[ (y + m_pathW) >> 4][ (x) >> 4] == 1 &&
              M_imapno[ (y + m_pathW) >> 4][ (x + 16) >> 4] == 1)
          {
            M_iCPlay[icpu][1] = x;
            M_iCPlay[icpu][2] = y;
            rr[3] = 1;
          }
          else if (M_imapno[ (y + m_pathW) >> 4][ (x + M_iCPlay[icpu][5]) >> 4] ==
                   1 && M_imapno[ (y + m_pathW) >> 4][ (x + m_pathW) >> 4] == 1)
          {
            if ( (x & 0xf) <= 5)
            {
              k = 0;
            }
            else
            {
              k = 16;
            }
            M_iCPlay[icpu][1] = ( (x >> 4) << 4) + k;
            M_iCPlay[icpu][2] = y;
            rr[3] = 1;
          }
          i = 3;
        }
        if (rr[0] == 1 || rr[1] == 1 || rr[2] == 1 || rr[3] == 1)
        {
          M_iCPlay[icpu][3] = i;
          M_iCPlay[icpu][4] = (M_iCPlay[icpu][4] + 1) & 0x1;
        }
        else
        {
          int iii = 0;
          while (rr[0] == 0 && iii < 6)
          { ///////////////最多选5次,当能你可以改
            x = M_iCPlay[icpu][1];
            y = M_iCPlay[icpu][2];
            i = rand_no(4);
            iii++;
            /*      if (i == 0)
                  {
                    i = 2;
                  }
                  else if (i == 1)
                  {
                    i = 4;
                  }
                  else if (i == 2)
                  {
                    i = 6;
                  }
                  else
                  {
                    i = 8;
                  }   */
            if (i == 0)
            { //<<----------
              x = x - M_iCPlay[icpu][5];
              if (M_imapno[ (y) >> 4][ (x + 1) >> 4] == 1 &&
                  M_imapno[ (y + 16) >> 4][ (x + 1) >> 4] == 1)
              { // 修改
                M_iCPlay[icpu][1] = x;
                M_iCPlay[icpu][2] = y;
                rr[0] = 1;
              }
              else if (M_imapno[ (y + M_iCPlay[icpu][5]) >> 4][x >> 4] == 1 &&
                       M_imapno[ (y + m_pathW) >> 4][x >> 4] == 1)
              { //修改
                M_iCPlay[icpu][1] = x;
                if ( (y & 0xf) <= 5)
                {
                  k = 0;
                }
                else
                {
                  k = 16;
                }
                M_iCPlay[icpu][2] = ( (y >> 4) << 4) + k;
                rr[0] = 1;
              }
              i = 0;
            }
            else if (i == 1)
            { //  up
              y = y - M_iCPlay[icpu][5];
              if (M_imapno[y >> 4][ (x) >> 4] == 1 &&
                  M_imapno[y >> 4][ (x + 16) >> 4] == 1)
              {
                M_iCPlay[icpu][1] = x;
                M_iCPlay[icpu][2] = y;
                rr[0] = 1;
              }
              else if (M_imapno[y >> 4][ (x + M_iCPlay[icpu][5]) >> 4] == 1 &&
                       M_imapno[y >> 4][ (x + m_pathW) >> 4] == 1)
              { //修改
                if ( (x & 0xf) <= 5)
                {
                  k = 0;
                }
                else
                {
                  k = 16;
                }
                M_iCPlay[icpu][1] = ( (x >> 4) << 4) + k;
                M_iCPlay[icpu][2] = y;
                rr[0] = 1;
              }
              i = 1;
            }
            else if (i == 2)
            { ///---->
              x = x + M_iCPlay[icpu][5];
              if (M_imapno[ (y) >> 4][ (x + m_pathW) >> 4] == 1 &&
                  M_imapno[ (y + 16) >> 4][ (x + m_pathW) >> 4] == 1)
              {
                M_iCPlay[icpu][1] = x;
                M_iCPlay[icpu][2] = y;
                rr[0] = 1;
              }
              else if (M_imapno[ (y + M_iCPlay[icpu][5]) >> 4][ (x + m_pathW) >>
                       4
                       ] == 1 &&
                       M_imapno[ (y + m_pathW) >> 4][ (x + m_pathW) >> 4] == 1)
              {
                if ( (y & 0xf) <= 5)
                {
                  k = 0;
                }
                else
                {
                  k = 16;
                }
                M_iCPlay[icpu][1] = x;
                M_iCPlay[icpu][2] = ( (y >> 4) << 4) + k;
                rr[0] = 1;
              }
              i = 2;
            }
            else if (i == 3)
            { ////down
              y = y + M_iCPlay[icpu][5];
              if (M_imapno[ (y + m_pathW) >> 4][ (x) >> 4] == 1 &&
                  M_imapno[ (y + m_pathW) >> 4][ (x + 16) >> 4] == 1)
              {
                M_iCPlay[icpu][1] = x;
                M_iCPlay[icpu][2] = y;
                rr[0] = 1;
              }
              else if (M_imapno[ (y + m_pathW) >> 4][ (x + M_iCPlay[icpu][5]) /
                       16] == 1 &&
                       M_imapno[ (y + m_pathW) >> 4][ (x + m_pathW) >> 4] == 1)
              {
                if ( (x & 0xf) <= 5)
                {
                  k = 0;
                }
                else
                {
                  k = 16;
                }
                M_iCPlay[icpu][1] = ( (x >> 4) << 4) + k;
                M_iCPlay[icpu][2] = y;
                rr[0] = 1;
              }
              i = 3;
            }

            if (rr[0] == 1)
            {
              M_iCPlay[icpu][3] = i;
              M_iCPlay[icpu][4] = 0;
            }
          }
        }
      }
    }
  }

  private  final void DisposalHplay() { //////////////////处理人玩家
    int x, y, i, j = 0, k, kk;
    x = M_iHPlay[1];
    y = M_iHPlay[2];
    i = M_iHPlay[3];
    if (m_iKey == KEY_FIRE)
    { //////////////处理放蛋  5 is keycode
      k = x >> 4; // k and kk is bomb position
      if ( (x & 0xf) >= 8)
      {
        k = k + 1;
      }
      kk = y >> 4;
      if ( (y & 0xf) >= 8)
      {
        kk = kk + 1;
      }
      if (M_imapno[kk][k] != 3)
      { // ???
        for (i = 0; i < m_bombtotal; i++)
        {
          if (M_Bomb[i][0] == 1)
          {
            j++; // 统计炸弹个数
          }
        }
        if (j < M_iHPlay[6])
        {
          for (i = 0; i < m_bombtotal; i++)
          {
            if (M_Bomb[i][0] == 0)
            {
              M_imapno[kk][k] = 3;
              M_Bomb[i][0] = 1;
              M_Bomb[i][1] = (byte) k;

⌨️ 快捷键说明

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