Render stub static scene
This commit is contained in:
parent
d321098555
commit
bf26e85b49
4 changed files with 62 additions and 3 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -1603,6 +1603,14 @@
|
||||||
"callbag": "^1.1.0"
|
"callbag": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"callbag-subscribe": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/callbag-subscribe/-/callbag-subscribe-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-CRj2jKfcRvG8gap2ehsm/NxZVAjnwUApI+0ZY3bu6nyFfhhOzH+4RWpB/4RSJUZNN3ZILdSgAKQiUov/7ov9BQ==",
|
||||||
|
"requires": {
|
||||||
|
"callbag": "^1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"caller-callsite": {
|
"caller-callsite": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz",
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"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-subscribe": "^1.5.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,52 @@
|
||||||
|
import subscribe from "callbag-subscribe";
|
||||||
|
|
||||||
|
import { Game } from "../Applet/Init";
|
||||||
|
import { KeyControl, KeyName } from "../Applet/Keyboard";
|
||||||
|
import { DrawSet } from "../Applet/Render";
|
||||||
|
import { Location, Polygon, RenderBounds } from "../Ecs/Components";
|
||||||
|
import { Create } from "../Ecs/Data";
|
||||||
import {} from "../Ecs/Lockstep";
|
import {} from "../Ecs/Lockstep";
|
||||||
import {} from "./GameComponents";
|
import { RunRenderBounds } from "../Ecs/Renderers";
|
||||||
|
import { LockstepClient } from "../Net/LockstepClient";
|
||||||
|
import { Data, Engine } from "./GameComponents";
|
||||||
|
import { Buttons } from "./Input";
|
||||||
|
|
||||||
|
@Game("#GameCanvas")
|
||||||
|
export class Main extends LockstepClient<KeyName[], Data> {
|
||||||
|
|
||||||
|
buttons = new Buttons();
|
||||||
|
|
||||||
|
constructor(canvas: HTMLCanvasElement, cx: CanvasRenderingContext2D, keys: KeyControl) {
|
||||||
|
super(new Engine());
|
||||||
|
keys.setHandler(this.buttons);
|
||||||
|
|
||||||
|
subscribe((frame: Data) => {
|
||||||
|
const drawSet = new DrawSet();
|
||||||
|
|
||||||
|
RunRenderBounds(frame, drawSet);
|
||||||
|
|
||||||
|
drawSet.draw(cx, 0);
|
||||||
|
})(this.renderFrames);
|
||||||
|
}
|
||||||
|
|
||||||
|
gatherInput() {
|
||||||
|
return this.buttons.getPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
initState(patch: Partial<Data>) {
|
||||||
|
const newState = new Data();
|
||||||
|
|
||||||
|
Create(newState, {
|
||||||
|
location: new Location({
|
||||||
|
X: 200,
|
||||||
|
Y: 200,
|
||||||
|
VAngle: 0.02,
|
||||||
|
}),
|
||||||
|
bounds: new Polygon([-30, 0, 30, 0, 0, 40]),
|
||||||
|
renderBounds: new RenderBounds("#a0f", 0),
|
||||||
|
});
|
||||||
|
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<title></title>
|
<title></title>
|
||||||
<link rel="stylesheet" href="./index.scss" />
|
<link rel="stylesheet" href="./index.scss" />
|
||||||
</head><body>
|
</head><body>
|
||||||
<canvas id="RenderTest" width="500" height="400"></canvas>
|
|
||||||
<canvas id="GameCanvas" width="500" height="400"></canvas>
|
<canvas id="GameCanvas" width="500" height="400"></canvas>
|
||||||
|
<canvas id="RenderTest" width="500" height="400"></canvas>
|
||||||
<script src="./index.ts"></script>
|
<script src="./index.ts"></script>
|
||||||
</body></html>
|
</body></html>
|
||||||
|
|
Loading…
Reference in a new issue