Skip to content

Instantly share code, notes, and snippets.

@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
@TheCuttlefish
TheCuttlefish / Fade.cs
Created April 25, 2023 14:50
Screen Fade
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Fade : MonoBehaviour
{
CanvasGroup group;
float timer;
float fadeOutTimer;