"you are here" in favicon (idea from Yves)
This commit is contained in:
parent
938160f053
commit
738e92c16b
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
After Width: 16px | Height: 16px | Size: 762 B |
38
favicon.php
38
favicon.php
@ -2,43 +2,15 @@
|
||||
header('Content-Type: image/x-icon');
|
||||
|
||||
const SIZE = 16;
|
||||
const WALL = 1;
|
||||
const GROUND = 0;
|
||||
|
||||
$favicon = imagecreatetruecolor(SIZE, SIZE);
|
||||
$wallColor = imagecolorallocate($favicon, 165, 80, 30);
|
||||
$groundColor = imagecolorallocate($favicon, 203, 162, 133);
|
||||
$x = filter_input(INPUT_GET, "x", FILTER_SANITIZE_NUMBER_INT);
|
||||
$y = filter_input(INPUT_GET, "y", FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
imagefill($favicon, 0, 0, $wallColor);
|
||||
$favicon = imagecreatefrombmp("favicon.ico");
|
||||
|
||||
$maze = array();
|
||||
for ($y = 0; $y < SIZE; $y++) {
|
||||
$maze[$y] = array();
|
||||
for ($x = 0; $x < SIZE; $x++) {
|
||||
$maze[$y][$x] = WALL;
|
||||
}
|
||||
}
|
||||
$red = imagecolorallocate($favicon, 255, 0, 0);
|
||||
imagesetpixel($favicon, $x, $y, $red);
|
||||
|
||||
function dig($position) {
|
||||
global $maze;
|
||||
global $favicon;
|
||||
global $groundColor;
|
||||
$directions = [[0, 1], [0, -1], [1, 0], [-1, 0]];
|
||||
shuffle($directions);
|
||||
foreach ($directions as $direction) {
|
||||
$step1 = [$position[0] + $direction[0], $position[1] + $direction[1]];
|
||||
$step2 = [$step1[0] + $direction[0], $step1[1] + $direction[1]];
|
||||
if (0 <= $step2[1] and $step2[1] < SIZE and 0 <= $step2[0] and $step2[0] < SIZE and $maze[$step2[1]][$step2[0]] == WALL) {
|
||||
$maze[$step1[1]][$step1[0]] = GROUND;
|
||||
imagesetpixel($favicon, $step1[0], $step1[1], $groundColor);
|
||||
$maze[$step2[1]][$step2[0]] = GROUND;
|
||||
imagesetpixel($favicon, $step2[0], $step2[1], $groundColor);
|
||||
dig($step2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dig([1, 1]);
|
||||
imagebmp($favicon);
|
||||
imagedestroy($favicon);
|
||||
?>
|
@ -4,7 +4,7 @@
|
||||
<title>Daedalus</title>
|
||||
<meta charset=utf-8 />
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.php"/>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" id="favicon"/>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<!-- Import maps polyfill -->
|
||||
<!-- Remove this when import maps will be widely supported -->
|
||||
@ -12,8 +12,8 @@
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"three": "https://unpkg.com/three@0.155/build/three.module.js?module",
|
||||
"three/addons/": "https://unpkg.com/three@0.155/examples/jsm/"
|
||||
"three": "https://unpkg.com/three@0.157/build/three.module.js?module",
|
||||
"three/addons/": "https://unpkg.com/three@0.157/examples/jsm/"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
6
main.js
6
main.js
@ -122,6 +122,12 @@ if (!dev) {
|
||||
mazeCollisionner.add(clone);
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
let x = Math.floor(8 + camera.position.x * 16 / mazeWidth)
|
||||
let y = Math.floor(8 + camera.position.z * 16 / mazeWidth)
|
||||
favicon.href = `favicon.php?x=${x}&y=${y}`
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
|
||||
// Ground
|
||||
|
Loading…
x
Reference in New Issue
Block a user