UNPKG

snake-cli-ts

Version:
27 lines (26 loc) 881 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Food = (function () { function Food(foodSettings, foodManager) { this.foodManager = foodManager; this.point = foodSettings.point; this.symbol = foodSettings.symbol; this.onEat = foodSettings.onEat; } Food.prototype.use = function () { var _a; var useDefault = true; (_a = this.onEat) === null || _a === void 0 ? void 0 : _a.call(this, { preventDefault: function () { useDefault = false; }, }); if (useDefault) { this.foodManager.remove(this.point.x, this.point.y); this.foodManager.add(); this.foodManager.game.snake.eat(this.point.x, this.point.y); } }; return Food; }()); exports.default = Food;