Skip to content

Instantly share code, notes, and snippets.

// yocto-queue からの引用
// https://github.com/sindresorhus/yocto-queue
/*
How it works:
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
*/
class Node {
value;
next;
@naosim
naosim / nocodestate.mjs
Created June 22, 2025 15:17
nocodestate.mjs
const event = {
action: 'idle',
onGround: false
}
const stateMaChines = [
{
state: 'idle',
events: [
@naosim
naosim / nocode.js
Last active June 18, 2025 13:16
ノーコードのようなもの
/**
* @typedef {"eval" | "forFilter" | "forMap" | "forReduce" | "if" | "milestone"} ProcessType
*/
/**
* @typedef ProcessObject
* @property {any} [input]
* @property {ProcessType} type
* @property {string} [process]
* @property {string} [referenceId] - The id to store the output of this process in the payload
@naosim
naosim / action_first.js
Last active January 10, 2025 22:03
アクションゲームを作る初期状態
/**
* プレイヤー。矢印で操作できる
*/
class Player {
gameObject;
cursors;
create(scene) {
const player = (this.gameObject = scene.physics.add.existing(
scene.add.rectangle(100, 300, 16, 28, 0xffff00)
));
@naosim
naosim / ScreenGamePad.js
Created November 3, 2024 20:53
【microStudio】スマホ用スクリーンゲームパッド
class ScreenGamePad {
UP = false;
DOWN = false;
RIGHT = false;
LEFT = false;
A = false;
B = false;
press = {
UP: false,
DOWN: false,
@naosim
naosim / ChangeEventChecker.js
Created October 15, 2024 21:01
変更を監視する
class ChangeEventChecker {
add(name, checkerFunc) {
this[name] = {checkerFunc, lastValue:undefined, isChanged:false};
return this;
}
check() {
Object.entries(this).forEach((e) => {
const [k, v] = e;
const value = v.checkerFunc();
@naosim
naosim / GamePad.js
Last active October 18, 2024 19:04
【microScript】ゲームパッドのラッパー
class GamePad {
UP = false;
DOWN = false;
RIGHT = false;
LEFT = false;
A = false;
B = false;
press = {
UP: false,
DOWN: false,
@naosim
naosim / GameObjects.js
Created October 11, 2024 22:57
【microStudio】小要素を管理するオブジェクト
class GameObjects {
children = new Set();
constructor() {
this.children = new Set();
}
add(child) {
this.children.add(child);
}
remove(child) {
@naosim
naosim / fromEntries.js
Created October 3, 2024 21:33
fromEntries
const text = "name=naosim,point=10,state=4"
const result = text.split(",").reduce((memo, v) => {
const [key, value] = v.split("=");
return {...memo, [key]:value};
}, {})
console.log(result);
const result2 = Object.fromEntries(text.split(",").map(v => v.split("=")))
console.log(result2);
@naosim
naosim / microStudio-js-cheatcommand.js
Created October 2, 2024 21:17
【microStudio】裏技の実装(コナミコマンド)
class CheatCommand {
cheatCommandDef = "uuddlrlrba" // コナミコマンド
initKeys;
inputKeys;
isCheatCompleted = false;
init() {
this.initKeys = this.cheatCommandDef.split("").map(v => "-").join("");
this.inputKeys = this.initKeys;
}
update() {