use callbag-pipe
This commit is contained in:
parent
48940e1073
commit
33eb28e338
4 changed files with 745 additions and 637 deletions
1357
package-lock.json
generated
1357
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@
|
||||||
"callbag": "^1.2.0",
|
"callbag": "^1.2.0",
|
||||||
"callbag-animation-frames": "^2.1.0",
|
"callbag-animation-frames": "^2.1.0",
|
||||||
"callbag-map": "^1.1.0",
|
"callbag-map": "^1.1.0",
|
||||||
|
"callbag-pipe": "^1.2.0",
|
||||||
"callbag-subscribe": "^1.5.1"
|
"callbag-subscribe": "^1.5.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import pipe from "callbag-pipe";
|
||||||
import subscribe from "callbag-subscribe";
|
import subscribe from "callbag-subscribe";
|
||||||
|
|
||||||
import { KeyControl, KeyName } from "../Applet/Keyboard";
|
import { KeyControl, KeyName } from "../Applet/Keyboard";
|
||||||
|
@ -20,15 +21,18 @@ export class Main extends LockstepClient<KeyName[], Data> {
|
||||||
|
|
||||||
this.connect(Loopback);
|
this.connect(Loopback);
|
||||||
|
|
||||||
subscribe((frame: Data) => {
|
pipe(
|
||||||
const drawSet = new DrawSet();
|
this.renderFrames,
|
||||||
cx.fillStyle = "#000";
|
subscribe((frame: Data) => {
|
||||||
cx.fillRect(0, 0, canvas.width, canvas.height);
|
const drawSet = new DrawSet();
|
||||||
|
cx.fillStyle = "#000";
|
||||||
|
cx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
RunRenderBounds(frame, drawSet);
|
RunRenderBounds(frame, drawSet);
|
||||||
|
|
||||||
drawSet.draw(cx, 0);
|
drawSet.draw(cx, 0);
|
||||||
})(this.renderFrames);
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
gatherInput() {
|
gatherInput() {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { Callbag } from "callbag";
|
import { Callbag } from "callbag";
|
||||||
import animationFrames from "callbag-animation-frames";
|
import animationFrames from "callbag-animation-frames";
|
||||||
import map from "callbag-map";
|
import map from "callbag-map";
|
||||||
|
import pipe from "callbag-pipe";
|
||||||
|
|
||||||
import { INPUT_FREQUENCY, LockstepProcessor, LockstepState } from "../Ecs/Lockstep";
|
import { INPUT_FREQUENCY, LockstepProcessor, LockstepState } from "../Ecs/Lockstep";
|
||||||
|
|
||||||
|
@ -88,5 +89,8 @@ export abstract class LockstepClient<Input, State> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderFrames = map((ms: number) => this.state.getStateToRender())(animationFrames);
|
public renderFrames = pipe(
|
||||||
|
animationFrames,
|
||||||
|
map(_ms => this.state.getStateToRender())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue