This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Container from "pixi.js"; | |
function getLocalPos(target: Container, parent: Container): void { | |
return parent.toLocal(target.parent.toGlobal(target.position)); | |
} | |
// Change target's parent but preserve its screen position | |
function changeParent(target: Container, parent: Container): void { | |
const position = getLocalPos(target, parent); | |
parent.addChild(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Somewhere within the main gameplay controller class | |
private processHeroMove(nextPos: GlobalGridCoords) { | |
const interaction = new InteractionHandler(gameState); | |
const movement = new MovementHandler(gameState); | |
const combat = new CombatHandler(gameState); | |
const start = interaction; | |
interaction.next = movement; | |
movement.next = combat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DisplayObject } from "@pixi/display"; | |
export class Pool<T extends DisplayObject> { | |
private inactive: T[] = []; | |
public active: T[] = []; | |
private readonly createObject: () => T; | |
private readonly resetObject: (elem: T) => void; | |
private readonly destroyObject: (elem: T) => void; | |
constructor( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Random CSS to make HTML version of Data-Oriented Design book (https://www.dataorienteddesign.com/dodbook/) a bit more pleasant to read on my 15" FHD laptop */ | |
body { | |
font-family: 'Lato', "Verdana", sans-serif; | |
font-size: 1.4em; | |
line-height: 1.5em; | |
padding: 20px; | |
background-color: #eee; | |
color: #222 | |
} |