for(int across = player.PlayerX-5; across < player.PlayerX+5; across++)
{
for(int vert = player.PlayerY-5; vert < player.PlayerX+5; vert++)
{
//double RANDOM = Math.random();
if(across < 0 || vert < 0)
{
}
else if(levONE.A[vert][across] == 1)
{
g.drawImage(Floor,across*32,vert*32,this);
else if(levONE.A[vert][across] == 0)
g.drawImage(Wall,across*32,vert*32,this);
}
}
答案 0 :(得分:1)
看起来你有一张自上而下的2d游戏,带有瓷砖地图。你试图在玩家中间渲染一个9x9的方块吗?
在'else if(levONE.A [vert] [across] == 1)之后你有一些括号奇怪但是我认为它不会在当前状态下编译?
除了代码看起来不错外,我可能首先添加print语句以确保您获得的数据符合您的预期。有点像...
for(int across = player.PlayerX-5; across < player.PlayerX+5; across++)
{
for(int vert = player.PlayerY-5; vert < player.PlayerX+5; vert++)
{
//double RANDOM = Math.random();
if(across < 0 || vert < 0) //might want to check the 'high' bounds here too
{
}
else if(levONE.A[vert][across] == 1)
{
g.drawImage(Floor,across*32,vert*32,this);
}
else if(levONE.A[vert][across] == 0)
{
g.drawImage(Wall,across*32,vert*32,this);
}
//print ("%d ", levONE.A[vert][across]);
}
//print ("\n");
}
应该为你提供一个很好的网格
0 0 0 0 0 0 0 0
1 1 0 0 1 1 1 1
etc..