diff --git a/README.md b/README.md index 25264ba..c5d8569 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,11 @@ This is a Chinese New Year greeting card and mini video game for the Year of the Tiger. Gong Xi Fa Cai, everyone! -Original code was based on [AvO Adventure Mk3](https://github.com/shaunanoordin/avo-adventure-mk3). +Play it online at [shaunanoordin.github.io/cny2022](https://shaunanoordin.github.io/cny2022/) +or [shaunanoordin.com/cny2022](https://shaunanoordin.com/cny2022/) -Created by [Shaun A. Noordin](https://shaunanoordin.com). +Created by [Shaun A. Noordin](https://shaunanoordin.com). Original code based on +[AvO Adventure Mk3](https://github.com/shaunanoordin/avo-adventure-mk3). ## How to Use diff --git a/app/main.css b/app/main.css index db620b8..ac56015 100644 --- a/app/main.css +++ b/app/main.css @@ -102,7 +102,7 @@ table th { } #app > main #home-menu #banner #card { display: block; - max-width: 50%; + max-width: 60%; margin: 0 auto; } #app > main #home-menu #levels-list { diff --git a/app/main.js b/app/main.js index d4b1842..1d5ac9f 100644 --- a/app/main.js +++ b/app/main.js @@ -96,7 +96,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Vase)\n/* harmony export */ });\n/* harmony import */ var _avo_atom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @avo/atom */ \"./src/avo/atom/index.js\");\n/* harmony import */ var _avo_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @avo/constants */ \"./src/avo/constants.js\");\n/* harmony import */ var _avo_misc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @avo/misc */ \"./src/avo/misc.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\nvar FRAGILITY = 0.15;\nvar DECAY_MAX = 500;\n\nvar Vase = /*#__PURE__*/function (_Atom) {\n _inherits(Vase, _Atom);\n\n var _super = _createSuper(Vase);\n\n function Vase(app) {\n var _this;\n\n var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var row = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n\n _classCallCheck(this, Vase);\n\n _this = _super.call(this, app);\n _this._type = 'cny2022-vase';\n _this.colour = 'rgba(32, 32, 64, 0.5)';\n _this.solid = true;\n _this.movable = true;\n _this.x = col * _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE + _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE / 2;\n _this.y = row * _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE + _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE / 2;\n _this.prevPushX = 0;\n _this.prevPushY = 0;\n _this.broken = false;\n _this.decayCounter = 0;\n return _this;\n }\n\n _createClass(Vase, [{\n key: \"play\",\n value: function play(timeStep) {\n _get(_getPrototypeOf(Vase.prototype), \"play\", this).call(this, timeStep); // If the object is broken, begin the decay process\n\n\n if (this.broken) {\n this.decayCounter = Math.min(this.decayCounter + timeStep, DECAY_MAX);\n if (this.decayCounter >= DECAY_MAX) this._expired = true;\n return;\n } // Calculate the impulse of the object\n // If the object is jolted too much (moves too much in a short amount of\n // time) then it breaks\n\n\n var impulseX = this.pushX - this.prevPushX;\n var impulseY = this.pushY - this.prevPushY;\n var impulseSquared = (impulseX * impulseX + impulseY * impulseY) * this.mass * timeStep / (_avo_constants__WEBPACK_IMPORTED_MODULE_1__.EXPECTED_TIMESTEP * 1000);\n this.prevPushX = this.pushX;\n this.prevPushY = this.pushY;\n\n if (impulseSquared > FRAGILITY) {\n this[\"break\"]();\n }\n }\n }, {\n key: \"paint\",\n value: function paint() {\n var layer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n // super.paint(layer)\n var c2d = this._app.canvas2d;\n var camera = this._app.camera;\n var animationSpritesheet = this._app.assets.cny2022;\n\n if (layer === 0 && !this.broken) {\n c2d.fillStyle = this.colour; // Draw shadow\n\n c2d.beginPath();\n c2d.arc(Math.floor(this.x + camera.x), Math.floor(this.y + camera.y), this.size / 2, 0, 2 * Math.PI);\n c2d.closePath();\n c2d.fill();\n } else if (layer === 1) {\n if (!animationSpritesheet) return;\n var SPRITE_SIZE = 96;\n var SPRITE_OFFSET_X = 0;\n var SPRITE_OFFSET_Y = -8;\n var srcSizeX = SPRITE_SIZE;\n var srcSizeY = SPRITE_SIZE;\n var srcX = SPRITE_SIZE * 4;\n var srcY = 0;\n var tgtSizeX = SPRITE_SIZE * 1;\n var tgtSizeY = SPRITE_SIZE * 1;\n var tgtX = Math.floor(this.x + camera.x) - srcSizeX / 2 + SPRITE_OFFSET_X - (tgtSizeX - srcSizeX) / 2;\n var tgtY = Math.floor(this.y + camera.y) - srcSizeY / 2 + SPRITE_OFFSET_Y - (tgtSizeY - srcSizeY) / 2;\n\n if (this.broken) {\n var progress = this.decayCounter / DECAY_MAX;\n if (progress < 0.33) srcY = SPRITE_SIZE * 1;else if (progress < 0.67) srcY = SPRITE_SIZE * 2;else srcY = SPRITE_SIZE * 3;\n } else {\n srcY = 0;\n }\n\n c2d.drawImage(animationSpritesheet.img, Math.floor(srcX), Math.floor(srcY), Math.floor(srcSizeX), Math.floor(srcSizeY), Math.floor(tgtX), Math.floor(tgtY), Math.floor(tgtSizeX), Math.floor(tgtSizeY));\n }\n }\n }, {\n key: \"break\",\n value: function _break() {\n if (this.broken) return;\n this.broken = true;\n var victory = this._app.rules['cny2022-victory'];\n if (victory) victory.score--;\n }\n }]);\n\n return Vase;\n}(_avo_atom__WEBPACK_IMPORTED_MODULE_0__.default);\n\n\n\n//# sourceURL=webpack://cny2022/./src/avo/atom/types/cny2022/vase.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Vase)\n/* harmony export */ });\n/* harmony import */ var _avo_atom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @avo/atom */ \"./src/avo/atom/index.js\");\n/* harmony import */ var _avo_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @avo/constants */ \"./src/avo/constants.js\");\n/* harmony import */ var _avo_misc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @avo/misc */ \"./src/avo/misc.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\nvar FRAGILITY = 0.15;\nvar DECAY_MAX = 500;\n\nvar Vase = /*#__PURE__*/function (_Atom) {\n _inherits(Vase, _Atom);\n\n var _super = _createSuper(Vase);\n\n function Vase(app) {\n var _this;\n\n var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var row = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n\n _classCallCheck(this, Vase);\n\n _this = _super.call(this, app);\n _this._type = 'cny2022-vase';\n _this.colour = 'rgba(32, 32, 64, 0.5)';\n _this.solid = true;\n _this.movable = true;\n _this.transparent = true;\n _this.x = col * _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE + _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE / 2;\n _this.y = row * _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE + _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE / 2;\n _this.prevPushX = 0;\n _this.prevPushY = 0;\n _this.broken = false;\n _this.decayCounter = 0;\n return _this;\n }\n\n _createClass(Vase, [{\n key: \"play\",\n value: function play(timeStep) {\n _get(_getPrototypeOf(Vase.prototype), \"play\", this).call(this, timeStep); // If the object is broken, begin the decay process\n\n\n if (this.broken) {\n this.decayCounter = Math.min(this.decayCounter + timeStep, DECAY_MAX);\n if (this.decayCounter >= DECAY_MAX) this._expired = true;\n return;\n } // Calculate the impulse of the object\n // If the object is jolted too much (moves too much in a short amount of\n // time) then it breaks\n\n\n var impulseX = this.pushX - this.prevPushX;\n var impulseY = this.pushY - this.prevPushY;\n var impulseSquared = (impulseX * impulseX + impulseY * impulseY) * this.mass * timeStep / (_avo_constants__WEBPACK_IMPORTED_MODULE_1__.EXPECTED_TIMESTEP * 1000);\n this.prevPushX = this.pushX;\n this.prevPushY = this.pushY;\n\n if (impulseSquared > FRAGILITY) {\n this[\"break\"]();\n }\n }\n }, {\n key: \"paint\",\n value: function paint() {\n var layer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n // super.paint(layer)\n var c2d = this._app.canvas2d;\n var camera = this._app.camera;\n var animationSpritesheet = this._app.assets.cny2022;\n\n if (layer === 0 && !this.broken) {\n c2d.fillStyle = this.colour; // Draw shadow\n\n c2d.beginPath();\n c2d.arc(Math.floor(this.x + camera.x), Math.floor(this.y + camera.y), this.size / 2, 0, 2 * Math.PI);\n c2d.closePath();\n c2d.fill();\n } else if (layer === 1) {\n if (!animationSpritesheet) return;\n var SPRITE_SIZE = 96;\n var SPRITE_OFFSET_X = 0;\n var SPRITE_OFFSET_Y = -8;\n var srcSizeX = SPRITE_SIZE;\n var srcSizeY = SPRITE_SIZE;\n var srcX = SPRITE_SIZE * 4;\n var srcY = 0;\n var tgtSizeX = SPRITE_SIZE * 1;\n var tgtSizeY = SPRITE_SIZE * 1;\n var tgtX = Math.floor(this.x + camera.x) - srcSizeX / 2 + SPRITE_OFFSET_X - (tgtSizeX - srcSizeX) / 2;\n var tgtY = Math.floor(this.y + camera.y) - srcSizeY / 2 + SPRITE_OFFSET_Y - (tgtSizeY - srcSizeY) / 2;\n\n if (this.broken) {\n var progress = this.decayCounter / DECAY_MAX;\n if (progress < 0.33) srcY = SPRITE_SIZE * 1;else if (progress < 0.67) srcY = SPRITE_SIZE * 2;else srcY = SPRITE_SIZE * 3;\n } else {\n srcY = 0;\n }\n\n c2d.drawImage(animationSpritesheet.img, Math.floor(srcX), Math.floor(srcY), Math.floor(srcSizeX), Math.floor(srcSizeY), Math.floor(tgtX), Math.floor(tgtY), Math.floor(tgtSizeX), Math.floor(tgtSizeY));\n }\n }\n }, {\n key: \"break\",\n value: function _break() {\n if (this.broken) return;\n this.broken = true;\n var victory = this._app.rules['cny2022-victory'];\n if (victory) victory.score--;\n }\n }]);\n\n return Vase;\n}(_avo_atom__WEBPACK_IMPORTED_MODULE_0__.default);\n\n\n\n//# sourceURL=webpack://cny2022/./src/avo/atom/types/cny2022/vase.js?"); /***/ }), @@ -130,6 +130,16 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ }), +/***/ "./src/avo/atom/types/text-message.js": +/*!********************************************!*\ + !*** ./src/avo/atom/types/text-message.js ***! + \********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TextMessage)\n/* harmony export */ });\n/* harmony import */ var _avo_atom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @avo/atom */ \"./src/avo/atom/index.js\");\n/* harmony import */ var _avo_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @avo/constants */ \"./src/avo/constants.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n/*\r\nThe TextMessage displays (non-interactable) text on the canvas.\r\nUseful for having in-game instructions.\r\n */\n\nvar TextMessage = /*#__PURE__*/function (_Atom) {\n _inherits(TextMessage, _Atom);\n\n var _super = _createSuper(TextMessage);\n\n function TextMessage(app, text) {\n var _this;\n\n var col = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n var row = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n var layer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;\n\n _classCallCheck(this, TextMessage);\n\n _this = _super.call(this, app);\n _this._type = 'text-message';\n _this.x = col * _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE + _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE / 2;\n _this.y = row * _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE + _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE / 2;\n _this.text = text;\n _this.layer = layer;\n _this.colour = 'rgba(0, 0, 0, 0.5)';\n _this.font = '3em sans-serif';\n _this.textBaseline = 'middle';\n _this.textAlign = 'center';\n _this.solid = false;\n _this.movable = false;\n return _this;\n }\n\n _createClass(TextMessage, [{\n key: \"paint\",\n value: function paint() {\n var layer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n // super.paint(layer)\n var c2d = this._app.canvas2d;\n var camera = this._app.camera;\n\n if (layer === this.layer) {\n c2d.font = this.font;\n c2d.textBaseline = this.textBaseline;\n c2d.textAlign = this.textAlign;\n c2d.fillStyle = this.colour;\n c2d.fillText(this.text, this.x, this.y);\n }\n }\n }]);\n\n return TextMessage;\n}(_avo_atom__WEBPACK_IMPORTED_MODULE_0__.default);\n\n\n\n//# sourceURL=webpack://cny2022/./src/avo/atom/types/text-message.js?"); + +/***/ }), + /***/ "./src/avo/atom/types/wall.js": /*!************************************!*\ !*** ./src/avo/atom/types/wall.js ***! @@ -216,7 +226,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Levels)\n/* harmony export */ });\n/* harmony import */ var _avo_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @avo/constants */ \"./src/avo/constants.js\");\n/* harmony import */ var _avo_atom_types_hero__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @avo/atom/types/hero */ \"./src/avo/atom/types/hero.js\");\n/* harmony import */ var _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @avo/atom/types/wall */ \"./src/avo/atom/types/wall.js\");\n/* harmony import */ var _avo_atom_types_ball__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @avo/atom/types/ball */ \"./src/avo/atom/types/ball.js\");\n/* harmony import */ var _avo_atom_types_enemy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @avo/atom/types/enemy */ \"./src/avo/atom/types/enemy.js\");\n/* harmony import */ var _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @avo/atom/types/cny2022/cat */ \"./src/avo/atom/types/cny2022/cat.js\");\n/* harmony import */ var _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @avo/atom/types/cny2022/laser-pointer */ \"./src/avo/atom/types/cny2022/laser-pointer.js\");\n/* harmony import */ var _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @avo/atom/types/cny2022/goal */ \"./src/avo/atom/types/cny2022/goal.js\");\n/* harmony import */ var _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @avo/atom/types/cny2022/coin */ \"./src/avo/atom/types/cny2022/coin.js\");\n/* harmony import */ var _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @avo/atom/types/cny2022/vase */ \"./src/avo/atom/types/cny2022/vase.js\");\n/* harmony import */ var _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @avo/atom/types/cny2022/glass-wall */ \"./src/avo/atom/types/cny2022/glass-wall.js\");\n/* harmony import */ var _avo_rule_types_zelda_controls__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @avo/rule/types/zelda-controls */ \"./src/avo/rule/types/zelda-controls.js\");\n/* harmony import */ var _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @avo/rule/types/cny2022-controls */ \"./src/avo/rule/types/cny2022-controls.js\");\n/* harmony import */ var _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @avo/rule/types/cny2022-victory */ \"./src/avo/rule/types/cny2022-victory.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar CNY2022_HIGHSCORE_STORAGE_KEY = 'cny2022.highscores';\n\nvar Levels = /*#__PURE__*/function () {\n function Levels(app) {\n _classCallCheck(this, Levels);\n\n this._app = app;\n this.current = 0;\n this.cny2022LevelGenerators = [this.generate_cny2022_level_1.bind(this), this.generate_cny2022_level_2.bind(this)];\n this.cny2022HighScores = this.cny2022LevelGenerators.map(function () {\n return undefined;\n });\n this.loadCNY2022HighScores();\n }\n\n _createClass(Levels, [{\n key: \"reset\",\n value: function reset() {\n var app = this._app;\n app.hero = undefined;\n app.atoms = [];\n app.clearRules();\n app.camera = {\n target: null,\n x: 0,\n y: 0\n };\n app.playerAction = _avo_constants__WEBPACK_IMPORTED_MODULE_0__.PLAYER_ACTIONS.IDLE;\n app.setInteractionMenu(false);\n app.paused = false;\n }\n }, {\n key: \"load\",\n value: function load() {\n var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n var app = this._app;\n this.current = level;\n this.reset();\n\n if (this.cny2022LevelGenerators[level]) {\n this.cny2022LevelGenerators[level]();\n }\n }\n }, {\n key: \"reload\",\n value: function reload() {\n this.load(this.current);\n }\n }, {\n key: \"registerCNY2022Score\",\n value: function registerCNY2022Score(score) {\n var highscore = this.cny2022HighScores[this.current];\n\n if (highscore === undefined || highscore < score) {\n this.cny2022HighScores[this.current] = score;\n }\n\n this.saveCNY2022HighScores();\n }\n }, {\n key: \"saveCNY2022HighScores\",\n value: function saveCNY2022HighScores() {\n var _window;\n\n var storage = (_window = window) === null || _window === void 0 ? void 0 : _window.localStorage;\n if (!storage) return;\n storage.setItem(CNY2022_HIGHSCORE_STORAGE_KEY, JSON.stringify(this.cny2022HighScores));\n }\n }, {\n key: \"loadCNY2022HighScores\",\n value: function loadCNY2022HighScores() {\n var _window2;\n\n var storage = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.localStorage;\n if (!storage) return;\n\n try {\n var str = storage.getItem(CNY2022_HIGHSCORE_STORAGE_KEY);\n this.cny2022HighScores = str ? JSON.parse(str) : [];\n } catch (err) {\n this.cny2022HighScores = [];\n console.error(err);\n }\n }\n /*\r\n Default top-down adventure level.\r\n */\n\n }, {\n key: \"generate_zelda_default\",\n value: function generate_zelda_default() {\n var app = this._app;\n app.hero = new _avo_atom_types_hero__WEBPACK_IMPORTED_MODULE_1__.default(app, 11, 1);\n app.atoms.push(app.hero);\n app.camera.target = app.hero;\n app.addRule(new _avo_rule_types_zelda_controls__WEBPACK_IMPORTED_MODULE_11__.default(app)); // app.addRule(new CNY2022Controls(app))\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, 0, 1, 23)); // West Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 22, 0, 1, 23)); // East Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 1, 0, 21, 1)); // North Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 1, 22, 21, 1)); // South Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 3, 2, 3, 1));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 3, 4, 3, 1));\n app.atoms.push(new _avo_atom_types_ball__WEBPACK_IMPORTED_MODULE_3__.default(app, 8, 6));\n var enemy = new _avo_atom_types_enemy__WEBPACK_IMPORTED_MODULE_4__.default(app, 4, 8);\n enemy.rotation = -45 / 180 * Math.PI;\n app.atoms.push(enemy);\n }\n }, {\n key: \"generate_cny2022_default\",\n value: function generate_cny2022_default() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_5__.default(app, 3, 13);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_6__.default(app, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1) / 2, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 3);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_12__.default(app, cat, laserPointer));\n this.createOuterWalls();\n }\n }, {\n key: \"generate_cny2022_level_1\",\n value: function generate_cny2022_level_1() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_5__.default(app, 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_6__.default(app, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1) / 2, 3);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_12__.default(app, cat, laserPointer));\n app.addRule(new _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_13__.default(app)); // Layout\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_10__.default(app, 11, 6, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_10__.default(app, 11, 1, 1, 5));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_10__.default(app, 28, 1, 1, 5));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 11, 13, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_7__.default(app, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2)); // Coins\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 18, 11));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 21, 11));\n\n for (var i = 0; i < 4; i++) {\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 15 + i * 3, 15));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 15 + i * 3, 17));\n }\n\n this.createOuterWalls();\n }\n }, {\n key: \"generate_cny2022_level_2\",\n value: function generate_cny2022_level_2() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_5__.default(app, 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_6__.default(app, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1) / 2, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 3);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_12__.default(app, cat, laserPointer));\n app.addRule(new _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_13__.default(app)); // Layout\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 11, 6, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_10__.default(app, 11, 15, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_10__.default(app, 11, 16, 1, 3));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_10__.default(app, 28, 16, 1, 3));\n app.atoms.push(new _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_7__.default(app, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2)); // Coins\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 11.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 15.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 19.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 23.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 27.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 5.5, 14));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 3.5, 15.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 7.5, 15.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 4.5, 17.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_8__.default(app, 6.5, 17.5)); // Vases\n\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_9__.default(app, 13.5, 9.5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_9__.default(app, 16.5, 9.5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_9__.default(app, 19.5, 9.5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_9__.default(app, 22.5, 9.5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_9__.default(app, 25.5, 9.5));\n this.createOuterWalls();\n }\n }, {\n key: \"createOuterWalls\",\n value: function createOuterWalls() {\n var app = this._app;\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, 0, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS, 1)); // North Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS, 1)); // South Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, 1, 1, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 2)); // West Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1, 1, 1, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 2)); // East Wall\n }\n }]);\n\n return Levels;\n}();\n\n\n\n//# sourceURL=webpack://cny2022/./src/avo/levels.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Levels)\n/* harmony export */ });\n/* harmony import */ var _avo_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @avo/constants */ \"./src/avo/constants.js\");\n/* harmony import */ var _avo_atom_types_hero__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @avo/atom/types/hero */ \"./src/avo/atom/types/hero.js\");\n/* harmony import */ var _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @avo/atom/types/wall */ \"./src/avo/atom/types/wall.js\");\n/* harmony import */ var _avo_atom_types_ball__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @avo/atom/types/ball */ \"./src/avo/atom/types/ball.js\");\n/* harmony import */ var _avo_atom_types_enemy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @avo/atom/types/enemy */ \"./src/avo/atom/types/enemy.js\");\n/* harmony import */ var _avo_atom_types_text_message__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @avo/atom/types/text-message */ \"./src/avo/atom/types/text-message.js\");\n/* harmony import */ var _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @avo/atom/types/cny2022/cat */ \"./src/avo/atom/types/cny2022/cat.js\");\n/* harmony import */ var _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @avo/atom/types/cny2022/laser-pointer */ \"./src/avo/atom/types/cny2022/laser-pointer.js\");\n/* harmony import */ var _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @avo/atom/types/cny2022/goal */ \"./src/avo/atom/types/cny2022/goal.js\");\n/* harmony import */ var _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @avo/atom/types/cny2022/coin */ \"./src/avo/atom/types/cny2022/coin.js\");\n/* harmony import */ var _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @avo/atom/types/cny2022/vase */ \"./src/avo/atom/types/cny2022/vase.js\");\n/* harmony import */ var _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @avo/atom/types/cny2022/glass-wall */ \"./src/avo/atom/types/cny2022/glass-wall.js\");\n/* harmony import */ var _avo_rule_types_zelda_controls__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @avo/rule/types/zelda-controls */ \"./src/avo/rule/types/zelda-controls.js\");\n/* harmony import */ var _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @avo/rule/types/cny2022-controls */ \"./src/avo/rule/types/cny2022-controls.js\");\n/* harmony import */ var _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @avo/rule/types/cny2022-victory */ \"./src/avo/rule/types/cny2022-victory.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar CNY2022_HIGHSCORE_STORAGE_KEY = 'cny2022.highscores';\n\nvar Levels = /*#__PURE__*/function () {\n function Levels(app) {\n _classCallCheck(this, Levels);\n\n this._app = app;\n this.current = 0;\n this.cny2022LevelGenerators = [this.generate_cny2022_level_1.bind(this), this.generate_cny2022_level_2.bind(this), this.generate_cny2022_level_3.bind(this), this.generate_cny2022_level_4.bind(this), this.generate_cny2022_level_5.bind(this)];\n this.cny2022HighScores = this.cny2022LevelGenerators.map(function () {\n return undefined;\n });\n this.loadCNY2022HighScores();\n }\n\n _createClass(Levels, [{\n key: \"reset\",\n value: function reset() {\n var app = this._app;\n app.hero = undefined;\n app.atoms = [];\n app.clearRules();\n app.camera = {\n target: null,\n x: 0,\n y: 0\n };\n app.playerAction = _avo_constants__WEBPACK_IMPORTED_MODULE_0__.PLAYER_ACTIONS.IDLE;\n app.setInteractionMenu(false);\n app.paused = false;\n }\n }, {\n key: \"load\",\n value: function load() {\n var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n var app = this._app;\n this.current = level;\n this.reset();\n\n if (this.cny2022LevelGenerators[level]) {\n this.cny2022LevelGenerators[level]();\n }\n }\n }, {\n key: \"reload\",\n value: function reload() {\n this.load(this.current);\n }\n }, {\n key: \"registerCNY2022Score\",\n value: function registerCNY2022Score(score) {\n var highscore = this.cny2022HighScores[this.current];\n\n if (highscore === undefined || highscore < score) {\n this.cny2022HighScores[this.current] = score;\n }\n\n this.saveCNY2022HighScores();\n }\n }, {\n key: \"saveCNY2022HighScores\",\n value: function saveCNY2022HighScores() {\n var _window;\n\n var storage = (_window = window) === null || _window === void 0 ? void 0 : _window.localStorage;\n if (!storage) return;\n storage.setItem(CNY2022_HIGHSCORE_STORAGE_KEY, JSON.stringify(this.cny2022HighScores));\n }\n }, {\n key: \"loadCNY2022HighScores\",\n value: function loadCNY2022HighScores() {\n var _window2;\n\n var storage = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.localStorage;\n if (!storage) return;\n\n try {\n var str = storage.getItem(CNY2022_HIGHSCORE_STORAGE_KEY);\n this.cny2022HighScores = str ? JSON.parse(str) : [];\n } catch (err) {\n this.cny2022HighScores = [];\n console.error(err);\n }\n }\n /*\r\n Default top-down adventure level.\r\n */\n\n }, {\n key: \"generate_zelda_default\",\n value: function generate_zelda_default() {\n var app = this._app;\n app.hero = new _avo_atom_types_hero__WEBPACK_IMPORTED_MODULE_1__.default(app, 11, 1);\n app.atoms.push(app.hero);\n app.camera.target = app.hero;\n app.addRule(new _avo_rule_types_zelda_controls__WEBPACK_IMPORTED_MODULE_12__.default(app)); // app.addRule(new CNY2022Controls(app))\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, 0, 1, 23)); // West Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 22, 0, 1, 23)); // East Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 1, 0, 21, 1)); // North Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 1, 22, 21, 1)); // South Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 3, 2, 3, 1));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 3, 4, 3, 1));\n app.atoms.push(new _avo_atom_types_ball__WEBPACK_IMPORTED_MODULE_3__.default(app, 8, 6));\n var enemy = new _avo_atom_types_enemy__WEBPACK_IMPORTED_MODULE_4__.default(app, 4, 8);\n enemy.rotation = -45 / 180 * Math.PI;\n app.atoms.push(enemy);\n }\n }, {\n key: \"generate_cny2022_default\",\n value: function generate_cny2022_default() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_6__.default(app, 3, 13);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_7__.default(app, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1) / 2, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 3);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_13__.default(app, cat, laserPointer));\n this.createOuterWalls();\n }\n }, {\n key: \"generate_cny2022_level_1\",\n value: function generate_cny2022_level_1() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_6__.default(app, 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_7__.default(app, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1) / 2, 3);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_13__.default(app, cat, laserPointer));\n app.addRule(new _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_14__.default(app)); // Layout\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 11, 6, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 11, 1, 1, 5));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 28, 1, 1, 5));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 11, 13, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_8__.default(app, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2)); // Coins\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 18, 11));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 21, 11));\n\n for (var i = 0; i < 4; i++) {\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 15 + i * 3, 15));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 15 + i * 3, 17));\n } // Hints\n\n\n var hint1 = new _avo_atom_types_text_message__WEBPACK_IMPORTED_MODULE_5__.default(app, '👆 Tap or click to aim laser', 19.5, 9, 0);\n var hint2 = new _avo_atom_types_text_message__WEBPACK_IMPORTED_MODULE_5__.default(app, 'Get tiger to goal 🐅⬇️', 37.5, 7.5, 0);\n hint2.textAlign = 'right';\n var hint3 = new _avo_atom_types_text_message__WEBPACK_IMPORTED_MODULE_5__.default(app, 'Coins add to score ➡️', 2, 16, 0);\n hint3.textAlign = 'left';\n app.atoms.push(hint1, hint2, hint3);\n this.createOuterWalls();\n }\n }, {\n key: \"generate_cny2022_level_2\",\n value: function generate_cny2022_level_2() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_6__.default(app, 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_7__.default(app, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1) / 2, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 3);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_13__.default(app, cat, laserPointer));\n app.addRule(new _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_14__.default(app)); // Layout\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 11, 6, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 11, 15, 18, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 11, 16, 1, 3));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 28, 16, 1, 3));\n app.atoms.push(new _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_8__.default(app, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2)); // Coins\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 11.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 15.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 19.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 23.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 27.5, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 5.5, 14));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 3.5, 15.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 7.5, 15.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 4.5, 17.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 6.5, 17.5)); // Vases\n\n for (var i = 0; i < 5; i++) {\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 13.5 + i * 3, 8.5));\n }\n\n for (var _i = 0; _i < 3; _i++) {\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 16.5 + _i * 3, 11.5));\n } // Hints\n\n\n var hint1 = new _avo_atom_types_text_message__WEBPACK_IMPORTED_MODULE_5__.default(app, '⬆️ Don\\'t break vases!', 19.5, 13.5, 0);\n var hint2 = new _avo_atom_types_text_message__WEBPACK_IMPORTED_MODULE_5__.default(app, 'Walls block lasers', 19.5, 6, 2);\n hint2.colour = 'rgba(255, 255, 255, 0.8)';\n app.atoms.push(hint1, hint2);\n this.createOuterWalls();\n }\n }, {\n key: \"generate_cny2022_level_3\",\n value: function generate_cny2022_level_3() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_6__.default(app, 3, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1) / 2);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_7__.default(app, (_avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1) / 2, 6.5);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_13__.default(app, cat, laserPointer));\n app.addRule(new _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_14__.default(app)); // Layout\n\n this.createOuterWalls();\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 1, 1, 3, 3, 'se')); // North triangle\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 36, 1, 3, 3, 'sw')); // North triangle\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 5, 5, 30, 1)); // North wall\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 17, 6, 1, 2)); // Glass cage\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 22, 6, 1, 2)); // Glass cage\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 17, 8, 6, 1)); // Glass cage\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 10, 14, 8, 1)); // South wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 22, 14, 8, 1)); // South wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 18, 12, 4, 1)); // South wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 17, 12, 1, 2)); // South wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 22, 12, 1, 2)); // South wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 5, 14, 5, 5, 'nw'));\n app.atoms.push(new _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_8__.default(app, 19.5, 13.5)); // Coins\n\n for (var i = 0; i < 6; i++) {\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 9.5 + i * 4, 2.5));\n }\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 2.5, 16.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 11.5, 16.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 27.5, 16.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 36.5, 16.5)); // Vases\n\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 8, 9));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 12, 9));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 27, 9));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 31, 9));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 10, 12));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 29, 12));\n }\n }, {\n key: \"generate_cny2022_level_4\",\n value: function generate_cny2022_level_4() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_6__.default(app, 19.5, 4.5);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_7__.default(app, 19.5, 9.5);\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_13__.default(app, cat, laserPointer));\n app.addRule(new _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_14__.default(app));\n this.createOuterWalls();\n app.atoms.push(new _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_8__.default(app, 19.5, 2)); // Central cage\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 18, 7, 4, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 18, 12, 4, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 17, 8, 1, 4));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 22, 8, 1, 4));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 18, 9.5, 0.5, 1));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 21.5, 9.5, 0.5, 1));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 19.5, 8, 1, 0.5));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 19.5, 11.5, 1, 0.5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 19.5, 6));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 19.5, 13));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 16, 9.5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 23, 9.5)); // Left Side\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 4, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 4, 16));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 12, 6));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 12, 13));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 2, 5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 2, 14));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 7, 7));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 7, 12));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 9, 16));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 2, 7, 1, 6));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 6, 9, 5, 1, 'ne'));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 6, 10, 5, 1, 'se')); // Middle\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 19.5, 15));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 19.5, 17)); // Right Side\n\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 35, 3));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 35, 16));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 27, 6));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 27, 13));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 37, 5));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 37, 14));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 32, 7));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 32, 12));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 30, 16));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 37, 7, 1, 6));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 29, 9, 5, 1, 'nw'));\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 29, 10, 5, 1, 'sw'));\n }\n }, {\n key: \"generate_cny2022_level_5\",\n value: function generate_cny2022_level_5() {\n var app = this._app;\n var cat = new _avo_atom_types_cny2022_cat__WEBPACK_IMPORTED_MODULE_6__.default(app, 19.5, 17);\n var laserPointer = new _avo_atom_types_cny2022_laser_pointer__WEBPACK_IMPORTED_MODULE_7__.default(app, 19.5, 1.5); // const laserPointer = new LaserPointer(app, 37.5, 1.5)\n\n app.atoms.push(cat);\n app.atoms.push(laserPointer);\n app.addRule(new _avo_rule_types_cny2022_controls__WEBPACK_IMPORTED_MODULE_13__.default(app, cat, laserPointer));\n app.addRule(new _avo_rule_types_cny2022_victory__WEBPACK_IMPORTED_MODULE_14__.default(app));\n this.createOuterWalls(); // North Wall\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 4, 3, 35, 1)); // West Wall\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 4, 7, 1, 9));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 2, 11)); // Eastern Maze\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 32, 4, 1, 9)); // East wall\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 32, 16, 1, 3)); // East wall\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 33, 6, 4, 1)); // East maze 1\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 35, 9, 4, 1)); // East maze 2\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 33, 12, 4, 1)); // East maze 3\n\n app.atoms.push(new _avo_atom_types_cny2022_goal__WEBPACK_IMPORTED_MODULE_8__.default(app, 35.5, 17));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 35.5, 4.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 35.5, 7.5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 35.5, 10.5)); // Middle maze\n\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 8, 7, 9, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 8, 11, 9, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 8, 15, 9, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 23, 9, 5, 1));\n app.atoms.push(new _avo_atom_types_cny2022_glass_wall__WEBPACK_IMPORTED_MODULE_11__.default(app, 23, 13, 5, 1));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 18, 7));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 18, 11));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 18, 15));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 21, 9));\n app.atoms.push(new _avo_atom_types_cny2022_vase__WEBPACK_IMPORTED_MODULE_10__.default(app, 21, 13));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 12, 5));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 12, 9));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 12, 13));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 25, 7));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 25, 11));\n app.atoms.push(new _avo_atom_types_cny2022_coin__WEBPACK_IMPORTED_MODULE_9__.default(app, 25, 15));\n }\n }, {\n key: \"createOuterWalls\",\n value: function createOuterWalls() {\n var app = this._app;\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, 0, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS, 1)); // North Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 1, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS, 1)); // South Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, 0, 1, 1, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 2)); // West Wall\n\n app.atoms.push(new _avo_atom_types_wall__WEBPACK_IMPORTED_MODULE_2__.default(app, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_COLS - 1, 1, 1, _avo_constants__WEBPACK_IMPORTED_MODULE_0__.CNY2022_ROWS - 2)); // East Wall\n }\n }]);\n\n return Levels;\n}();\n\n\n\n//# sourceURL=webpack://cny2022/./src/avo/levels.js?"); /***/ }), @@ -276,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ CNY2022Victory)\n/* harmony export */ });\n/* harmony import */ var _avo_rule__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @avo/rule */ \"./src/avo/rule/index.js\");\n/* harmony import */ var _avo_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @avo/constants */ \"./src/avo/constants.js\");\n/* harmony import */ var _avo_misc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @avo/misc */ \"./src/avo/misc.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\nvar VICTORY_COUNTER_MAX = 500;\nvar RETURN_TO_HOME_MENU_COUNTER_MAX = 1500;\n/*\r\nThis Rule keeps track of scores and the victory condition.\r\n- If the Cat touches a Coin, the score will increase.\r\n- If a Vase is broken, the score will decrease.\r\n- If the Cat touches the Goal, the player wins the level.\r\n- If the player has won the level, play the victory message.\r\n- The player should always be able to see their score\r\n */\n\nvar CNY2022Victory = /*#__PURE__*/function (_Rule) {\n _inherits(CNY2022Victory, _Rule);\n\n var _super = _createSuper(CNY2022Victory);\n\n function CNY2022Victory(app) {\n var _this;\n\n _classCallCheck(this, CNY2022Victory);\n\n _this = _super.call(this, app);\n _this._type = 'cny2022-victory'; // Once the player has finished the level, show the victory message over a\n // period of time, and then pause the gameplay.\n\n _this.victory = false; // bool: has the player finished the level?\n\n _this.victoryCounter = 0; // Once the player has seen the victory message, wait a moment before\n // opening the home menu. (The home menu should only be opened automatically\n // ONCE.)\n\n _this.returnToHomeMenuCounter = 0;\n _this.returnedToHomeMenu = false; // bool: has the home menu been opened?\n\n _this.score = 0;\n return _this;\n }\n\n _createClass(CNY2022Victory, [{\n key: \"play\",\n value: function play(timeStep) {\n var app = this._app;\n\n _get(_getPrototypeOf(CNY2022Victory.prototype), \"play\", this).call(this, timeStep); // If the cat has reached the exit, run the victory phase.\n\n\n if (this.victory) {\n this.victoryCounter = Math.min(this.victoryCounter + timeStep, VICTORY_COUNTER_MAX); // Victory phase part 1: show the victory message over a period of time,\n // and after that pause the game.\n\n if (this.victoryCounter >= VICTORY_COUNTER_MAX) {\n app.paused = true;\n this.returnToHomeMenuCounter = Math.min(this.returnToHomeMenuCounter + timeStep, RETURN_TO_HOME_MENU_COUNTER_MAX); // Victory phase part 2: once the victory message has finished playing,\n // wait a moment and then open the home menu again. Note that the home\n // menu should only be opened automatically ONCE.\n\n if (this.returnToHomeMenuCounter >= RETURN_TO_HOME_MENU_COUNTER_MAX && !this.returnedToHomeMenu) {\n this.returnedToHomeMenu = true;\n app.setHomeMenu(true);\n }\n }\n }\n }\n /*\r\n Paint the score and/or victory screen\r\n - Paint the victory screen, if the player has won the level\r\n - Paint the score on the top layer\r\n */\n\n }, {\n key: \"paint\",\n value: function paint() {\n var layer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n if (layer !== 2) return;\n var app = this._app;\n var c2d = this._app.canvas2d; // Victory message\n\n if (this.victory) {\n var VICTORY_TEXT = 'YOU DID IT!';\n var VICTORY_X = app.canvasWidth / 2;\n var VICTORY_Y = app.canvasHeight / 2;\n var VICTORY_SIZE_START = 5;\n var VICTORY_SIZE_END = 10; // Paint victory text\n\n var progress = Math.min(this.victoryCounter / VICTORY_COUNTER_MAX, 1); // returns 0.0 to 1.0\n\n var smoothedProgress = (0,_avo_misc__WEBPACK_IMPORTED_MODULE_2__.easeOut)(progress);\n var textSize = (smoothedProgress * (VICTORY_SIZE_END - VICTORY_SIZE_START) + VICTORY_SIZE_START).toFixed(2);\n var blockOpacity = smoothedProgress * 0.5;\n c2d.fillStyle = \"rgba(128, 128, 128, \".concat(blockOpacity, \")\");\n c2d.fillRect(0, 0, app.canvasWidth, app.canvasHeight);\n c2d.font = \"\".concat(textSize, \"em Source Code Pro\");\n c2d.textAlign = 'center';\n c2d.textBaseline = 'middle';\n c2d.lineWidth = 8;\n c2d.strokeStyle = '#eee';\n c2d.strokeText(VICTORY_TEXT, VICTORY_X, VICTORY_Y);\n c2d.fillStyle = '#c44';\n c2d.fillText(VICTORY_TEXT, VICTORY_X, VICTORY_Y);\n } // Score\n\n\n var SCORE_TEXT = \"\".concat(this.score, \" points\");\n var SCORE_X = app.canvasWidth - _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE * 1;\n var SCORE_Y = app.canvasHeight - _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE * 0.1;\n c2d.font = \"3em sans-serif\";\n c2d.textAlign = 'right';\n c2d.textBaseline = 'bottom';\n c2d.lineWidth = 8;\n c2d.strokeStyle = '#eee';\n c2d.strokeText(SCORE_TEXT, SCORE_X, SCORE_Y);\n c2d.fillStyle = '#ca4';\n c2d.fillText(SCORE_TEXT, SCORE_X, SCORE_Y);\n }\n /*\r\n Triggers the victory for the level. Usually called by Goal Atom.\r\n */\n\n }, {\n key: \"triggerVictory\",\n value: function triggerVictory() {\n if (this.victory) return; // Don't trigger more than once\n\n this._app.levels.registerCNY2022Score(this.score);\n\n this.victory = true;\n }\n }]);\n\n return CNY2022Victory;\n}(_avo_rule__WEBPACK_IMPORTED_MODULE_0__.default);\n\n\n\n//# sourceURL=webpack://cny2022/./src/avo/rule/types/cny2022-victory.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ CNY2022Victory)\n/* harmony export */ });\n/* harmony import */ var _avo_rule__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @avo/rule */ \"./src/avo/rule/index.js\");\n/* harmony import */ var _avo_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @avo/constants */ \"./src/avo/constants.js\");\n/* harmony import */ var _avo_misc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @avo/misc */ \"./src/avo/misc.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\nvar VICTORY_COUNTER_MAX = 500;\nvar RETURN_TO_HOME_MENU_COUNTER_MAX = 1500;\n/*\r\nThis Rule keeps track of scores and the victory condition.\r\n- If the Cat touches a Coin, the score will increase.\r\n- If a Vase is broken, the score will decrease.\r\n- If the Cat touches the Goal, the player wins the level.\r\n- If the player has won the level, play the victory message.\r\n- The player should always be able to see their score\r\n */\n\nvar CNY2022Victory = /*#__PURE__*/function (_Rule) {\n _inherits(CNY2022Victory, _Rule);\n\n var _super = _createSuper(CNY2022Victory);\n\n function CNY2022Victory(app) {\n var _this;\n\n _classCallCheck(this, CNY2022Victory);\n\n _this = _super.call(this, app);\n _this._type = 'cny2022-victory'; // Once the player has finished the level, show the victory message over a\n // period of time, and then pause the gameplay.\n\n _this.victory = false; // bool: has the player finished the level?\n\n _this.victoryCounter = 0; // Once the player has seen the victory message, wait a moment before\n // opening the home menu. (The home menu should only be opened automatically\n // ONCE.)\n\n _this.returnToHomeMenuCounter = 0;\n _this.returnedToHomeMenu = false; // bool: has the home menu been opened?\n\n _this.score = 0;\n _this.victoryScore = 0;\n return _this;\n }\n\n _createClass(CNY2022Victory, [{\n key: \"play\",\n value: function play(timeStep) {\n var app = this._app;\n\n _get(_getPrototypeOf(CNY2022Victory.prototype), \"play\", this).call(this, timeStep); // If the cat has reached the exit, run the victory phase.\n\n\n if (this.victory) {\n this.victoryCounter = Math.min(this.victoryCounter + timeStep, VICTORY_COUNTER_MAX); // Victory phase part 1: show the victory message over a period of time,\n // and after that pause the game.\n\n if (this.victoryCounter >= VICTORY_COUNTER_MAX) {\n app.paused = true;\n this.returnToHomeMenuCounter = Math.min(this.returnToHomeMenuCounter + timeStep, RETURN_TO_HOME_MENU_COUNTER_MAX); // Victory phase part 2: once the victory message has finished playing,\n // wait a moment and then open the home menu again. Note that the home\n // menu should only be opened automatically ONCE.\n\n if (this.returnToHomeMenuCounter >= RETURN_TO_HOME_MENU_COUNTER_MAX && !this.returnedToHomeMenu) {\n this.returnedToHomeMenu = true;\n app.setHomeMenu(true);\n }\n }\n }\n }\n /*\r\n Paint the score and/or victory screen\r\n - Paint the victory screen, if the player has won the level\r\n - Paint the score on the top layer\r\n */\n\n }, {\n key: \"paint\",\n value: function paint() {\n var layer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n if (layer !== 2) return;\n var app = this._app;\n var c2d = this._app.canvas2d; // Victory message\n\n if (this.victory) {\n var VICTORY_TEXT = \"YOU DID IT!\";\n\n var _SCORE_TEXT = \"\".concat(this.victoryScore, \" point\").concat(this.victoryScore === 1 ? '' : 's');\n\n var VICTORY_X = app.canvasWidth / 2;\n var VICTORY_Y = app.canvasHeight / 2 - _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE * 0.5;\n\n var _SCORE_Y = app.canvasHeight / 2 + _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE * 0.5;\n\n var VICTORY_SIZE_START = 5;\n var VICTORY_SIZE_END = 10; // Paint victory text\n\n var progress = Math.min(this.victoryCounter / VICTORY_COUNTER_MAX, 1); // returns 0.0 to 1.0\n\n var smoothedProgress = (0,_avo_misc__WEBPACK_IMPORTED_MODULE_2__.easeOut)(progress);\n var textSize = (smoothedProgress * (VICTORY_SIZE_END - VICTORY_SIZE_START) + VICTORY_SIZE_START).toFixed(2);\n var blockOpacity = smoothedProgress * 0.5;\n c2d.fillStyle = \"rgba(128, 128, 128, \".concat(blockOpacity, \")\");\n c2d.fillRect(0, 0, app.canvasWidth, app.canvasHeight);\n c2d.font = \"\".concat(textSize, \"em sans-serif\");\n c2d.textAlign = 'center';\n c2d.lineWidth = 8;\n c2d.strokeStyle = '#eee';\n c2d.fillStyle = '#c44';\n c2d.textBaseline = 'bottom';\n c2d.strokeText(VICTORY_TEXT, VICTORY_X, VICTORY_Y);\n c2d.fillText(VICTORY_TEXT, VICTORY_X, VICTORY_Y);\n c2d.textBaseline = 'top';\n c2d.strokeText(_SCORE_TEXT, VICTORY_X, _SCORE_Y);\n c2d.fillText(_SCORE_TEXT, VICTORY_X, _SCORE_Y);\n } // Score\n\n\n var SCORE_TEXT = \"\".concat(this.score, \" points\");\n var SCORE_X = app.canvasWidth - _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE * 1;\n var SCORE_Y = app.canvasHeight - _avo_constants__WEBPACK_IMPORTED_MODULE_1__.TILE_SIZE * 0.1;\n c2d.font = \"3em sans-serif\";\n c2d.textAlign = 'right';\n c2d.textBaseline = 'bottom';\n c2d.lineWidth = 8;\n c2d.strokeStyle = '#eee';\n c2d.strokeText(SCORE_TEXT, SCORE_X, SCORE_Y);\n c2d.fillStyle = '#ca4';\n c2d.fillText(SCORE_TEXT, SCORE_X, SCORE_Y);\n }\n /*\r\n Triggers the victory for the level. Usually called by Goal Atom.\r\n */\n\n }, {\n key: \"triggerVictory\",\n value: function triggerVictory() {\n if (this.victory) return; // Don't trigger more than once\n\n this._app.levels.registerCNY2022Score(this.score);\n\n this.victory = true;\n this.victoryScore = this.score;\n }\n }]);\n\n return CNY2022Victory;\n}(_avo_rule__WEBPACK_IMPORTED_MODULE_0__.default);\n\n\n\n//# sourceURL=webpack://cny2022/./src/avo/rule/types/cny2022-victory.js?"); /***/ }), diff --git a/index.html b/index.html index 464b169..4b77812 100644 --- a/index.html +++ b/index.html @@ -12,17 +12,17 @@ - - + + - - + + - +