WIP
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
type Current = null | (() => void);
|
||||
|
||||
let current: Current = null;
|
||||
|
||||
export function createSignal<T>(value: T): [() => T, (value: T) => void] {
|
||||
let innerValue = value;
|
||||
const observers = new Set<() => void>();
|
||||
|
||||
const getter = () => {
|
||||
current !== null && observers.add(current);
|
||||
|
||||
return innerValue;
|
||||
};
|
||||
const setter = (value: T) => {
|
||||
innerValue = value;
|
||||
for (const observer of observers) {
|
||||
observer();
|
||||
}
|
||||
};
|
||||
|
||||
return [getter, setter];
|
||||
}
|
||||
|
||||
export function createEffect(callback: () => void) {
|
||||
current = callback;
|
||||
callback();
|
||||
current = null;
|
||||
}
|
||||
@@ -283,9 +283,9 @@ export function moveAndSlide(
|
||||
continue; // TODO
|
||||
}
|
||||
|
||||
const ts = Math.min(0, time - 0.001);
|
||||
velocity.x += velocity.x * ts;
|
||||
velocity.y += velocity.y * ts;
|
||||
// const ts = Math.min(0, time - 0.001);
|
||||
// velocity.x += velocity.x * ts;
|
||||
// velocity.y += velocity.y * ts;
|
||||
|
||||
const dot = getDotProduct(velocity, collision.normal);
|
||||
const rt = 1 - time + 0.001;
|
||||
|
||||
Reference in New Issue
Block a user