User prompt
Fix Bug: 'TypeError: villagerA.kiss is not a function' in this line: 'villagerA.kiss(villagerB);' Line Number: 331
User prompt
Fix
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 407
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'self.self.houses.push(house);' Line Number: 386
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 407
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'self.self.houses.push(house);' Line Number: 386
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 407
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'self.self.houses.push(house);' Line Number: 386
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 407
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'self.self.houses.push(house);' Line Number: 386
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 407
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 386
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 407
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 386
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 407
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'push')' in this line: 'this.workplaces.push(workplace);' Line Number: 398
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(newHouse);' Line Number: 389
User prompt
fix
User prompt
fix villager dont moving
User prompt
Fix Bug: 'Uncaught ReferenceError: ResourceDisplay is not defined' in this line: 'self.resourceDisplay = new ResourceDisplay(self.resources);' Line Number: 312
User prompt
Fix Bug: 'Uncaught ReferenceError: FramerateDisplay is not defined' in this line: 'self.framerateDisplay = new FramerateDisplay();' Line Number: 311
User prompt
fix
User prompt
make the background visible
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'push')' in this line: 'this.workplaces.push(workplace);' Line Number: 442
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 429
===================================================================
--- original.js
+++ change.js
@@ -177,8 +177,9 @@
var self = Container.call(this);
Villager.prototype.kiss = function (otherVillager) {};
self.gameResources = resources;
var villagerGraphics = self.createAsset('villager', 'Villager Graphics', .5, .5);
+ self.initializeVillager();
});
var EmployingWorkPlace = Container.expand(function () {
var self = Container.call(this);
var workplaceGraphics = self.createAsset('workplace', 'Workplace Graphics', .5, .5);
@@ -271,8 +272,28 @@
}
;
};
});
+Villager.prototype.initializeVillager = function () {
+ this.targetX = null;
+ this.targetY = null;
+ this.home = null;
+ this.workplace = null;
+ this.resourceType = null;
+ this.speed = 12;
+ this.directionX = 1;
+ this.directionY = 1;
+ this.carriedWood = 0;
+ this.carriedRock = 0;
+ this.carriedFood = 0;
+ this.tiredness = 0;
+ this.iq = 100;
+ this.currentAction = null;
+ this.decideNextAction = function () {};
+ this.canFallInLove = function (otherVillager) {
+ return true;
+ };
+};
Villager.prototype.isDoingSomething = function () {
return this.currentAction !== null;
};
Villager.prototype.initializePosition = function (x, y) {
@@ -341,8 +362,9 @@
self.timerText.x = 2048 - 500;
self.timerText.y = 2732;
LK.gui.topCenter.addChild(self.timerText);
self.startTime = Date.now();
+ self.villagers = [];
var market = new Market();
self.addChild(market);
var inn = new Inn();
self.addChild(inn);
@@ -377,28 +399,9 @@
};
}
Game.prototype.createVillager = function (x, y, isBaby) {
var villager = new Villager(this.resources);
- villager.x = x;
- villager.y = y;
- villager.targetX = null;
- villager.targetY = null;
- villager.home = null;
- villager.workplace = null;
- villager.resourceType = null;
- villager.speed = 12;
- villager.directionX = 1;
- villager.directionY = 1;
- villager.carriedWood = 0;
- villager.carriedRock = 0;
- villager.carriedFood = 0;
- villager.tiredness = 0;
- villager.iq = 100;
- villager.currentAction = null;
- villager.decideNextAction = function () {};
- villager.canFallInLove = function (otherVillager) {
- return true;
- };
+ villager.initializePosition(x, y);
if (isBaby) {
villager.scale.x = 0.5;
villager.scale.y = 0.5;
}
@@ -409,17 +412,22 @@
this.registerVillager(villager);
};
self.villagers = [];
self.houses = [];
- self.workplaces = [];
self.cloudLayer = new Container();
LK.stageContainer.addChild(self.cloudLayer);
self.clouds = [];
for (var i = 0; i < 5; i++) {
var cloud = new Cloud();
self.clouds.push(cloud);
self.cloudLayer.addChild(cloud);
}
+ self.addVillager(self.createVillager(1024, 1366));
+ for (var i = 0; i < 10; i++) {
+ self.addVillager(self.createVillager(Math.random() * 2048, Math.random() * 2732));
+ }
+ self.market = new Market();
+ self.addChild(self.market);
Game.prototype.createHouse = function (x, y) {
var house = new House();
house.x = x;
house.y = y;
@@ -428,11 +436,12 @@
Game.prototype.addHouse = function (house) {
this.addChild(house);
this.houses.push(house);
};
+ var houses = [];
var newHouse = self.createHouse(2048 / 2, 2732 / 2);
self.addHouse(newHouse);
- self.houses.push(newHouse);
+ houses.push(newHouse);
Game.prototype.createWorkplace = function () {
var workplace = new EmployingWorkPlace();
workplace.x = Math.random() * 2048;
workplace.y = Math.random() * 2732;
@@ -441,8 +450,9 @@
Game.prototype.addWorkplace = function (workplace) {
this.addChild(workplace);
this.workplaces.push(workplace);
};
+ self.workplaces = [];
var workplace = self.createWorkplace();
self.addWorkplace(workplace);
self.workplaces.push(workplace);
var house = new House();
@@ -457,14 +467,28 @@
self.addChild(workplace);
self.villagerCreationInterval = LK.setInterval(function () {
self.createAndAddVillagerIfPossible();
}, 10000);
+ LK.on('tick', function () {
+ var currentTime = Date.now();
+ var elapsedTime = Math.floor((currentTime - self.startTime) / 1000);
+ self.timerText.setText('Time: ' + elapsedTime);
+ self.updateResourceDisplay();
+ for (var i = 0; i < self.villagers.length; i++) {
+ self.villagers[i].update();
+ }
+ self.handleVillagersFallingInLove();
+ self.updateDayNightCycle();
+ for (var i = 0; i < self.clouds.length; i++) {
+ self.clouds[i].move();
+ }
+ });
self.updateDayNightCycle = function () {
var cycleDuration = 5000;
var time = (Date.now() - self.startTime) % cycleDuration;
var dayProgress = time / cycleDuration * 2 * Math.PI;
var alpha = 0.15 + 0.2 * Math.cos(dayProgress - Math.PI) * -0.5;
- LK.stageContainer.alpha = alpha;
+ LK.stageContainer.alpha = 1;
var hours = Math.floor(time / 3600000) % 24;
var minutes = Math.floor(time % 3600000 / 60000);
self.timeOfDayText.setText('Time of Day: ' + hours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0'));
};
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.