User prompt
Кнопка купить улучшение местности может заставить Пол подарок и ёлку
User prompt
Измени местность на Белый
User prompt
Стоимость пола 1кв² 1$
User prompt
Стоимость пола 1$
User prompt
Стоимость пола 1
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'self.terrainUpgrades.forEach(function (upgrade) {' Line Number: 152
User prompt
Кнопка Пол сравнить объект floor
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'self.terrainUpgrades.forEach(function (upgrade) {' Line Number: 153
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'self.terrainUpgrades.forEach(function (upgrade) {' Line Number: 152
User prompt
Стоимость пола 0$
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'self.terrainUpgrades.forEach(function (upgrade) {' Line Number: 153
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'self.terrainUpgrades.forEach(function (upgrade) {' Line Number: 152
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'self.terrainUpgrades.forEach(function (upgrade) {' Line Number: 151
User prompt
Сделай кнопку которая сравнить Пол под объектами а потом и про сто
User prompt
Сделай дефолтный Белый Пол
User prompt
Сделай чёрный белым
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')' in this line: 'FoxBehavior.prototype.onFoxClicked = function () {' Line Number: 2
var foxTimeout;
var Floor = Container.expand(function () {
var self = Container.call(this);
var floorGraphics = self.createAsset('floor', 'Floor Graphics', 0, 1);
floorGraphics.tint = 0xFFFFFF;
floorGraphics.width = LK.stage.width;
floorGraphics.height = LK.stage.height;
self.y = LK.stage.height - self.height;
self.update = function () {};
});
var Guard = Container.expand(function () {
var self = Container.call(this);
self.setLocation('North Pole');
self.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('engineGift', 'Engine 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);
self.factoryGraphics = self.createAsset('factory', 'Factory Graphics', .5, .5);
self.productionValue = 5;
self.upgradeCost = 1000;
self.produceGift = function () {
LK.setInterval(function () {
var earnedMoney = self.productionValue;
LK.setScore(LK.getScore() + earnedMoney);
var earnedMoneyTxt = new Text2('+' + earnedMoney, {
size: 100,
fill: "#ffffff"
});
earnedMoneyTxt.x = self.x;
earnedMoneyTxt.y = self.y - 100;
earnedMoneyTxt.anchor.set(0.5, 0.5);
LK.gui.addChild(earnedMoneyTxt);
var moveUpwards = function () {
earnedMoneyTxt.y -= 2;
if (earnedMoneyTxt.y < self.y - 300) {
earnedMoneyTxt.destroy();
}
};
LK.on('tick', moveUpwards);
LK.setTimeout(function () {
LK.off('tick', moveUpwards);
if (earnedMoneyTxt.parent) {
earnedMoneyTxt.destroy();
}
}, 3000);
}, 5000);
};
self.terrainUpgrades = [];
self.upgradeTerrain = function () {
self.terrainUpgradeCost = self.terrainUpgradeCost || 50;
if (LK.getScore() >= self.terrainUpgradeCost) {
LK.setScore(LK.getScore() - self.terrainUpgradeCost);
var newUpgrade;
var assetId, assetDescription;
if (Math.random() < 0.5) {
assetId = 'christmasTree';
assetDescription = 'Christmas Tree Graphics';
} else {
assetId = 'giftDecoration';
assetDescription = 'Gift Decoration Graphics';
}
newUpgrade = new FloorItem(assetId, assetDescription);
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 () {
Game.prototype.upgradeFactory = function (factory) {
if (LK.getScore() >= factory.upgradeCost) {
LK.setScore(LK.getScore() - factory.upgradeCost);
factory.productionValue *= 2;
factory.upgradeCost *= 2;
}
};
var self = Container.call(this);
var floor = self.addChild(new Floor());
floor.width = LK.stage.width;
floor.height = LK.stage.height;
var gifts = [];
var factories = [];
var santa = self.addChild(new Santa());
santa.x = 2048 / 2;
var floor = self.addChild(new Floor());
santa.y = floor.y - santa.height / 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.width;
purchaseGuardButton.y = 2732 - purchaseGuardButton.height / 2;
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: "#ffffff"
});
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');
});
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,51 +1,9 @@
var foxTimeout;
-FoxBehavior.prototype.onFoxClicked = 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 - this.x, 2) + Math.pow(prev.y - this.y, 2));
- var currDistance = Math.sqrt(Math.pow(curr.x - this.x, 2) + Math.pow(curr.y - this.y, 2));
- return prevDistance < currDistance ? prev : curr;
- });
- closestGuard.catchFox(this);
- } else {
- LK.clearTimeout(foxTimeout);
- this.destroy();
- }
-};
-FoxBehavior.prototype.moveFox = function () {
- this.y += this.speed;
-};
-FoxBehavior.prototype.stealMoney = function () {
- if (LK.getScore() >= 100) {
- LK.setScore(LK.getScore() - 100);
- }
- this.destroy();
-};
-var FoxBehavior = Container.expand(function (speedIncrement) {
- var self = Container.call(this);
- var foxGraphics = self.createAsset('fox', 'Fox Graphics', .5, .5);
- self.speed = 1 + (speedIncrement || 0.5);
- self.interactive = true;
- self.buttonMode = true;
- self.on('down', self.onFoxClicked);
- self.update = self.moveFox;
-});
-var FoxBehavior = Container.expand(function (speedIncrement) {
- var self = Container.call(this);
- var foxGraphics = self.createAsset('fox', 'Fox Graphics', .5, .5);
- self.speed = 1 + (speedIncrement || 0.5);
- self.interactive = true;
- self.buttonMode = true;
- self.on('down', self.onFoxClicked);
- self.update = self.moveFox;
-});
var Floor = Container.expand(function () {
var self = Container.call(this);
var floorGraphics = self.createAsset('floor', 'Floor Graphics', 0, 1);
+ floorGraphics.tint = 0xFFFFFF;
floorGraphics.width = LK.stage.width;
floorGraphics.height = LK.stage.height;
self.y = LK.stage.height - self.height;
self.update = function () {};
@@ -64,16 +22,40 @@
}
};
self.update = function () {};
});
-var FoxBehavior = Container.expand(function (speedIncrement) {
+var Fox = Container.expand(function (speedIncrement) {
var self = Container.call(this);
var foxGraphics = self.createAsset('fox', 'Fox Graphics', .5, .5);
- self.speed = 1 + (speedIncrement || 0.5);
+ self.speed = 1;
self.interactive = true;
self.buttonMode = true;
- self.on('down', self.onFoxClicked);
- self.update = self.moveFox;
+ 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);
Фабрика 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.