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

📄 gamelogic.java~1~

📁 一个类似炸弹人的游戏(city hunter)
💻 JAVA~1~
📖 第 1 页 / 共 5 页
字号:
         { //////在暴炸点上
           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 void Disposaldetonation_spot(Graphics g) { /////////////处理暴炸点.-1
    int k = 0;
    for (; k < M_detonation_spot.length; 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 void DisposalCPUplay() { //////////////////////////处理CPU玩家.没有处理特殊小怪.(穿插墙,放蛋可在这处理)
    for (int icpu = 0; icpu < m_iCPUPlayNo; 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 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;
              M_iHPlay[1] = (M_Bomb[i][1] * 16);
              M_Bomb[i][2] = (byte) kk;
              M_iHPlay[2] = (M_Bomb[i][2] * 16);
              M_Bomb[i][3] = bombset; // bomb live time
              M_Bomb[i][4] = (byte) (M_iHPlay[4]);
              break;
            }
          }
        }
      }
    }
    else
    { ///////////////////////////////////处理行走
      oldmandirect = (byte) M_iHPlay[3];
      //    m_pathW=16-M_iHPlay[5];  //修改行走
      m_pathW = 16 - M_iHPlay[5];
      if (m_iKey == KEY_LEFT)
      { //<<----------

        x = x - M_iHPlay[5];



        if (M_imapno[ (y)  >>4][ (x + 1) >>4] == 1 &&
            M_imapno[ (y + 16) >>4][ (x + 1) >>4] == 1)
        {
          M_iHPlay[1] = x;
          M_iHPlay[2] = y;
        }
        else if (M_imapno[ (y + M_iHPlay[5]+2) / 16][x / 16] == 1 &&
                 M_imapno[ (y + m_pathW-2) / 16][x / 16] == 1)
        {
          M_iHPlay[1] = x;
          if ((y &0xf) <= 5)
          {
            k = 0;
          }
          else
          {
            k = 16;
          }
          M_iHPlay[2] = ( (y >> 4) << 4) + k;
        }
        i = 0;
      }
      else if (m_iKey == KEY_UP)
      { ////// up
        y = y - M_iHPlay[5];



        if (M_imapno[y >>4][ (x) >>4] == 1 &&
            M_imapno[y >>4][ (x + 16) >>4] == 1)
        {
          M_iHPlay[1] = x;
          M_iHPlay[2] = y;
        }
        else if (M_imapno[ (y) >>4][ (x + M_iHPlay[5]+2) >>4] == 1 &&
                 M_imapno[ (y) >> 4][ (x + m_pathW-2) >>4] == 1)
        { //修改
          if ((x &0xf) <= 5)
          {
            k = 0;
          }
          else
          {
            k = 16;
          }
          M_iHPlay[1] = ( (x >> 4) << 4) + k;
          M_iHPlay[2] = y;
        }
        i = 1;
      }
      else if (m_iKey == KEY_RIGHT)
      { ///---->
        x = x + M_iHPlay[5];

        if( M_imapno[ y >>4][ x>>4] == 3)
       {
         M_iHPlay[1] = x;
         M_iHPlay[2] = y;
       }

        if (M_imapno[ (y) >>4][ (x + m_pathW) >>4] == 1 &&
            M_imapno[ (y + 16) >>4][ (x + m_pathW) >>4] ==1 )
        {
          M_iHPlay[1] = x;
          M_iHPlay[2] = y;
        }
        else if (M_imapno[ (y + M_iHPlay[5]+2) >>4][ (x + m_pathW) >>4] == 1 &&
                 M_imapno[ (y + m_pathW-2) >>4][ (x + m_pathW) >>4] == 1)
        {
          if ((y &0xf) <= 5)
          {
            k = 0;
          }
          else
          {
            k = 16;
          }
          M_iHPlay[1] = x;
          M_iHPlay[2] = ( (y >> 4) << 4) + k;
        }
        i = 2;
      }
      else if (m_iKey == KEY_DOWN)
      { ////// down

        y = y + M_iHPlay[5];
        if( M_imapno[ y >>4][ x>>4] == 3)
        {
          M_iHPlay[1] = x;
          M_iHPlay[2] = y;
        }
        if (M_imapno[ (y + m_pathW) >>4][ (x) >>4] == 1 &&
            M_imapno[ (y + m_pathW) >>4][ (x + 16) >>4] == 1)
        {
          M_iHPlay[1] = x;
          M_iHPlay[2] = y;
        }
        else if (M_imapno[ (y + m_pathW) >>4][ (x + M_iHPlay[5]+2) >>4] == 1 &&
                 M_imapno[ (y + m_pathW) >>4][ (x + m_pathW-2) >>4] == 1)
        {
          if ((x &0xf) <= 5)
          {
            k = 0;
          }
          else
          {

⌨️ 快捷键说明

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