Skip to content

Instantly share code, notes, and snippets.

@TheCuttlefish
TheCuttlefish / .js
Last active June 20, 2025 05:58
Hue Hint (Browser Injection)
javascript:(()=>{if(document.getElementById('kw-highlighter-box'))return;const e=document.createElement("div");e.id="kw-highlighter-box",e.style="position:fixed;top:20px;right:20px;z-index:9999;background:#fff;border:1px solid #ccc;padding:10px;border-radius:8px;box-shadow:0 2px 6px rgba(0,0,0,0.2);font-family:sans-serif;width:600px;opacity:0;transform:scale(0.98);transition:opacity 0.3s ease,transform 0.3s ease;",e.innerHTML='<div style="display:flex;justify-content:space-between;align-items:center;"><h4 style="margin:0">🔍 Hue Hint</h4><button id="kw-close" title="Close" style="border:none;background:none;font-size:18px;cursor:pointer;">×</button></div><div id="kw-fields" style="margin-top:10px;"></div><div style="display:flex;justify-content:space-between;align-items:center;margin-top:10px;"><div style="display:flex;gap:6px;"><button id="kw-add" title="Add a new field" style="font-size:16px;padding:4px 8px;width:36px;height:36px;color:#28a745;">+</button><button id="kw-remove" title="Remove last field" styl
@TheCuttlefish
TheCuttlefish / showLightSensorValues.js
Created April 1, 2025 21:56
Show light sensor values 0-255 (makey makey + BBC:micro)
basic.forever(function () {
let light = input.lightLevel()
let fillAmount = Math.map(light, 0, 255, 0, 25)
fillAmount = Math.constrain(fillAmount, 0, 25)
basic.clearScreen()
for (let i = 0; i < fillAmount; i++) {
let x = i % 5
let y = Math.floor(i / 5)
@TheCuttlefish
TheCuttlefish / TiltDection.js
Created April 1, 2025 21:36
tilt to keys makey makey + BBC micro (slow)
basic.forever(function () {
let roll = input.rotation(Rotation.Roll) // Left/right tilt
if (roll < -20) {
makeyMakey.typeKey(makeyMakey.KeyPress.A)
basic.showArrow(ArrowNames.West)
} else if (roll > 20) {
makeyMakey.typeKey(makeyMakey.KeyPress.D)
basic.showArrow(ArrowNames.East)
@TheCuttlefish
TheCuttlefish / clapDetection.js
Created April 1, 2025 21:15
clap to press "w" on makey makey + BBC micro
makeyMakey.sx1509Init()
input.onSound(DetectedSound.Loud, function () {
makeyMakey.typeKey(makeyMakey.KeyPress.W)
basic.showIcon(IconNames.Happy)
basic.pause(10)
basic.clearScreen()
})
@TheCuttlefish
TheCuttlefish / Chunk.cs
Created January 30, 2025 02:52
Seeds for tile world
private Transform activeMap;
void SwapMap()
{
if (activeMap) activeMap.gameObject.SetActive(false);
int chunkHash = Mathf.Abs((int)transform.position.x * 73856093 ^ (int)transform.position.y * 19349663);
activeMap = maps[seed.Next(chunkHash, maps.Count)]; // Directly store GameObject
activeMap.gameObject.SetActive(true);
@TheCuttlefish
TheCuttlefish / VirtualPlane.cs
Last active January 30, 2025 01:20
Swap tiles ahead of the player in parallax style
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VirtualPlane : MonoBehaviour
{
GameObject player;
int planeSize = 200;
int planeHalf = 100;
@TheCuttlefish
TheCuttlefish / CamFeed.cs
Created July 4, 2024 18:06
Camera feed to texture
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CamFeed : MonoBehaviour
{
private WebCamTexture webCamTexture;
@TheCuttlefish
TheCuttlefish / Spawner.cs
Last active June 16, 2024 09:49
The Sierpinski triangle ( in C# + camera depth only version)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public List<Transform> points = new List<Transform>(); // add 3 points in the world
public GameObject point;// -- can be used for spawning
@TheCuttlefish
TheCuttlefish / SpawnObject.cs
Created May 9, 2024 10:47
spawn things (once!)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnObject : MonoBehaviour
{
public List<Transform> possiblePositions = new List<Transform>();
public List<GameObject> allThings = new List<GameObject>();
@TheCuttlefish
TheCuttlefish / Ripple.cs
Created October 31, 2023 12:45
Ripple effect in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ripple : MonoBehaviour
{
//preset