个人对45度地图结构的思考(含代码演示) |
| 作者:不详 来源:J2ME.com.cn 发布时间:2005-11-24 17:13:56 |
|
currentDir = 3; } tally++; break; } KEY_LAST = KEY_CURRENT; if(IS_UP) { KEY_LAST = 0; KEY_CURRENT = 0; } } private void drawMap() { gb.setColor(0x00ffffff); gb.fillRect(0, 0, nWidth, nHeight); for(int i = 0; i < mapHeight; i++) { for(int j = 0; j < mapWidth; j++) { for(int k = 0; k <= mapDepth[j]; k++) { gb.drawImage(mapImg, nWidth / 2 + j * cellSizeWidth / 2 - i * cellSizeWidth / 2 - (targetMX * cellSizeWidth / 2 - targetMY * cellSizeWidth / 2), -k * 16 + nHeight / 2 + j * cellSizeHeight / 2 + i * cellSizeHeight / 2 - (targetMX * cellSizeHeight / 2 + targetMY * cellSizeHeight / 2), 3); } } } } //人物固定在屏幕中间(nwidht/2,nHeight / 2的地方 private void drawPerson() { //人物绘制部分,只考虑高度问题。在屏幕上的坐标固定为nWidth/2,nHeight/2. gb.drawImage(menImg[currentDir][(tally / 2)%2], nWidth / 2, nHeight / 2 - mapDepth[targetMY][targetMX] * 16, 33); ///// for(int j = targetMX + 1; j < mapWidth; j++) { for(int k = 1; k <= mapDepth[targetMY][j]; k++) { gb.drawImage(mapImg, nWidth / 2 + j * cellSizeWidth / 2 - targetMY * cellSizeWidth / 2 - (targetMX * cellSizeWidth / 2 - targetMY * cellSizeWidth / 2), -k * 16 + nHeight / 2 + j * cellSizeHeight / 2 + targetMY * cellSizeHeight / 2 - (targetMX * cellSizeHeight / 2 + targetMY * cellSizeHeight / 2), 3); } } for(int i = targetMY + 1; i < mapHeight; i++) { for(int j = 0; j < mapWidth; j++) { if(j >= mapHeight) { continue; } for(int k = 1; k <= mapDepth[j]; k++) { gb.drawImage(mapImg, nWidth / 2 + j * cellSizeWidth / 2 - i * cellSizeWidth / 2 - (targetMX * cellSizeWidth / 2 - targetMY * cellSizeWidth / 2), -k * 16 + nHeight / 2 + j * cellSizeHeight / 2 + i * cellSizeHeight / 2 - (targetMX * cellSizeHeight / 2 + targetMY * cellSizeHeight / 2), 3); } } } } private void drawBalk() { } } 相关下载:点击下载 |
| [] [返回上一页] [打 印] |
文章评论 |
