浏览代码

Add weight attribute

tags/v0.0.1
Fen Dweller 5 年前
父节点
当前提交
c8a41857b5
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. +10
    -1
      macrovision.js

+ 10
- 1
macrovision.js 查看文件

@@ -15,6 +15,9 @@ const unitChoices = {
length: [
"meters",
"kilometers"
],
mass: [
"kilograms"
]
}
const config = {
@@ -173,6 +176,12 @@ function makeEntity() {
power: 1,
type: "length",
base: math.unit(1, "meter")
},
weight: {
name: "Weight",
power: 3,
type: "mass",
base: math.unit(80, "kg")
}
}
}
@@ -190,7 +199,7 @@ function makeEntity() {
return math.multiply(Math.pow(this.parent.scale, this.attributes[key].power), this.attributes[key].base);
},
set: function(value) {
const newScale = Math.pow(math.divide(value, this.attributes[key].base), this.attributes[key].power);
const newScale = Math.pow(math.divide(value, this.attributes[key].base), 1 / this.attributes[key].power);
this.parent.scale = newScale;
}
}


正在加载...
取消
保存