mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 13:23:56 -07:00
- With modules JavaScript code can be split up into multiple files. We already implemented such a mechanism (`Engine.LoadLibrary`) in multiple parts of the engine. The advantage of using modules is that it's standart (JS-devs are familiar with it) and it doesn't has to be implemented multiple times. Note that `Engine.LoadLibrary` loads all files in a directory while the new `import` only loads one file. - With modules seemingly global variables are local to that script/module. We already implemented such a mechanism (`ScriptInterface::LoadScript`).
18 lines
211 B
JavaScript
18 lines
211 B
JavaScript
import { circleArea } from "include/geometry/area.js";
|
|
|
|
class Circle
|
|
{
|
|
radius;
|
|
|
|
constructor(radius)
|
|
{
|
|
this.radius = radius;
|
|
}
|
|
|
|
get area()
|
|
{
|
|
return circleArea(this.radius);
|
|
}
|
|
}
|
|
|
|
export default Circle;
|