User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'graphics')' in this line: 'self.graphics.isTeaching = false;' Line Number: 110
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'isTeaching')' in this line: 'self.isTeaching = false;' Line Number: 110
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'isTeaching')' in this line: 'self.isTeaching = false;' Line Number: 110
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'isTeaching')' in this line: 'self.isTeaching = true;' Line Number: 110
User prompt
add one type of each building at the begining
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'isTeaching')' in this line: 'self.isTeaching = false;' Line Number: 110
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'isTeaching')' in this line: 'self.isTeaching = false;' Line Number: 110
User prompt
add one type of each batiment at the begining
User prompt
add 5 nesw functionality
User prompt
improve villager behavior and movement base on their behavior
User prompt
add 4 new functionality
User prompt
add 3 new functionality
User prompt
add 2 new functionality
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 122
User prompt
improve 2 time
User prompt
Add a day cycle in 24 hours where every hours take one second
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var Farmer = Villager.expand(function (resources, iq) {' Line Number: 282
User prompt
Improve villager behavior
User prompt
Improve behavior
User prompt
Fix Bug: 'Uncaught ReferenceError: House is not defined' in this line: 'var house = new House();' Line Number: 788
User prompt
Fix Bug: 'Uncaught ReferenceError: House is not defined' in this line: 'var home = new House();' Line Number: 764
===================================================================
--- original.js
+++ change.js
@@ -1,20 +1,4 @@
-var Crop = Container.expand(function (type) {
- var self = Container.call(this);
- self.type = type;
- self.cropGraphics = self.createAsset(type.toLowerCase(), type + ' Crop Graphics', 0.5, 0.5);
- self.addChild(self.cropGraphics);
- self.growth = 0;
- self.yield = 10;
- self.isRipe = function () {
- return self.growth >= 100;
- };
- self.harvest = function () {
- if (self.isRipe()) {
- self.parent.removeChild(self);
- }
- };
-});
var Guard = Container.expand(function () {
var self = Container.call(this);
self.guardGraphics = self.createAsset('guard', 'Guard Graphics', 0.5, 0.5);
self.addChild(self.guardGraphics);
@@ -25,12 +9,11 @@
var patrolY = Math.random() * 2732;
self.moveTo(patrolX, patrolY, self.speed);
};
self.speed = 2;
- self.patrol = function () {
- LK.setTimeout(self.patrolArea, 5000);
- };
- LK.on('tick', self.patrol);
+ LK.on('tick', function () {
+ self.patrolArea();
+ });
});
var Brewery = Container.expand(function () {
var self = Container.call(this);
self.breweryGraphics = self.createAsset('brewery', 'Brewery Graphics', 0.5, 0.5);
@@ -225,11 +208,28 @@
villager.tiredness -= 5;
if (villager.tiredness < 0) villager.tiredness = 0;
};
});
-var Innkeeper = Container.expand(function (inn) {
+var Inn = Container.expand(function () {
var self = Container.call(this);
- self.inn = inn;
+ self.innGraphics = self.createAsset('inn', 'Inn Graphics', 0.5, 0.5);
+ self.initializeRandomPosition = function () {
+ do {
+ self.x = Math.random() * (2048 - self.innGraphics.width) + self.innGraphics.width / 2;
+ self.y = Math.random() * (2732 - self.innGraphics.height) + self.innGraphics.height / 2;
+ } while (self.parent && self.checkOverlapWithOtherBuildings());
+ };
+ self.checkOverlapWithOtherBuildings = function () {
+ var buildings = self.parent.children.filter(function (child) {
+ return child !== self && child instanceof Building;
+ });
+ return buildings.some(function (building) {
+ var dx = self.x - building.x;
+ var dy = self.y - building.y;
+ return Math.sqrt(dx * dx + dy * dy) < 300 + Math.max(self.innGraphics.width, self.innGraphics.height) / 2 + Math.max(building.width, building.height) / 2;
+ });
+ };
+ self.initializeRandomPosition();
self.isOccupiable = true;
self.occupy = function (villager) {
if (!self.isOccupiable) return;
self.isOccupiable = false;
@@ -364,23 +364,8 @@
self.tiredness = 0;
self.state = 'idle';
self.home = null;
self.workplace = null;
- self.farmingPower = 5;
- self.plant = function (crop) {
- if (crop instanceof Crop) {
- crop.growth += self.farmingPower;
- if (crop.growth >= 100) {
- crop.harvest();
- }
- }
- };
- self.harvest = function (crop) {
- if (crop instanceof Crop && crop.isRipe()) {
- self.gameResources.food.amount += crop.yield;
- crop.destroy();
- }
- };
});
var Blacksmith = Container.expand(function (resources) {
var self = Container.call(this);
self.gameResources = resources;
@@ -435,18 +420,33 @@
}
return villager;
};
});
-var Baker = Container.expand(function (resources) {
+var Bakery = Container.expand(function () {
var self = Container.call(this);
- self.gameResources = resources;
- self.bakingPower = 5;
- self.bakeBread = function () {
- if (self.gameResources.wood.amount >= 5 && self.gameResources.food.amount >= 2) {
- self.gameResources.wood.amount -= 5;
- self.gameResources.food.amount -= 2;
- self.gameResources.food.amount += self.bakingPower;
- if (self.gameResources.food.amount > 100) self.gameResources.food.amount = 100;
+ self.bakeryGraphics = self.createAsset('bakery', 'Bakery Graphics', 0.5, 0.5);
+ self.initializeRandomPosition = function () {
+ do {
+ self.x = Math.random() * (2048 - self.bakeryGraphics.width) + self.bakeryGraphics.width / 2;
+ self.y = Math.random() * (2732 - self.bakeryGraphics.height) + self.bakeryGraphics.height / 2;
+ } while (self.parent && self.checkOverlapWithOtherBuildings());
+ };
+ self.checkOverlapWithOtherBuildings = function () {
+ var buildings = self.parent.children.filter(function (child) {
+ return child !== self && child instanceof Building;
+ });
+ return buildings.some(function (building) {
+ var dx = self.x - building.x;
+ var dy = self.y - building.y;
+ return Math.sqrt(dx * dx + dy * dy) < 300 + Math.max(self.bakeryGraphics.width, self.bakeryGraphics.height) / 2 + Math.max(building.width, building.height) / 2;
+ });
+ };
+ self.bakeBread = function (villager) {
+ if (villager.gameResources.wood.amount >= 5 && villager.gameResources.food.amount >= 2) {
+ villager.gameResources.wood.amount -= 5;
+ villager.gameResources.food.amount -= 2;
+ villager.gameResources.food.amount += 10;
+ if (villager.gameResources.food.amount > 100) villager.gameResources.food.amount = 100;
}
};
});
var Cloud = Container.expand(function () {
@@ -775,13 +775,43 @@
self.timerText.y = 2732;
LK.gui.topCenter.addChild(self.timerText);
self.startTime = Date.now();
var inn = new Inn();
+ inn.x = 100;
+ inn.y = 100;
self.addChild(inn);
var bakery = new Bakery();
+ bakery.x = 300;
+ bakery.y = 100;
self.addChild(bakery);
var well = new Well();
+ well.x = 500;
+ well.y = 100;
self.addChild(well);
+ var brewery = new Brewery();
+ brewery.x = 700;
+ brewery.y = 100;
+ self.addChild(brewery);
+ var school = new School();
+ school.x = 900;
+ school.y = 100;
+ self.addChild(school);
+ var market = new Market();
+ market.x = 1100;
+ market.y = 100;
+ self.addChild(market);
+ var home = new Home();
+ home.x = 1300;
+ home.y = 100;
+ self.addChild(home);
+ var gardener = new Gardener();
+ gardener.x = 1500;
+ gardener.y = 100;
+ self.addChild(gardener);
+ var festival = new Festival();
+ festival.x = 1700;
+ festival.y = 100;
+ self.addChild(festival);
self.resources = createResources();
self.resourceDisplay = new ResourceDisplay(self.resources);
LK.gui.topLeft.addChild(self.resourceDisplay);
Game.prototype.handleVillagersFallingInLove = function () {
A background of a paysage with plain and without tree or montainbut no water see from the top in the air 100m by 100m Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
One human medieval villager in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a house in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree a rock and crambery in a RTS style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A heart comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cloud in a comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A market in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An Inn in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An school in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An bakery in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A well in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An apple in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A rock in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A home in a RTS and fantasy style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A brewery in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lumberjack in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a marketplace in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a festival in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.