Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java机会(离某物越远,机会越小)_Java_Libgdx_Tiles - Fatal编程技术网

Java机会(离某物越远,机会越小)

Java机会(离某物越远,机会越小),java,libgdx,tiles,Java,Libgdx,Tiles,我正在为我的游戏创建一个岛屿,我有一张地图,地图的中点是陆地,其他的都是水。 如果接近中心100%的概率,并且距离中心越远,如何制作瓷砖落地的概率计算器 到目前为止,我只能为地图的一面做些什么: float centerx=r.mapsize/2*r.tilesize, centery=centerx; if(position.x<centerx&&position.y<centery){ float distancex = centerx-p

我正在为我的游戏创建一个岛屿,我有一张地图,地图的中点是陆地,其他的都是水。 如果接近中心100%的概率,并且距离中心越远,如何制作瓷砖落地的概率计算器

到目前为止,我只能为地图的一面做些什么:

float centerx=r.mapsize/2*r.tilesize, centery=centerx;
    if(position.x<centerx&&position.y<centery){
        float distancex = centerx-position.x, distancey = centerx-position.y;
        boolean chancex = rr.nextInt((int)distancex)/5==0; boolean chancey=rr.nextInt((int)distancey)/5==0;
        if(chancex&&chancey){sprite=AssetLoader.grass;}
    }

但它看起来不像是一个小岛。它就像瓷砖从中心爆炸一样。

要使您的方法适用于所有象限,您可能应该确保distanceX和distanceY永远不会为负,例如Math.abscenterx-positionX

若要获得更平滑、更逼真的地形,应选择其他算法,请参阅以获取常见选择


顺便说一句,与游戏设计相关的问题可能会比at更受欢迎,尽管他们通常也希望您进行更多的研究。

您地图的不同部分似乎存在问题,因为如果检查,但即使如此,该岛仍将由许多小块土地组成。使用距离x=Math.abscenterx-position.x;,与y相同,如果位置X