如鹏java学习进程 使用数组进行图片布局

来源:互联网 发布:网络平台服务合同 编辑:程序博客网 时间:2024/06/05 09:12
import com.rupeng.game.GameCore;


public class Main4 implements Runnable {


@Override
public void run() {


int[][] mapDate = { { 0, 0, 1, 2 }, { 0, 0, 0, 0 }, { 1, 2, 0, 1 }, { 1, 0, 0, 2 } };


int imgNum = 0;
for (int a = 0; a < mapDate.length; a++) {
int[] mapDateRow = mapDate[a];
for (int b = 0; b < mapDateRow.length; b++) {
int date = mapDateRow[b];


if (date == 1) {
GameCore.createImage(imgNum, "c_1.png");
GameCore.setImagePosition(imgNum, b * 80, a * 80);
imgNum++;
} else if (date == 2) {
GameCore.createImage(imgNum, "c_2.png");
GameCore.setImagePosition(imgNum, b * 80, a * 80);
imgNum++;
}


}

}
while(true)
{
GameCore.pause(10);
}


}


public static void main(String[] args) {
GameCore.start(new Main4());


}


}
原创粉丝点击