Skip to content

Commit

Permalink
feat: pong example web
Browse files Browse the repository at this point in the history
  • Loading branch information
load1n9 committed Jun 2, 2022
1 parent a490b49 commit ed690d5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
9 changes: 5 additions & 4 deletions web/dist/mod.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/dist/mod.js.map

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions web/src/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class World {
}

async start(): Promise<void> {
printBanner("2.3.6");
printBanner("2.4.6");
await this.renderer.init();
this.setup();
await this.currentScene.loadResources();
Expand All @@ -57,10 +57,7 @@ export class World {
setFPS(fps: number): void {
this.FPS = fps;
}
keyDown(e: string): void {
this.currentScene.keyDown(e);
}

keyDown = (e: string): boolean => this.currentScene.keyDown(e);
setScene(scene: number | string): void {
if (typeof scene === "string") {
for (const s of this.scenes) {
Expand Down
6 changes: 4 additions & 2 deletions web/src/events/KeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export class KeyManager {
setKeys(keys: Array<string>) {
this.listeners = keys;
// @ts-ignore: typescript is weird
window!.addEventListener("keydown", (e: KeyboardEvent) => {
// deno-lint-ignore no-window-prefix
window.addEventListener("keydown", (e: KeyboardEvent) => {
if (this.listeners.includes(e.key)) {
this.keysDown[e.key] = true;
}
});
// @ts-ignore: typescript is weird
window!.addEventListener("keyup", (e: KeyboardEvent) => {
// deno-lint-ignore no-window-prefix
window.addEventListener("keyup", (e: KeyboardEvent) => {
if (this.listeners.includes(e.key)) {
this.keysDown[e.key] = false;
}
Expand Down

0 comments on commit ed690d5

Please sign in to comment.