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

📄 mscreen.java~5~

📁 手机游戏小游戏 合金弹头 J2ME S60模拟器源代码
💻 JAVA~5~
📖 第 1 页 / 共 5 页
字号:
   private int copyrigh_line = 0;
   private final void copyrigh_init(){
     copyrigh_line = 0;
   }

   private final void copyrigh_run(){
     if((key_Statuse & KEY_OVER) != 0){
       if(copyrigh_line > 0) copyrigh_line --;
     }else if((key_Statuse & KEY_DOWN) != 0){
       if(copyrigh_line < copyrigh_text.length - 12) copyrigh_line ++;
     }
     refresh();
   }

   private final void copyrigh_key(int keycode){
     switch(keycode){
       case KEY_SOFT2: process_set(SCREEN_MAINMENU); break;
     }
   }

   private final void copyrigh_draw(){
     g.setClip(0, 0, screen_w, screen_h);
     g.drawImage(faceres[FACE_MENUCOVER], 0, 0, 0);
     g.setColor(0xFFFFFF);
     for(int i = 0; i < 12; i++){
       g.setColor(0);
       g.drawString(copyrigh_text[copyrigh_line + i], (screen_w >> 1) - 1, 12 + 14 * i,17);
       g.drawString(copyrigh_text[copyrigh_line + i], (screen_w >> 1) + 1, 12 + 14 * i,17);
       g.drawString(copyrigh_text[copyrigh_line + i], screen_w >> 1, 13 + 14 * i,17);
       g.drawString(copyrigh_text[copyrigh_line + i], screen_w >> 1, 11 + 14 * i,17);
       g.setColor(0xFFFFFF);
       g.drawString(copyrigh_text[copyrigh_line + i], screen_w >> 1, 12 + 14 * i,17);
     }
     g.drawString("上/上翻 下/下翻", 14, 188, 0); g.drawString("返回", 134, 188, 0);
   }

   //****************************************************************************
   /** @todo:帮助信息 */
   //****************************************************************************
   private final String[] help_3650 = {
     "    游戏描述",
     "  这是家喻户晓的街机游",
     "戏《合金弹头》的手机版,",
     "大家可以在手机上重温一下",
     "当时的记忆了。",
     "    游戏规则",
     "  在漫天的炮火中,突破",
     "重重阻挠完成任务,击败最",
     "终敌人。",
     "   战士操作指南",
     "举枪/起身:    1/上",
     "向左移动:     2/左",
     "向右移动:     */右",
     "下蹲:       3/下",
     "开枪:     #/导航键",
     "投掷手雷:     0",
     "跳跃:       9",
     "   飞机操作指南",
     "向上移动/枪口向上:1/上",
     "向左移动:     2/左",
     "向右移动:     */右",
     "向下移动/枪口向下:3/下",
     "开枪:     #/导航键",
     "   坦克操作指南",
     "枪口向上:     1/上",
     "向左移动/枪口向左:2/左",
     "向右移动/枪口向右:*/右",
     "下蹲/枪口向下:  3/下",
     "开枪:     #/导航键",
     "跳跃:       9",
   };
   private final String[] help_7650 ={
     "    游戏描述",
     "  这是家喻户晓的街机游",
     "戏《合金弹头》的手机版,",
     "大家可以在手机上重温一下",
     "当时的记忆了。",
     "    游戏规则",
     "  在漫天的炮火中,突破",
     "重重阻挠完成任务,击败最",
     "终敌人。",
     "   战士操作指南",
     "向上开枪/起身:  2/上",
     "向左移动:     4/左",
     "向右移动:     6/右",
     "下蹲开枪:     8/下",
     "开枪:     9/导航键",
     "投掷手雷:     0",
     "跳跃:       */#",
     "   飞机操作指南",
     "向上移动/枪口向上:2/上",
     "向左移动:     4/左",
     "向右移动:     6/右",
     "向下移动/枪口向下:8/下",
     "开枪:     9/导航键",
     "   坦克操作指南",
     "枪口向上:     2/上",
     "向左移动/枪口向左:4/左",
     "向右移动/枪口向右:6/右",
     "下蹲/枪口向下:  8/下",
     "开枪:     9/导航键",
     "跳跃:       */#",
   };
   private int helpinfo_line;
   private final void helpinfo_init(){
     helpinfo_line = 0;
   }

   private final void helpinfo_run(){
     String[] help = (platform == N3650)?help_3650:help_7650;
     if((key_Statuse & KEY_OVER) != 0){
       if(helpinfo_line > 0) helpinfo_line --;
     }else if((key_Statuse & KEY_DOWN) != 0){
       if(helpinfo_line < help.length - 12) helpinfo_line ++;
     }
     refresh();
   }

   private final void helpinfo_key(int keycode){
     switch(keycode){
       case KEY_SOFT2: process_set(SCREEN_MAINMENU); break;
     }
   }

   private final void helpinfo_draw(){
     g.setClip(0, 0, screen_w, screen_h);
     g.drawImage(faceres[FACE_MENUCOVER], 0, 0, 0);
     g.setColor(0xFFFFFF);
     String[] help = (platform == N3650)?help_3650:help_7650;
     for(int i = 0; i < 12; i++){
       g.setColor(0);
       g.drawString(help[helpinfo_line + i], 15, 12 + 14 * i, 0);
       g.drawString(help[helpinfo_line + i], 17, 12 + 14 * i, 0);
       g.drawString(help[helpinfo_line + i], 16, 11 + 14 * i, 0);
       g.drawString(help[helpinfo_line + i], 16, 13 + 14 * i, 0);
       g.setColor(0xFFFFFF);
       g.drawString(help[helpinfo_line + i], 16, 12 + 14 * i, 0);
     }
     g.drawString("上/上翻 下/下翻", 14, 188, 0); g.drawString("返回", 134, 188, 0);
   }

   //****************************************************************************
   /** @todo:关卡选择 */
   //****************************************************************************
   private int selegate_max = 1;
   private int selegate_index = 1;

   private final void selegate_init(){
     selegate_max = record_read_mission();
   }

   private final void selegate_draw(){
     g.setColor(0);
     g.setClip(0 , 0, screen_w, screen_h);
     g.fillRect(0, 0, screen_w, screen_h);
     g.setColor(0xFFFFFF);
     g.drawImage(faceres[FACE_MISSION_OPT], 61, 79, 0);
     g.setColor(0xBDBDBD);
     g.drawRect(59, 78 + (selegate_index - 1) * 21, 59, 21);
     draw_alpharect(59, 78 + selegate_max * 21, 95, 97, (short)0x5000);
   }

   private final void selegate_key(int keycode){
     switch(keycode){
       case KEY_OVER:
         if(selegate_index > 1) selegate_index --;
         refresh();
         break;
       case KEY_DOWN:
         if(selegate_index < selegate_max) selegate_index ++;
         refresh();
         break;
       case KEY_SOFT2:
         process_set(SCREEN_MAINMENU);
         break;
       case KEY_FIRE:
       case KEY_SOFT1:
         hero_anima = 10;
         hero_bombcount = 10;
         hero_being = 3;
         hero_score = 0;
         gamemenushow = false;
         gamebodyexit = false;
         mission_start(selegate_index);
         screen_index = SCREEN_GAMEBODY;
         break;
     }
   }
   private void selegate_run(){
     refresh();
   }
  //****************************************************************************
  /** @todo:地图数据 */
  //****************************************************************************
  private static Image[] platres; //图形资源列表
  private static Image[] faceres; //界面用的图形资源

  private final void face_load(){
    InputStream in = stream_create("/game.bin");
    try{
      faceres = new Image[in.read() + (in.read() << 8)];
      skip(in, faceres.length * 2);
      for(int i = 0; i < faceres.length; i++){
        int len = in.read() + (in.read() << 8);
        byte[] gdata = new byte[len + 6];
        System.arraycopy("GIF89a".getBytes(), 0, gdata, 0, 6);
        in.read(gdata, 6, len);
        faceres[i] = Image.createImage(gdata, 0, gdata.length);
      }
    }catch(Exception e){
      e.printStackTrace();
    }
  }


  //****************************************************************************
  /** @todo: 场景 */
  //****************************************************************************
  private static int platid = 1; //当前的地图索引
  private static int plat_w; //地图网格宽度
  private static int plat_h; //地图网格高度
  private static int plat_n; //右边出口

  private int[][] facts; //基本地物数据
  private int backIndex; //0层及后面的图形的个数

  private final void fact_draw_back(){
    g.setClip(0, 0, screen_w, screen_h);
    int[] fact;
    for(int i = 0 ; i < backIndex; i++){
      fact = facts[i];
      if(visible(fact[0], fact[1], fact[2], fact[3]))
        dg.drawImage(platres[fact[5]], fact[0] - position_x, fact[1] - position_y, 0, fact[4]);
    }
  }

  private final void fact_draw_fore(){
    g.setClip(0, 0, screen_w, screen_h);
    int[] fact;
    for(int i = backIndex; i < facts.length; i++){
      fact = facts[i];
      if(visible(fact[0], fact[1], fact[2], fact[3]))
        dg.drawImage(platres[fact[5]], fact[0] - position_x, fact[1] - position_y, 0, fact[4]);
    }
  }


  private final void fact_load(InputStream in) throws IOException {
    backIndex = readWord(in);
    int total = readWord(in);
    facts = new int[total][6];
    for (int i = 0; i < total; i++) {
      facts[i][0] = readByte(in) * 8;
      facts[i][1] = readByte(in) * 8;
      facts[i][4] = translateRotate(in.read());
      facts[i][5] = in.read();
      if ( (facts[i][4] == 90) || (facts[i][4] == 270)) {
        facts[i][2] = facts[i][0] + platres[facts[i][5]].getHeight();
        facts[i][3] = facts[i][1] + platres[facts[i][5]].getWidth();
      }
      else {
        facts[i][2] = facts[i][0] + platres[facts[i][5]].getWidth();
        facts[i][3] = facts[i][1] + platres[facts[i][5]].getHeight();
      }
    }
  }
  //****************************************************************************
  /** @todo: 地形 */
  //****************************************************************************
  private byte[]  grids; //地形数组 每个方格占4BIT
  private final int CELL_NONE = 0;//空白
  private final int CELL_WALL = 1;//墙壁
  private final int CELL_ROOF = 2;//平台

  /**********************************************
   * 查询地图上某个格子的作用区属性
   * @param x int 场景上某格的X坐标
   * @param y int 场景上某格的Y坐标
   * @return int  (X,Y)所表示格子的作用区值 如果(X,Y)的位置超出地图范围-1
   **********************************************/
  private final int grid_cellvalue(int x, int y){
    if((x < 0) || (x >= plat_w) || (y < 0) || (y >= plat_h))  return - 1;
    int v = x + y * plat_w;
    return ((v & 1) == 1)? grids[v >> 1] >> 4: grids[v >> 1] & 0x0f;
  }

  private final void grid_load(InputStream in) throws IOException {
    grids = new byte[ (plat_h * plat_w) >> 1];
    in.read(grids);
  }

  //****************************************************************************
  /** @todo: 背景 */
  //****************************************************************************
  private int background1_face_w;
  private int background1_face_h;
  private int background1_face_index = -1;

  private int background2_face_y;
  private int background2_face_w;
  private int background2_speed;
  private int background2_face_index = -1;
  private int background2_position_x;

  private int background3_face_y;
  private int background3_face_w;
  private int background3_speed;
  private int background3_face_index = -1;
  private int background3_position_x;

  /**********************************************
   * 初始化游戏背景
   * @param in InputStream 地图文件流
   * @throws IOException IO异常
   **********************************************/
  private final void back_load(InputStream in) throws IOException {
    int bg1 = readByte(in);
    int bg2 = readByte(in);
    int bg3 = readByte(in);
    int bg2_top = readWord(in);
    int bg3_top = readWord(in);
    int bg2_spd = readByte(in);
    int bg3_spd = readByte(in);
    if ( (bg1 >= 0) && (bg1 < platres.length)) {
      background1_face_index = bg1;
      background1_face_w = platres[bg1].getWidth();
      background1_face_h = platres[bg1].getHeight();
    }
    else background1_face_index = -1;
    if ( (bg2 >= 0) && (bg2 < platres.length)) {
      background2_face_index = bg2;
      background2_face_y = bg2_top;
      background2_face_w = platres[bg2].getWidth();
      background2_position_x = 0;
      background2_speed = bg2_spd;
    }
    else background2_face_index = -1;

⌨️ 快捷键说明

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