35 lines
No EOL
1.2 KiB
TypeScript
35 lines
No EOL
1.2 KiB
TypeScript
import { Loader, Sprite } from "pixi.js";
|
|
import { Door } from "./Components/door";
|
|
import { DebugRect } from "./Components/rendering/debugRect";
|
|
import { roomBounds } from "./constants";
|
|
import globals from "./globals";
|
|
import { createRandomHuman } from "./util";
|
|
import { Position } from "./Components/position";
|
|
import { Point } from "./Datatypes/point";
|
|
|
|
|
|
export function setup(){
|
|
let resources = Loader.shared.resources;
|
|
|
|
//base sprites without entity representation
|
|
const bgTex = new Sprite(resources["Background"].texture)
|
|
globals.app.stage.addChild(bgTex)
|
|
|
|
//start entities
|
|
|
|
//door
|
|
globals.world.createEntity()
|
|
.addComponent(Position, <Position>{value: new Point(38, 2)})
|
|
.addComponent(Door, <Door>{open: true,
|
|
openOffset: {x:0, y:0}, openTex: resources["Door"].spritesheet.textures[0],
|
|
closedOffset: {x:0, y:0}, closedTex: resources["Door"].spritesheet.textures[1]})
|
|
|
|
//debug room bounds
|
|
globals.world.createEntity()
|
|
.addComponent(DebugRect, <DebugRect>{color:0x0000FF, rect: roomBounds})
|
|
|
|
//example humans
|
|
//TODO delete those
|
|
for(let i=0;i<10;i++)
|
|
createRandomHuman(globals.world)
|
|
} |