モーメントで私はマップを使って小さなゲームをします。 すべて動作しますが、何かが不明です。ゲームマップボーダー計算
あなたは私が持っていると、再び何をしたいことをここに見ることができます。 https://picul.de/view/HsY
瞬間に私のコードは次のようになります。
function calcTile ($x, $y, $tilemin, $tilemax,$atilemin, $atilemax){
//ActualTile
$m = calcNoise($x, $y);
//Above Tiles
$tl = calcNoise($x-1, $y-1);
$t = calcNoise($x, $y-1);
$tr = calcNoise($x+1, $y-1);
//Right Tile
$r = calcNoise($x+1, $y);
//Below Tiles
$br = calcNoise($x+1, $y+1);
$b = calcNoise($x, $y+1);
$bl = calcNoise($x-1, $y+1);
//Left Tiles
$l = calcNoise($x-1, $y);
if(
$t >= $tilemin && $t <= $tilemax &&
$r >= $tilemin && $r <= $tilemax &&
$b >= $tilemin && $b <= $tilemax &&
$l >= $tilemin && $l <= $tilemax
){
$field = 50;
} else
//Vertical
if(
$t >= $atilemin && $t <= $atilemax &&
$r >= $tilemin && $r <= $tilemax &&
$b >= $atilemin && $b <= $atilemax &&
$l >= $tilemin && $l <= $tilemax
){
$field = 45;
} else
//Horizontal
if(
$t >= $tilemin && $t <= $tilemax &&
$r >= $atilemin && $r <= $atilemax &&
$b >= $tilemin && $b <= $tilemax &&
$l >= $atilemin && $l <= $atilemax
){
$field = 46;
} else {
...
}
}
だから私の新しいアイデアは、このようなパターンで表示することです:
$array = array(
2 => array(
'0', '1', '1',
'0', '1', '1',
'0', '0', '0'
),
3 => array('1', '1', '0',
'1', '1', '0',
'0', '0', '0'
),
4 => array('0', '0', '0',
'1', '1', '0',
'1', '1', '0'
)
);
$key = array_search(array('0', '1', '1',
'0', '1', '1',
'0', '0', '0'), $array); // $key = 2;
echo $key."<br><br>";
これは作業になります。
しかし、私の問題は、同じタイルの2つの以上のパターンがあることが可能であろう、..です
私の考えでは、アレイにも
array(
2 => array(array(
'0', '1', '1',
'0', '1', '1',
'0', '0', '0'
), array(
'0', '1', '1',
'0', '1', '1',
'0', '0', '1'
)
)
配列だったが、問題は、今ありますarray_searchに配列番号が必要なものが見つかりません:
$ key = array_search(array( '0'、 '1'、 '1'、 '0'、 '1'、 '1' 、 '0'、 '0'、 '0')、$ array [2]);
この問題はどのように解決できますか?どのように私は彼らにこの番号を知らせることができますか?
これは、数値は、現時点では、次のとおりです。 https://picul.de/view/Hs-
1-50他の一つであり、テストの
それとも別の質問: は/コーナーなど国境を「計算」するためのより良い方法はありますか?
挨拶 ダニエル