package map;
import javax.microedition.lcdui.Image;
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
public class Draw{
public static int[] tanrs = {0,6,3,5,2,1,7,4};
int nMapData0[][]={
{0x0002,0x0009,0x0002,0x0001,0x0002,0x0003,0x000c,0x0014,0x1000016,0x1000018,0x1000018,0x1000018,0x1000018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1000018,0x1000012,0x000c,0x000c,0x000c,0x0006,0x0002,0x0001,0x0009,0x0009},
{0x0009,0x0001,0x0002,0x0002,0x100050a,0x1000004,0x000c,0x100040c,0x0014,0x0017,0x0017,0x0016,0x1000018,0x0018,0x0018,0x1000018,0x1000018,0x1000018,0x1000018,0x1000018,0x1000018,0x1000018,0x0018,0x0018,0x1000013,0x0012,0x000b,0x000c,0x000f,0x1000506,0x0007,0x0001,0x0001},
{0x0002,0x0001,0x0001,0x0001,0x0004,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x0014,0x0016,0x1000018,0x1000018,0x1000018,0x001b,0x0017,0x0017,0x0017,0x0016,0x100001d,0x1000018,0x0018,0x1000018,0x0011,0x100021c,0x000b,0x000b,0x000c,0x0006,0x002a,0x0004},
{0x0006,0x0001,0x0002,0x0004,0x000c,0x000c,0x0008,0x000c,0x000c,0x000f,0x000c,0x000c,0x0014,0x0017,0x0017,0x0017,0x001c,0x000c,0x000c,0x000c,0x0014,0x0016,0x1000018,0x1000018,0x1000018,0x1000011,0x000b,0x000b,0x000e,0x000b,0x000c,0x000c,0x000d},
{0x000c,0x0006,0x0004,0x000c,0x000c,0x000c,0x000c,0x000b,0x000c,0x000c,0x000e,0x000c,0x000c,0x000c,0x000b,0x100010c,0x100000c,0x000c,0x000d,0x000c,0x000c,0x0014,0x0016,0x1000018,0x0018,0x1000013,0x1000012,0x000b,0x000f,0x000b,0x000c,0x000d,0x000c},
{0x000b,0x000c,0x000e,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x0008,0x000c,0x000c,0x000b,0x000b,0x000e,0x000c,0x000c,0x100040d,0x000c,0x001a,0x1000018,0x0018,0x0018,0x1000013,0x1000012,0x100060c,0x000c,0x100000c,0x000c,0x100001a},
{0x000c,0x0005,0x0003,0x000c,0x000d,0x000c,0x000c,0x000c,0x000c,0x000c,0x100030c,0x000c,0x000c,0x000c,0x000c,0x000e,0x000f,0x000c,0x000c,0x100030c,0x000c,0x001a,0x1000019,0x1000018,0x0018,0x0018,0x0018,0x0013,0x1000015,0x0015,0x1000015,0x1000015,0x1000019},
{0x0008,0x0029,0x000a,0x0003,0x000e,0x000c,0x000c,0x000c,0x100020c,0x000c,0x001a,0x1000015,0x0012,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x001a,0x1000019,0x1000018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1000018,0x0018,0x1000018,0x0018,0x0018},
{0x000c,0x0029,0x0002,0x002b,0x000b,0x000b,0x100020c,0x000c,0x001a,0x1000015,0x1000019,0x1000018,0x0011,0x000c,0x000d,0x000d,0x000d,0x000c,0x100001a,0x1000015,0x1000019,0x1000018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1000018,0x0018,0x1000018,0x0018,0x0018},
{0x000c,0x0006,0x002a,0x0004,0x000b,0x000b,0x001a,0x1000015,0x1000019,0x1000018,0x0018,0x100001d,0x0011,0x000d,0x000c,0x001a,0x1000015,0x1000015,0x1000019,0x0018,0x0018,0x1000018,0x1000018,0x1000018,0x1000018,0x001d,0x0018,0x0018,0x1000018,0x0018,0x1000018,0x1000018,0x1000018},
{0x000c,0x000e,0x000c,0x000b,0x000b,0x001a,0x1000019,0x0018,0x0018,0x0018,0x0018,0x1000018,0x1000013,0x1000015,0x1000015,0x1000019,0x1000018,0x0018,0x1000018,0x1000018,0x1000018,0x001b,0x0017,0x0016,0x1000018,0x0018,0x0018,0x1000018,0x100001b,0x0017,0x1000017,0x0016,0x1000018},
{0x000c,0x100060c,0x000c,0x100000c,0x001a,0x1000019,0x1000018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1000018,0x1000018,0x001b,0x0017,0x001c,0x000d,0x0014,0x1000016,0x1000018,0x1000018,0x001b,0x100001c,0x000c,0x100000c,0x000d,0x0016},
{0x000c,0x100000c,0x000c,0x100000c,0x1000020,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1000018,0x1000018,0x1000018,0x001b,0x001c,0x000c,0x000c,0x100030c,0x100010c,0x1000014,0x0017,0x0017,0x001c,0x000e,0x000c,0x000c,0x000c,0x000d},
{0x1000015,0x1000015,0x0015,0x1000015,0x0019,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1000018,0x001b,0x0017,0x001c,0x000d,0x000c,0x100040c,0x000c,0x100030c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c},
{0x0018,0x1000018,0x0018,0x1000018,0x0018,0x1000018,0x1000018,0x1000018,0x0018,0x0018,0x0018,0x0018,0x0018,0x1000018,0x1000018,0x1000018,0x001c,0x100030c,0x000c,0x000c,0x000c,0x000e,0x000c,0x000c,0x000c,0x000c,0x000c,0x0005,0x002c,0x0003,0x000c,0x000c,0x100030c},
{0x0018,0x1000018,0x0018,0x1000018,0x1000018,0x001b,0x0016,0x1000018,0x1000018,0x1000018,0x1000018,0x1000018,0x1000018,0x1000018,0x001b,0x0017,0x001c,0x000c,0x000b,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x0005,0x000a,0x0009,0x002b,0x000c,0x000c,0x100040c},
{0x0018,0x1000018,0x0018,0x100001b,0x0017,0x001c,0x0014,0x0016,0x1000018,0x1000018,0x001b,0x0017,0x0017,0x0017,0x001c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000d,0x0029,0x000a,0x000a,0x002b,0x000c,0x000c,0x000c},
{0x1000018,0x100001b,0x0017,0x100001c,0x000c,0x000d,0x000d,0x0014,0x0017,0x0017,0x001c,0x000c,0x100030c,0x000b,0x100020c,0x000b,0x000c,0x0005,0x0003,0x000c,0x000c,0x000b,0x000c,0x000c,0x100030c,0x000c,0x0006,0x000a,0x0001,0x0004,0x000c,0x000c,0x000c},
{0x0017,0x001c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000d,0x000c,0x000c,0x000c,0x000c,0x000b,0x000b,0x000c,0x0005,0x0002,0x0002,0x0003,0x000c,0x000c,0x0005,0x0003,0x000c,0x000d,0x000b,0x0006,0x0004,0x000c,0x000c,0x000c,0x000c},
{0x000f,0x000c,0x000c,0x0005,0x002c,0x0003,0x000c,0x000c,0x000c,0x000c,0x100040c,0x000c,0x000c,0x000c,0x000c,0x0005,0x0002,0x0001,0x000a,0x0002,0x0003,0x0005,0x0002,0x0002,0x002c,0x0003,0x000c,0x000f,0x000c,0x000c,0x000c,0x000f,0x000c},
{0x000f,0x000f,0x000c,0x0029,0x0002,0x0002,0x0003,0x000c,0x000c,0x000c,0x000c,0x000c,0x0005,0x002c,0x002c,0x0002,0x0002,0x0001,0x0002,0x0001,0x0002,0x0002,0x0001,0x0007,0x000a,0x0004,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c},
{0x000c,0x000f,0x000f,0x0006,0x0002,0x0007,0x0004,0x000c,0x0008,0x000c,0x000c,0x0005,0x0002,0x0009,0x0001,0x0002,0x0001,0x0002,0x0009,0x0001,0x0002,0x0004,0x0006,0x002a,0x0004,0x000c,0x000c,0x000c,0x0005,0x002c,0x0003,0x000d,0x000c},
{0x000c,0x000c,0x000c,0x000b,0x0006,0x0004,0x000c,0x000c,0x000c,0x000c,0x000e,0x0006,0x002a,0x002a,0x002a,0x0002,0x0002,0x002a,0x0002,0x0002,0x0004,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x0005,0x0002,0x0001,0x0002,0x2000503,0x200000c},
{0x000c,0x000c,0x000c,0x000c,0x000f,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000d,0x000f,0x000c,0x000c,0x0006,0x0004,0x0008,0x0006,0x0004,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x0006,0x002a,0x0002,0x0009,0x002b,0x000c},
{0x000c,0x100020c,0x000c,0x100040c,0x000c,0x000c,0x000c,0x0008,0x000c,0x000c,0x000c,0x000c,0x000d,0x000c,0x000c,0x0008,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000f,0x000c,0x000d,0x100040c,0x000c,0x000c,0x000c,0x0006,0x002a,0x0004,0x000c},
{0x000c,0x000c,0x000c,0x000c,0x000c,0x100030c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000b,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c}};
short mapItem0[]={//地圖元素:{通過設置,子圖片索引}
0,0/*地形*/,
1,0/*地形*/,
2,0/*地形*/,
3,0/*地形*/,
4,0/*地形*/,
5,0/*地形*/,
6,0/*地形*/,
7,0/*地形*/,
8,0/*地形*/,
9,0/*地形*/,
10,0/*地形*/,
11,0/*地形*/,
10,0/*地形*/,
12,0/*地形*/,
13,0/*地形*/,
14,0/*地形*/,
15,0/*地形*/,
16,0/*地形*/,
17,0/*地形*/,
18,0/*地形*/,
19,0/*地形*/,
20,0/*地形*/,
21,0/*地形*/,
22,0/*地形*/,
23,0/*地形*/,
24,0/*地形*/,
25,0/*地形*/,
26,0/*地形*/,
27,0/*地形*/,
28,0/*地形*/,
29,0/*地形*/,
30,0/*地形*/,
31,0/*地形*/,
32,0/*地形*/,
33,0/*地形*/,
34,0/*地形*/,
35,0/*地形*/,
36,0/*地形*/,
37,0/*地形*/,
38,0/*地形*/,
39,0/*地形*/,
40,0/*地形*/,
41,0/*地形*/,
42,0/*地形*/
};
short nDrawPos[][]={
{6,0,0,16,16}, //索引:[0]
{6,16,0,16,16}, //索引:[1]
{6,64,16,16,16,4}, //索引:[2] 水平鏡象
{6,64,16,16,16,2}, //索引:[3] R180度
{6,64,16,16,16}, //索引:[4]
{6,64,16,16,16,5}, //索引:[5] 垂直鏡象
{6,0,16,16,16}, //索引:[6]
{6,48,32,16,16}, //索引:[7]
{6,64,32,16,16}, //索引:[8]
{6,0,32,16,16}, //索引:[9]
{6,48,0,16,16}, //索引:[10]
{6,32,16,16,16}, //索引:[11]
{6,32,32,16,16}, //索引:[12]
{6,48,16,16,16}, //索引:[13]
{4,0,0,16,16,4}, //索引:[14] 水平鏡象
{4,0,0,16,16}, //索引:[15]
{4,16,0,16,16}, //索引:[16]
{4,32,0,16,16}, //索引:[17]
{4,48,0,16,16}, //索引:[18]
{4,0,16,16,16}, //索引:[19]
{4,16,16,16,16}, //索引:[20]
{4,32,16,16,16}, //索引:[21]
{4,48,16,16,16}, //索引:[22]
{4,32,0,16,16,4}, //索引:[23] 水平鏡象
{4,16,0,16,16,4}, //索引:[24] 水平鏡象
{4,16,16,16,16,4}, //索引:[25] 水平鏡象
{4,48,0,16,16,4}, //索引:[26] 水平鏡象
{4,64,0,16,16}, //索引:[27]
{4,64,16,16,16}, //索引:[28]
{4,80,16,16,16}, //索引:[29]
{4,0,16,16,16,1}, //索引:[30] R90度
{4,16,0,16,16,2}, //索引:[31] R180度
{4,32,0,16,16,2}, //索引:[32] R180度
{4,32,0,16,16,1}, //索引:[33] R90度
{4,32,16,16,16,5}, //索引:[34] 垂直鏡象
{4,32,16,16,16,3}, //索引:[35] R270度
{4,64,16,16,16,3}, //索引:[36] R270度
{4,16,0,16,16,3}, //索引:[37] R270度
{4,16,16,16,16,3}, //索引:[38] R270度
{6,64,0,16,16}, //索引:[39]
{6,64,0,16,16,1}, //索引:[40] R90度
{6,64,0,16,16,2}, //索引:[41] R180度
{6,64,0,16,16,3}, //索引:[42] R270度
{1,0,0,33,21}, //索引:[43]
{2,0,0,39,34}, //索引:[44]
{3,2,44,21,11}, //索引:[45]
{3,0,0,43,44}, //索引:[46]
{3,43,8,9,18,4}, //索引:[47] 水平鏡象
{3,43,8,9,18}, //索引:[48]
{3,23,44,12,11}, //索引:[49]
{3,43,26,18,29}, //索引:[50]
{0,0,0,24,26}, //索引:[51]
{5,0,0,29,13}, //索引:[52]
{5,0,13,11,14}, //索引:[53]
{5,21,13,4,11}, //索引:[54]
{5,11,13,10,15,4}, //索引:[55] 水平鏡象
{5,11,13,10,15} //索引:[56]
};
short objItem0[][][]={//建築元素:{幀表->子圖表}
//{{134746130}}新對象:Speed,
{/*普通*/{43,8,1,44,11,-9}},
//{{134746130}}新對象:Speed,
{/*普通*/{45,-1,2,46,-2,-25}},
//{{134746130}}新對象:Speed,
{/*普通*/{47,4,-1,48,-4,-1}},
//{{134746130}}新對象:Speed,
{/*普通*/{49,-1,-8,49,-13,-4,49,14,7,49,-5,-1,49,-4,8,49,4,5,49,-10,0,50,1,-8}},
//{{134746130}}新對象:Speed,
{/*普通*/{43,7,1,51,4,-5}},
//{{134746130}}新對象:Speed,
{/*普通*/{43,18,90,43,18,59,43,18,38,43,18,17,43,18,80,52,15,36,52,15,10,52,15,75,52,15,23,52,15,88,52,15,62,53,3,1,54,26,67,54,26,80,54,5,67,54,5,80,53,3,92,55,28,91,52,15,49,54,5,15,54,5,28,54,5,54,54,26,54,54,5,41,54,26,15,54,26,28,54,26,41,56,26,0}}
};
Image[] drawImg = new Image[7];
public Draw() {
try {
drawImg[0] = Image.createImage("/0_map_0_lupai.png"); //��ʹ��1��
drawImg[1] = Image.createImage("/0_city_0_yz.png"); //��ʹ��1��
drawImg[2] = Image.createImage("/0_map_0_shi2.png"); //��ʹ��1��
drawImg[3] = Image.createImage("/0_map_0_tree3.png"); //��ʹ��6��
drawImg[4] = Image.createImage("/0_map_0_heliu.png"); //��ʹ��25��
drawImg[5] = Image.createImage("/0_city_0_qiao.png"); //��ʹ��5��
drawImg[6] = Image.createImage("/0_map_0_cao3.png"); //��ʹ��18��
}
catch (IOException ex) {
System.out.println("+++");
}
}
/**
* paintObject
*
* @param g Graphics
*/
public static final int Screen_Width = 240;
public static final int Screen_Height = 320;
public void paintObject(Graphics g, int currentX, int currentY) {
int move_x ,move_y;
for (int i = currentY; i < currentY+Screen_Height/16 +1; i++) {
for (int j = currentX; j <currentX+ Screen_Width/16 +1; j++) {
int mapindex = (nMapData0[i][j] >> 8) & 0xff;
if (mapindex == 0) {
continue;
}
mapindex -= 1;
short objectData[] = objItem0[mapindex][0];
int num = objectData.length /3;
for(int k = 0 ; k< num ; k++){
int tran = 0 ;
int objIndex = objectData[k*3];
move_x = objectData[k*3 +1];
move_y = objectData[k*3 +2];
int pic_index = nDrawPos[objIndex][0];
int x_pos = nDrawPos[objIndex][1];
int y_pos = nDrawPos[objIndex][2];
int pic_width = nDrawPos[objIndex][3];
int pic_height = nDrawPos[objIndex][4];
if (nDrawPos[objIndex].length == 6) {
tran = nDrawPos[objIndex][5];
}
tran = tanrs [tran];
g.drawRegion(drawImg[pic_index], x_pos, y_pos, pic_width, pic_height, tran, (j -currentX)* 16+move_x+8, move_y+(i-currentY) * 16+8, g.HCENTER | g.VCENTER);
}
}
}
}
/**
* paintMap
*
* @param g Graphics
*/
public void paintMap(Graphics g,int currentX,int currentY) {
for (int i = currentY; i < currentY+Screen_Height/16 +1; i++) {
for (int j = currentX; j < currentX+Screen_Width/16+1; j++) {
int mapindex = nMapData0[i][j] & 0xff;
if(mapindex == 0 ){
continue;
}
int tran= 0 ;
mapindex = (mapindex-1)*2 ;
int x = mapItem0[mapindex];
int pic_index = nDrawPos[x][0];
int x_pos = nDrawPos[x][1];
int y_pos = nDrawPos[x][2];
int pic_width = nDrawPos[x][3];
int pic_height = nDrawPos[x][4];
if(nDrawPos[x].length == 6){
tran =nDrawPos[x][5];
}
tran = tanrs [tran];
g.drawRegion(drawImg[pic_index], x_pos, y_pos, pic_width, pic_height,
tran, (j-currentX )* 16, (i -currentY)* 16, 0);
}
}
}
}