1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /*
- jbox
- A JSON Component
- Version: 1.0
- Docs:
- - jbox(tags=[])
- - pack() json
- > jbox renders it's version in debug.inspect mode
- Currently Supported Components:
- - pos (Obtains X and Y)
- - health (Obtains current HP and maxHP)
- - scale (Obtains scale.X and scale.Y)
- - rotate (Obtains angle, in degrees)
- */
- export function jbox(tags=[]) {
- return {
- id: "jbox",
- require: tags,
- inspect() {
- return "[[email protected]]"
- },
- pack() {
- let j = {
- jbox: "[[email protected]]",
- comps: {},
- };
- for (let tag in tags) {
- switch (tag) {
- case "pos": {
- j.comps["pos"] = {
- x: this.pos.x,
- y: this.pos.y,
- }
- }
- case "health": {
- j.comps["health"] = {
- health: this.hp(),
- max_health: this.maxHP(),
- }
- }
- case "scale": {
- j.comps["scale"] = {
- x: this.scale.x,
- y: this.scale.y,
- }
- }
- case "rotate": {
- j.comps["rotate"] = {
- angle: this.angle,
- }
- }
- }
- }
- return j;
- }
- }
- }
- export default () => {
- return jbox
- }
|