backmap.java

来自「手机RPG游戏」· Java 代码 · 共 91 行

JAVA
91
字号
package window;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.*;
public class BackMap extends TiledLayer{
  private int width=0;
  private int height=0;

  public BackMap(int colums,int rows,Image img,int cellw,int cellh,int backMapId) {
    super(colums,rows,img,cellw,cellh);
    width=colums*cellw;
    height=rows*cellh;
         //=new int[rows] [colums];
        switch(backMapId){
         case 0:
                int map_0[][]={//村内底图
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
               { 5, 5, 5, 12,5, 5, 5, 5, 5, 5, 5, 5},
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 12,5, 5},
               { 5, 5, 5, 5, 5, 12,5, 5, 5, 5,12, 5},
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
               { 5, 12,5, 5, 5, 5, 5, 12,5, 5, 5, 5},
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
               { 5, 5, 12,5, 5, 5, 5, 5,12,12, 5, 5},
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
               { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
               };
               this.readMap(map_0,colums,rows);
               break;
         case 1:
                 int map_1[][]={//村外底图
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 12,5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 12,5, 5},
              { 5, 5, 5, 5, 5, 12,5, 5, 5, 5,12, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 12,5, 5, 5, 5, 5, 12,5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 12,5, 5, 5, 5, 5,12,12, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              };
              this.readMap(map_1,colums,rows);
              break;
          case 2:
                 int map_2[][]={//山洞底图
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
              };
              this.readMap(map_2,colums,rows);
              break;
        }


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


 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]);
     }
   }


 }







}

⌨️ 快捷键说明

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