User prompt
Кнопка покупки охранника рядом с кнопка украшения
User prompt
Можно покупать охранников они стоят 1000$ охранники ловят 10 лис и уходят
User prompt
Fix Bug: 'ReferenceError: foxTimeout is not defined' in this line: 'LK.clearTimeout(foxTimeout);' Line Number: 8
User prompt
Скорость лис очень маленькая но каждый раз она возрастает
User prompt
Fix Bug: 'TypeError: self.upgradeFactory is not a function' in this line: 'self.upgradeFactory();' Line Number: 157
User prompt
Каждый раз как игрок зарабатывает 100$ то приходит лис если на него не нажать то он сворует 100$
User prompt
Если у игрока мало денег то появляется надпись нет денег на 5 секунд
User prompt
Прокачка местности стоит 50$ и её цена вырастает в два раза каждую покупку
User prompt
Кнопка прокачки местности около кнопки покупки фабрика
User prompt
Fix Bug: 'TypeError: self.upgradeFactory is not a function' in this line: 'self.upgradeFactory();' Line Number: 103
User prompt
Добавь прокачку местности добавляются рождественские ёлки и подарки
User prompt
Fix Bug: 'TypeError: self.upgradeFactory is not a function' in this line: 'self.upgradeFactory();' Line Number: 76
User prompt
Кнопка прокачки находиться около фабрики
User prompt
Первая фабрика при нажатие даёт5$
User prompt
Одна фабрика даёт 5$ в секунде
User prompt
Fix Bug: 'TypeError: self.upgradeFactory is not a function' in this line: 'self.upgradeFactory();' Line Number: 76
User prompt
Fix Bug: 'TypeError: self.upgradeFactory is not a function' in this line: 'self.upgradeFactory();' Line Number: 75
User prompt
Fix Bug: 'ReferenceError: factoryGraphics is not defined' in this line: 'upgradeButton.y = self.y + factoryGraphics.height / 2 + 20;' Line Number: 72
User prompt
Фабрики можно прокачивать если нажать на фабрику то появиться кнопка прокачки прокачка стоит 1000$ при прокачке фабрика начинает давать 10$
User prompt
Стоимость одной фабрики 100$
User prompt
При покупке одной фабрике надо нажать на экран и там появиться фабрика дающая 5$ в секунду
User prompt
Одна фабрика стоит 100$
User prompt
Добавь снизу кнопку покупки фабрики
User prompt
Сделай так чтоб один завод приносил по 5$
Initial prompt
Санта тайкон
var foxTimeout;
var Guard = Container.expand(function () {
var self = Container.call(this);
var guardGraphics = self.createAsset('guard', 'Guard Graphics', .5, .5);
self.foxesCaught = 0;
self.catchLimit = 10;
self.catchFox = function (fox) {
fox.destroy();
self.foxesCaught++;
if (self.foxesCaught >= self.catchLimit) {
self.destroy();
}
};
self.update = function () {};
});
var Fox = Container.expand(function (speedIncrement) {
var self = Container.call(this);
var foxGraphics = self.createAsset('fox', 'Fox Graphics', .5, .5);
self.speed = 1;
self.interactive = true;
self.buttonMode = true;
self.on('down', function () {
var guards = LK.stage.children.filter(function (child) {
return child instanceof Guard;
});
if (guards.length > 0) {
var closestGuard = guards.reduce(function (prev, curr) {
var prevDistance = Math.sqrt(Math.pow(prev.x - self.x, 2) + Math.pow(prev.y - self.y, 2));
var currDistance = Math.sqrt(Math.pow(curr.x - self.x, 2) + Math.pow(curr.y - self.y, 2));
return prevDistance < currDistance ? prev : curr;
});
closestGuard.catchFox(self);
} else {
LK.clearTimeout(foxTimeout);
self.destroy();
}
});
self.stealMoney = function () {
if (LK.getScore() >= 100) {
LK.setScore(LK.getScore() - 100);
}
self.destroy();
};
self.update = function () {
self.y += self.speed;
};
Fox.speedIncrement = speedIncrement || 0.5;
});
var GiftDecoration = Container.expand(function () {
var self = Container.call(this);
var giftDecorationGraphics = self.createAsset('giftDecoration', 'Gift Decoration Graphics', .5, .5);
self.update = function () {};
});
var ChristmasTree = Container.expand(function () {
var self = Container.call(this);
var treeGraphics = self.createAsset('christmasTree', 'Christmas Tree Graphics', .5, .5);
self.update = function () {};
});
var Gift = Container.expand(function () {
var self = Container.call(this);
var giftGraphics = self.createAsset('gift', 'Gift Graphics', .5, .5);
self.move = function () {};
self.update = function () {};
});
var Santa = Container.expand(function () {
var self = Container.call(this);
var santaGraphics = self.createAsset('santa', 'Santa Graphics', .5, .5);
self.move = function () {};
self.update = function () {};
});
var Factory = Container.expand(function () {
var self = Container.call(this);
var factoryGraphics = self.createAsset('factory', 'Factory Graphics', .5, .5);
self.productionValue = 5;
self.upgradeCost = 1000;
self.produceGift = function () {
LK.setInterval(function () {
LK.setScore(LK.getScore() + self.productionValue);
}, 1000);
};
self.upgradeFactory = function () {
if (LK.getScore() >= self.upgradeCost) {
LK.setScore(LK.getScore() - self.upgradeCost);
self.productionValue *= 2;
self.upgradeCost *= 2;
}
};
self.upgradeFactory = function () {
if (LK.getScore() >= self.upgradeCost) {
LK.setScore(LK.getScore() - self.upgradeCost);
self.productionValue *= 2;
self.upgradeCost *= 2;
}
};
self.terrainUpgrades = [];
self.upgradeTerrain = function () {
self.terrainUpgradeCost = self.terrainUpgradeCost || 50;
if (LK.getScore() >= self.terrainUpgradeCost) {
LK.setScore(LK.getScore() - self.terrainUpgradeCost);
var newUpgrade;
if (Math.random() < 0.5) {
newUpgrade = new ChristmasTree();
} else {
newUpgrade = new GiftDecoration();
}
newUpgrade.x = Math.random() * 2048;
newUpgrade.y = Math.random() * 2732;
self.terrainUpgrades.push(newUpgrade);
LK.stage.addChild(newUpgrade);
self.terrainUpgradeCost *= 2;
}
};
self.update = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var gifts = [];
var factories = [];
var santa = self.addChild(new Santa());
santa.x = 2048 / 2;
santa.y = 2732 / 2;
var factory = self.addChild(new Factory());
factory.x = 2048 / 4;
factory.y = 2732 / 4;
factories.push(factory);
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
var purchaseFactoryButton = self.createAsset('purchaseFactoryButton', 'Purchase Factory Button', 0.5, 1);
var purchaseGuardButton = self.createAsset('purchaseGuardButton', 'Purchase Guard Button', 0.5, 1);
purchaseGuardButton.x = 2048 / 2;
purchaseGuardButton.y = 2732 - purchaseGuardButton.height * 1.5;
self.addChild(purchaseGuardButton);
purchaseGuardButton.on('down', function () {
var guardCost = 1000;
if (LK.getScore() >= guardCost) {
LK.setScore(LK.getScore() - guardCost);
var newGuard = self.addChild(new Guard());
newGuard.x = Math.random() * 2048;
newGuard.y = Math.random() * 2732;
}
});
var upgradeTerrainButton = self.createAsset('upgradeTerrainButton', 'Upgrade Terrain Button', 0.5, 1);
purchaseFactoryButton.x = 2048 / 2 - purchaseFactoryButton.width;
purchaseFactoryButton.y = 2732 - purchaseFactoryButton.height / 2;
upgradeTerrainButton.x = 2048 / 2 + upgradeTerrainButton.width;
upgradeTerrainButton.y = 2732 - upgradeTerrainButton.height / 2;
self.addChild(purchaseFactoryButton);
self.addChild(upgradeTerrainButton);
purchaseFactoryButton.on('down', function () {
var factoryCost = 100;
if (LK.getScore() >= factoryCost) {
LK.setScore(LK.getScore() - factoryCost);
var newFactory = self.addChild(new Factory());
newFactory.x = 2048 / 4;
newFactory.y = 2732 / 4 * factories.length;
factories.push(newFactory);
newFactory.produceGift();
scoreTxt.setText(LK.getScore());
} else {
var noMoneyTxt = new Text2('No Money', {
size: 100,
fill: "#ff0000"
});
noMoneyTxt.x = LK.stage.width / 2;
noMoneyTxt.y = LK.stage.height / 2;
noMoneyTxt.anchor.set(0.5, 0.5);
LK.gui.addChild(noMoneyTxt);
LK.setTimeout(function () {
noMoneyTxt.destroy();
}, 5000);
}
});
upgradeTerrainButton.on('down', function () {
factory.upgradeTerrain();
scoreTxt.setText(LK.getScore());
});
LK.setScore(5);
scoreTxt.setText(0);
var lastScore = 0;
var foxTimeout;
LK.on('tick', function () {
var currentScore = LK.getScore();
if (currentScore >= lastScore + 100) {
lastScore += 100;
var fox = new Fox(Fox.speedIncrement);
fox.speed += Fox.speedIncrement;
fox.x = Math.random() * 2048;
fox.y = Math.random() * 2732;
self.addChild(fox);
foxTimeout = LK.setTimeout(function () {
fox.stealMoney();
scoreTxt.setText(LK.getScore());
}, 5000);
}
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
santa.on('down', function (obj) {
console.log('Santa was pressed');
});
factory.on('down', function (obj) {
var upgradeButton = self.createAsset('upgradeButton', 'Upgrade Factory Button', 0.5, 1);
upgradeButton.x = factory.x + factory.getChildAt(0).width / 2 + 20;
upgradeButton.y = factory.y;
self.addChild(upgradeButton);
upgradeButton.on('down', function () {
self.upgradeFactory();
scoreTxt.setText(LK.getScore());
upgradeButton.destroy();
});
factory.produceGift();
scoreTxt.setText(LK.getScore());
});
LK.on('tick', function () {
santa.update();
for (var i = 0; i < factories.length; i++) {
factories[i].update();
}
for (var i = 0; i < gifts.length; i++) {
gifts[i].move();
if (gifts[i].y < -50) {
gifts[i].destroy();
gifts.splice(i, 1);
}
}
});
});
===================================================================
--- original.js
+++ change.js
@@ -1,14 +1,40 @@
var foxTimeout;
+var Guard = Container.expand(function () {
+ var self = Container.call(this);
+ var guardGraphics = self.createAsset('guard', 'Guard Graphics', .5, .5);
+ self.foxesCaught = 0;
+ self.catchLimit = 10;
+ self.catchFox = function (fox) {
+ fox.destroy();
+ self.foxesCaught++;
+ if (self.foxesCaught >= self.catchLimit) {
+ self.destroy();
+ }
+ };
+ self.update = function () {};
+});
var Fox = Container.expand(function (speedIncrement) {
var self = Container.call(this);
var foxGraphics = self.createAsset('fox', 'Fox Graphics', .5, .5);
self.speed = 1;
self.interactive = true;
self.buttonMode = true;
self.on('down', function () {
- LK.clearTimeout(foxTimeout);
- self.destroy();
+ var guards = LK.stage.children.filter(function (child) {
+ return child instanceof Guard;
+ });
+ if (guards.length > 0) {
+ var closestGuard = guards.reduce(function (prev, curr) {
+ var prevDistance = Math.sqrt(Math.pow(prev.x - self.x, 2) + Math.pow(prev.y - self.y, 2));
+ var currDistance = Math.sqrt(Math.pow(curr.x - self.x, 2) + Math.pow(curr.y - self.y, 2));
+ return prevDistance < currDistance ? prev : curr;
+ });
+ closestGuard.catchFox(self);
+ } else {
+ LK.clearTimeout(foxTimeout);
+ self.destroy();
+ }
});
self.stealMoney = function () {
if (LK.getScore() >= 100) {
LK.setScore(LK.getScore() - 100);
@@ -101,8 +127,21 @@
size: 150,
fill: "#ffffff"
});
var purchaseFactoryButton = self.createAsset('purchaseFactoryButton', 'Purchase Factory Button', 0.5, 1);
+ var purchaseGuardButton = self.createAsset('purchaseGuardButton', 'Purchase Guard Button', 0.5, 1);
+ purchaseGuardButton.x = 2048 / 2;
+ purchaseGuardButton.y = 2732 - purchaseGuardButton.height * 1.5;
+ self.addChild(purchaseGuardButton);
+ purchaseGuardButton.on('down', function () {
+ var guardCost = 1000;
+ if (LK.getScore() >= guardCost) {
+ LK.setScore(LK.getScore() - guardCost);
+ var newGuard = self.addChild(new Guard());
+ newGuard.x = Math.random() * 2048;
+ newGuard.y = Math.random() * 2732;
+ }
+ });
var upgradeTerrainButton = self.createAsset('upgradeTerrainButton', 'Upgrade Terrain Button', 0.5, 1);
purchaseFactoryButton.x = 2048 / 2 - purchaseFactoryButton.width;
purchaseFactoryButton.y = 2732 - purchaseFactoryButton.height / 2;
upgradeTerrainButton.x = 2048 / 2 + upgradeTerrainButton.width;
Фабрика Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Лис в новогодний шапке Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Рождественская ёлка Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Стрелочка в верх Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Покупка Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Санта Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Разноцветный подарок Подарок Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.