📄 backmap.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -