Game Programming Patterns の 第8章 ダブルバッファのコメディ部分をTypeScriptで実装
Game Programming Patterns の 第8章 ダブルバッファのコメディ部分をTypeScriptで実装 お勉強。 1フレーム(update())ごとにバッファを入れ替える。 ファイル一覧 doubleBuffer.ts 実装 doubleBuffer.ts abstract class Actor { constructor(name: string) { this.name_ = name; this.currentSlapped_ = false; }; abstract update(): void; public swap(): void { this.currentSlapped_ = this.nextSlapped_; this.nextSlapped_ = false; } public slap(): void { this.nextSlapped_ = true }; public getname(): string { return this.name_ } protected wasSlapped(): boolean { return this.currentSlapped_ }; protected name_: string; private currentSlapped_: boolean; private nextSlapped_: boolean; } class Commedian extends Actor { // 顔の向き public face(actor: Actor) { this.facing_ = actor }; public update(): void { // console.log("name,wasSlapped : " + this.name_ + "," + this.wasSlapped()) if (this.wasSlapped()) { // 自分が叩かれてたら、こんどは顔が向いている方向にいる役者を叩く(どんなコメディだよ) this.facing_.slap() ...