mdoShotaro Nakamura
7/31/2023, 7:26:34 AM

開発中自作ゲームエンジン「KaguraJS」

小6から中1の初めのときくらいに作ってたやつをTypeScript/ESMで再実装中
https://nakasyou.github.io/KaguraJS/

import { Kagura, Sprite, Scene, Asset, type SceneConstructorOptions } from "kagurajs"

class MyScene extends Scene{
  gobo: Sprite
  speed?: number
  constructor (sceneConstructorOptions: SceneConstructorOptions) {
    super(sceneConstructorOptions)
    this.gobo = {} as Sprite
  }
  async init(){
    this.gobo = await new Sprite().init({
      asset: await new Asset().fromURL("./gobo.svg")
    })
    this.gobo.x = 100
    this.addChild(this.gobo)
  }
  async frame(){
    this.gobo.x ++
  }
}

const kagura = new Kagura({
  element: document.getElementById("game") as HTMLCanvasElement,
  startScene: MyScene,
})
await kagura.start()
TweetLike