~arcade/nebula

161dfab31bb0e7cf179fc53ce774988e9d640654 — Arcade Wise 5 months ago 3889c53
oneko.js
M docs/AI.html => docs/AI.html +3 -1
@@ 34,6 34,8 @@
  <meta property="twitter:title" content="Arcade Wise - nebula - ai disclousure" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 69,7 71,7 @@ The content of this page can be considered can be considered to be neither being
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

   

M docs/goblins.html => docs/goblins.html +3 -1
@@ 36,6 36,8 @@
  <meta property="twitter:title" content="Arcade Wise - Spritely&#39;s Goblins and How They&#39;re Gonna Steal the Future" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 280,7 282,7 @@ that all have to work together.</p>
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

   

M docs/hedonism.html => docs/hedonism.html +3 -1
@@ 34,6 34,8 @@
  <meta property="twitter:title" content="Arcade Wise - hedonism" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 81,7 83,7 @@ over the long term it won't help. Same for STDs.</p>
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

   

M docs/index.html => docs/index.html +3 -1
@@ 34,6 34,8 @@
  <meta property="twitter:title" content="Arcade Wise - aethopica - a home on the net" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 121,7 123,7 @@ fish shell.</li>
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

  

M docs/rndm/dithering.html => docs/rndm/dithering.html +3 -1
@@ 34,6 34,8 @@
  <meta property="twitter:title" content="Arcade Wise - Dithering - rndm" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 62,7 64,7 @@
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

   

M docs/rndm/stickers.html => docs/rndm/stickers.html +3 -1
@@ 34,6 34,8 @@
  <meta property="twitter:title" content="Arcade Wise - Stickers - Random Thoughts" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 73,7 75,7 @@ so the stickers are less for you (even though they look amazing), and more for t
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

   

A docs/static/oneko.gif => docs/static/oneko.gif +0 -0
A docs/static/oneko.js => docs/static/oneko.js +206 -0
@@ 0,0 1,206 @@
// oneko.js: https://github.com/adryd325/oneko.js

function oneko() {
  const nekoEl = document.createElement("div");
  let nekoPosX = 32;
  let nekoPosY = 32;
  let mousePosX = 0;
  let mousePosY = 0;
  let frameCount = 0;
  let idleTime = 0;
  let idleAnimation = null;
  let idleAnimationFrame = 0;
  const nekoSpeed = 10;
  const spriteSets = {
    idle: [[-3, -3]],
    alert: [[-7, -3]],
    scratchSelf: [
      [-5, 0],
      [-6, 0],
      [-7, 0],
    ],
    scratchWallN: [
      [0, 0],
      [0, -1],
    ],
    scratchWallS: [
      [-7, -1],
      [-6, -2],
    ],
    scratchWallE: [
      [-2, -2],
      [-2, -3],
    ],
    scratchWallW: [
      [-4, 0],
      [-4, -1],
    ],
    tired: [[-3, -2]],
    sleeping: [
      [-2, 0],
      [-2, -1],
    ],
    N: [
      [-1, -2],
      [-1, -3],
    ],
    NE: [
      [0, -2],
      [0, -3],
    ],
    E: [
      [-3, 0],
      [-3, -1],
    ],
    SE: [
      [-5, -1],
      [-5, -2],
    ],
    S: [
      [-6, -3],
      [-7, -2],
    ],
    SW: [
      [-5, -3],
      [-6, -1],
    ],
    W: [
      [-4, -2],
      [-4, -3],
    ],
    NW: [
      [-1, 0],
      [-1, -1],
    ],
  };

  function create() {
    nekoEl.id = "oneko";
    nekoEl.style.width = "32px";
    nekoEl.style.height = "32px";
    nekoEl.style.position = "fixed";
    nekoEl.style.pointerEvents = "none";
    nekoEl.style.backgroundImage = "url('./static/oneko.gif')";
    nekoEl.style.imageRendering = "pixelated";
    nekoEl.style.left = `${nekoPosX - 16}px`;
    nekoEl.style.top = `${nekoPosY - 16}px`;
    nekoEl.style.zIndex = "999";

    document.body.appendChild(nekoEl);

    document.onmousemove = (event) => {
      mousePosX = event.clientX;
      mousePosY = event.clientY;
    };

    window.onekoInterval = setInterval(frame, 100);
  }

  function setSprite(name, frame) {
    const sprite = spriteSets[name][frame % spriteSets[name].length];
    nekoEl.style.backgroundPosition = `${sprite[0] * 32}px ${sprite[1] * 32}px`;
  }

  function resetIdleAnimation() {
    idleAnimation = null;
    idleAnimationFrame = 0;
  }

  function idle() {
    idleTime += 1;

    // every ~ 20 seconds
    if (
      idleTime > 10 &&
      Math.floor(Math.random() * 200) == 0 &&
      idleAnimation == null
    ) {
      let avalibleIdleAnimations = ["sleeping", "scratchSelf"];
      if (nekoPosX < 32) {
        avalibleIdleAnimations.push("scratchWallW");
      }
      if (nekoPosY < 32) {
        avalibleIdleAnimations.push("scratchWallN");
      }
      if (nekoPosX > window.innerWidth - 32) {
        avalibleIdleAnimations.push("scratchWallE");
      }
      if (nekoPosY > window.innerHeight - 32) {
        avalibleIdleAnimations.push("scratchWallS");
      }
      idleAnimation =
        avalibleIdleAnimations[
          Math.floor(Math.random() * avalibleIdleAnimations.length)
        ];
    }

    switch (idleAnimation) {
      case "sleeping":
        if (idleAnimationFrame < 8) {
          setSprite("tired", 0);
          break;
        }
        setSprite("sleeping", Math.floor(idleAnimationFrame / 4));
        if (idleAnimationFrame > 192) {
          resetIdleAnimation();
        }
        break;
      case "scratchWallN":
      case "scratchWallS":
      case "scratchWallE":
      case "scratchWallW":
      case "scratchSelf":
        setSprite(idleAnimation, idleAnimationFrame);
        if (idleAnimationFrame > 9) {
          resetIdleAnimation();
        }
        break;
      default:
        setSprite("idle", 0);
        return;
    }
    idleAnimationFrame += 1;
  }

  function frame() {
    frameCount += 1;
    const diffX = nekoPosX - mousePosX;
    const diffY = nekoPosY - mousePosY;
    const distance = Math.sqrt(diffX ** 2 + diffY ** 2);

    if (distance < nekoSpeed || distance < 48) {
      idle();
      return;
    }

    idleAnimation = null;
    idleAnimationFrame = 0;

    if (idleTime > 1) {
      setSprite("alert", 0);
      // count down after being alerted before moving
      idleTime = Math.min(idleTime, 7);
      idleTime -= 1;
      return;
    }

    direction = diffY / distance > 0.5 ? "N" : "";
    direction += diffY / distance < -0.5 ? "S" : "";
    direction += diffX / distance > 0.5 ? "W" : "";
    direction += diffX / distance < -0.5 ? "E" : "";
    setSprite(direction, frameCount);

    nekoPosX -= (diffX / distance) * nekoSpeed;
    nekoPosY -= (diffY / distance) * nekoSpeed;

    nekoPosX = Math.min(Math.max(16, nekoPosX), window.innerWidth - 16);
    nekoPosY = Math.min(Math.max(16, nekoPosY), window.innerHeight - 16);

    nekoEl.style.left = `${nekoPosX - 16}px`;
    nekoEl.style.top = `${nekoPosY - 16}px`;
  }

  create();
}

setTimeout(oneko, 20);
\ No newline at end of file

M docs/web3.html => docs/web3.html +3 -1
@@ 34,6 34,8 @@
  <meta property="twitter:title" content="Arcade Wise - My (not so first) first thoughts on web3" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 162,7 164,7 @@ games.</p>
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

   

M docs/zombieProgrammers.html => docs/zombieProgrammers.html +3 -1
@@ 34,6 34,8 @@
  <meta property="twitter:title" content="Arcade Wise - Zombie Programmers and Mr. Barthes" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 114,7 116,7 @@ I have also attached some basic resources for further reading on this. Thanks fo
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

   

A site/content/static/nomod/oneko.gif => site/content/static/nomod/oneko.gif +0 -0
M site/theme/index.html => site/theme/index.html +3 -1
@@ 38,6 38,8 @@
  <meta property="twitter:title" content="Arcade Wise - {{ title }}" />
  <meta property="twitter:description" content="Arcade's digital home" />
  <meta property="twitter:image" content="/static/meta.png" />

  <script src="/static/oneko.js" > </script>
</head>

<body>


@@ 67,7 69,7 @@
    <img src="/static/linux-p.gif" alt="powered by linux" />
    <a href="https://tacohitbox.com"><img src="/static/aria.jpg" alt="catgirl" /></a>

    <a href="https://clownillustration.com/welcomehomeyou"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
    <a href="https://clownillustration.com/from-me-to-you"><img src="https://static.wixstatic.com/media/69154f_790b625a2f79481d9fb668af9e0ca711~mv2.gif" width="88px" height="31px" /></a>
  </div>

  {% if builtin.path == 'index.md' %}

A site/theme/static/oneko.js => site/theme/static/oneko.js +206 -0
@@ 0,0 1,206 @@
// oneko.js: https://github.com/adryd325/oneko.js

function oneko() {
  const nekoEl = document.createElement("div");
  let nekoPosX = 32;
  let nekoPosY = 32;
  let mousePosX = 0;
  let mousePosY = 0;
  let frameCount = 0;
  let idleTime = 0;
  let idleAnimation = null;
  let idleAnimationFrame = 0;
  const nekoSpeed = 10;
  const spriteSets = {
    idle: [[-3, -3]],
    alert: [[-7, -3]],
    scratchSelf: [
      [-5, 0],
      [-6, 0],
      [-7, 0],
    ],
    scratchWallN: [
      [0, 0],
      [0, -1],
    ],
    scratchWallS: [
      [-7, -1],
      [-6, -2],
    ],
    scratchWallE: [
      [-2, -2],
      [-2, -3],
    ],
    scratchWallW: [
      [-4, 0],
      [-4, -1],
    ],
    tired: [[-3, -2]],
    sleeping: [
      [-2, 0],
      [-2, -1],
    ],
    N: [
      [-1, -2],
      [-1, -3],
    ],
    NE: [
      [0, -2],
      [0, -3],
    ],
    E: [
      [-3, 0],
      [-3, -1],
    ],
    SE: [
      [-5, -1],
      [-5, -2],
    ],
    S: [
      [-6, -3],
      [-7, -2],
    ],
    SW: [
      [-5, -3],
      [-6, -1],
    ],
    W: [
      [-4, -2],
      [-4, -3],
    ],
    NW: [
      [-1, 0],
      [-1, -1],
    ],
  };

  function create() {
    nekoEl.id = "oneko";
    nekoEl.style.width = "32px";
    nekoEl.style.height = "32px";
    nekoEl.style.position = "fixed";
    nekoEl.style.pointerEvents = "none";
    nekoEl.style.backgroundImage = "url('./static/oneko.gif')";
    nekoEl.style.imageRendering = "pixelated";
    nekoEl.style.left = `${nekoPosX - 16}px`;
    nekoEl.style.top = `${nekoPosY - 16}px`;
    nekoEl.style.zIndex = "999";

    document.body.appendChild(nekoEl);

    document.onmousemove = (event) => {
      mousePosX = event.clientX;
      mousePosY = event.clientY;
    };

    window.onekoInterval = setInterval(frame, 100);
  }

  function setSprite(name, frame) {
    const sprite = spriteSets[name][frame % spriteSets[name].length];
    nekoEl.style.backgroundPosition = `${sprite[0] * 32}px ${sprite[1] * 32}px`;
  }

  function resetIdleAnimation() {
    idleAnimation = null;
    idleAnimationFrame = 0;
  }

  function idle() {
    idleTime += 1;

    // every ~ 20 seconds
    if (
      idleTime > 10 &&
      Math.floor(Math.random() * 200) == 0 &&
      idleAnimation == null
    ) {
      let avalibleIdleAnimations = ["sleeping", "scratchSelf"];
      if (nekoPosX < 32) {
        avalibleIdleAnimations.push("scratchWallW");
      }
      if (nekoPosY < 32) {
        avalibleIdleAnimations.push("scratchWallN");
      }
      if (nekoPosX > window.innerWidth - 32) {
        avalibleIdleAnimations.push("scratchWallE");
      }
      if (nekoPosY > window.innerHeight - 32) {
        avalibleIdleAnimations.push("scratchWallS");
      }
      idleAnimation =
        avalibleIdleAnimations[
          Math.floor(Math.random() * avalibleIdleAnimations.length)
        ];
    }

    switch (idleAnimation) {
      case "sleeping":
        if (idleAnimationFrame < 8) {
          setSprite("tired", 0);
          break;
        }
        setSprite("sleeping", Math.floor(idleAnimationFrame / 4));
        if (idleAnimationFrame > 192) {
          resetIdleAnimation();
        }
        break;
      case "scratchWallN":
      case "scratchWallS":
      case "scratchWallE":
      case "scratchWallW":
      case "scratchSelf":
        setSprite(idleAnimation, idleAnimationFrame);
        if (idleAnimationFrame > 9) {
          resetIdleAnimation();
        }
        break;
      default:
        setSprite("idle", 0);
        return;
    }
    idleAnimationFrame += 1;
  }

  function frame() {
    frameCount += 1;
    const diffX = nekoPosX - mousePosX;
    const diffY = nekoPosY - mousePosY;
    const distance = Math.sqrt(diffX ** 2 + diffY ** 2);

    if (distance < nekoSpeed || distance < 48) {
      idle();
      return;
    }

    idleAnimation = null;
    idleAnimationFrame = 0;

    if (idleTime > 1) {
      setSprite("alert", 0);
      // count down after being alerted before moving
      idleTime = Math.min(idleTime, 7);
      idleTime -= 1;
      return;
    }

    direction = diffY / distance > 0.5 ? "N" : "";
    direction += diffY / distance < -0.5 ? "S" : "";
    direction += diffX / distance > 0.5 ? "W" : "";
    direction += diffX / distance < -0.5 ? "E" : "";
    setSprite(direction, frameCount);

    nekoPosX -= (diffX / distance) * nekoSpeed;
    nekoPosY -= (diffY / distance) * nekoSpeed;

    nekoPosX = Math.min(Math.max(16, nekoPosX), window.innerWidth - 16);
    nekoPosY = Math.min(Math.max(16, nekoPosY), window.innerHeight - 16);

    nekoEl.style.left = `${nekoPosX - 16}px`;
    nekoEl.style.top = `${nekoPosY - 16}px`;
  }

  create();
}

setTimeout(oneko, 20);
\ No newline at end of file