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

📄 hitmap.java

📁 手机RPG游戏
💻 JAVA
字号:
package window;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.*;
public class HitMap    extends TiledLayer{
  private int width=0;
  private int height=0;

  public HitMap(int colums,int rows,Image img,int cellw,int cellh,int mapId) {
    super(colums,rows,img,cellw,cellh);
    width=colums*cellw;
    height=rows*cellh;
        // int map[][]=new int[rows] [colums];
        switch (mapId){
          case 0:
               int map_0[][]={//村内地图.
               { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0,14, 0, 0, 0, 0,13, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0,13, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0,14, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0,13, 0, 0, 0, 0, 0, 0,13, 6},
               { 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9},
               };
               this.readMap(map_0,colums,rows);
               break;
         case 1:
                 int map_1[][]={//村外地图.
               { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3},
               { 4,13, 0, 0, 0, 0, 0, 0, 0, 0,14, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9},
               };
               this.readMap(map_1,colums,rows);
               break;
             case 2:
                 int map_2[][]={//山洞地图.
               { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3},
               { 4,13, 0, 0, 0, 0, 0, 0, 0, 0,14, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
               { 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9},
               };
               this.readMap(map_2,colums,rows);
               break;

       }


  }//end BackMap
  //////////////////
  private void readMap(int map[][],int colums,int rows){
    for (int row=0; row<rows; row++) {
             for (int col=0; col<colums; col++)
             {      // map[row][col]= 5;//注意:这里的图号是从1开始的。应用数组定好值做地图
                     this.setCell(col,row,map[row][col]);
             }
           }

  }
 public int getMapWidth(){return width;}
 public int getMapHeight(){return height;}






}

⌨️ 快捷键说明

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