html2d
Version:
A Typescript game engine to build HTML5 games for the web using webcomponents.
44 lines (28 loc) • 810 B
text/typescript
import { HeroElement } from "./elements/hero/hero.element"
window.customElements.define("km-hero", HeroElement)
const hero = document.querySelector("km-hero") as HeroElement
const update = () => {
hero.update()
}
const render = () => {
hero.render()
}
// const updateInput = () {
// }
// const updateKey = (key: string) => {
// if (supportedKeys.includes(key) && key !== lastPressedKey) {
// lastPressedKey = key;
// }
// };
// document.addEventListener('keydown', ({ key }) => updateKeyUp(key));
// document.addEventListener('keyup', ({ key }) => updateKeyDown(key));
// Game logic
const gameLoop = () => {
update()
render()
// updateInput()
requestAnimationFrame(() => {
gameLoop()
})
}
gameLoop()