User prompt
improve
User prompt
make all villager work
User prompt
all villager have to work
User prompt
fix villager not moving
User prompt
fix villager not going to work
User prompt
fix villager not moving
User prompt
send villager to work
User prompt
check bug
User prompt
improve villager IQ and check if theire doing somtehing
User prompt
Fix Bug: 'Uncaught ReferenceError: resourceCollector is not defined' in this line: 'self.resourceCollector = resourceCollector;' Line Number: 37
User prompt
Fix Bug: 'Uncaught ReferenceError: resourceCollector is not defined' in this line: 'var self = Container.call(this, resourceCollector);' Line Number: 36
User prompt
optimise
User prompt
Fix Bug: 'TypeError: self.calculateBuildUtility is not a function' in this line: 'return this.carriedWood > 0 || this.carriedRock > 0 || this.carriedFood > 0;' Line Number: 45
User prompt
add two new fonctionality
User prompt
add one new fonctionality
User prompt
improve villager IQ
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'x')' in this line: 'self.moveTowards(self.home.x, self.home.y);' Line Number: 102
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'x')' in this line: 'self.moveTowards(self.home.x, self.home.y);' Line Number: 102
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'x')' in this line: 'self.moveTowards(self.workplace.x, self.workplace.y);' Line Number: 91
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'x')' in this line: 'self.moveTowards(self.workplace.x, self.workplace.y);' Line Number: 91
User prompt
create two villager in vegining
User prompt
Fix Bug: 'TypeError: this.handleVillagersFallingInLove is not a function' in this line: 'this.handleVillagersFallingInLove(villagers, houses, resources);' Line Number: 249
User prompt
Fix Bug: 'TypeError: this.handleVillagersFallingInLove is not a function' in this line: 'this.handleVillagersFallingInLove(villagers, houses, resources);' Line Number: 249
User prompt
Fix Bug: 'TypeError: this.handleVillagersFallingInLove is not a function' in this line: 'this.handleVillagersFallingInLove(villagers, houses, resources);' Line Number: 249
User prompt
Fix Bug: 'TypeError: this.handleVillagersFallingInLove is not a function' in this line: 'this.handleVillagersFallingInLove(villagers, houses, resources);' Line Number: 249
var HouseBuilder = Container.expand(function () {
var self = Container.call(this);
self.build = function (villager) {
var newHouse = new House();
newHouse.x = Math.random() * 2048;
newHouse.y = Math.random() * 2732;
villager.parent.addChild(newHouse);
villager.state = 'atHome';
villager.home = newHouse;
LK.setTimeout(function () {
villager.moveTo(villager.workplace.x, villager.workplace.y, 'goingToWork');
}, 5000);
};
});
var ResourceCollector = Container.expand(function () {
var self = Container.call(this);
self.collect = function (villager) {
if (villager.workplace && villager.workplace.resourceType && villager.state === 'working') {
var resource = villager.workplace.resourceType;
resource.amount += 1;
villager.moveTo(villager.home.x, villager.home.y, 'goingHome');
}
};
});
var Resource = Container.expand(function (type, amount) {
var self = Container.call(this);
self.type = type;
self.amount = amount;
var resourceGraphics = self.createAsset(type.toLowerCase() + 'Image', type + ' Image', .5, .5);
});
var Tree = Container.expand(function () {
var self = Container.call(this);
var treeGraphics = self.createAsset('treeImage', 'Tree Image', .5, .5);
});
var Villager = Container.expand(function (resources) {
var self = Container.call(this);
Villager.prototype.canFallInLove = function (otherVillager) {
return this.state === 'atHome' && otherVillager.state === 'atHome' && !this.partner && !otherVillager.partner;
};
self.gameResources = resources;
self.buildHouse = function () {
if (self.gameResources.wood.amount >= 200 && self.gameResources.rock.amount >= 200 && self.gameResources.food.amount >= 200) {
self.gameResources.wood.amount -= 200;
self.gameResources.rock.amount -= 200;
self.gameResources.food.amount -= 200;
var houseBuilder = new HouseBuilder();
houseBuilder.build(self);
}
};
self.collectResource = function () {
var resourceCollector = new ResourceCollector();
resourceCollector.collect(self);
};
self.arriveHome = function () {
self.state = 'atHome';
self.home.occupy(self);
};
self.startWorking = function () {
self.state = 'working';
self.workplace.employ(self);
};
var villagerGraphics = self.createAsset('villager', 'Villager Graphics', .5, .5);
self.targetX = null;
self.targetY = null;
self.home = null;
self.workplace = null;
self.resourceType = null;
self.state = Math.random() > 0.5 ? 'goingToWork' : 'buildingHouse';
self.speed = 12;
self.moveTo = function (x, y, state) {
self.targetX = x;
self.targetY = y;
if (state) self.state = state;
};
self.update = function () {
var utility = {
work: self.calculateWorkUtility(),
home: self.calculateHomeUtility(),
build: self.calculateBuildUtility()
};
var highestUtility = Math.max(utility.work, utility.home, utility.build);
if (highestUtility === utility.work) {
self.state = 'goingToWork';
} else if (highestUtility === utility.home) {
self.state = 'goingHome';
} else if (highestUtility === utility.build) {
self.state = 'buildingHouse';
}
switch (self.state) {
case 'goingToWork':
self.moveTowards(self.workplace.x, self.workplace.y);
if (self.intersects(self.workplace)) {
self.startWorking();
}
break;
case 'working':
self.collectResource();
break;
case 'goingHome':
self.moveTowards(self.home.x, self.home.y);
if (self.intersects(self.home)) {
self.arriveHome();
}
break;
case 'atHome':
break;
case 'buildingHouse':
self.buildHouse();
break;
}
};
self.calculateWorkUtility = function () {
return Math.random();
};
self.calculateHomeUtility = function () {
return Math.random();
};
self.calculateBuildUtility = function () {
return Math.random();
};
self.moveTowards = function (x, y) {
if (self.x !== x || self.y !== y) {
self.moveTo(x, y);
self.moveTowardsTarget();
}
};
self.moveTowardsTarget = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 1) {
self.x = self.targetX;
self.y = self.targetY;
self.targetX = null;
self.targetY = null;
} else {
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
}
};
});
var OccupiableHouse = Container.expand(function () {
var self = Container.call(this);
var houseGraphics = self.createAsset('house', 'House Graphics', .5, .5);
self.isOccupiable = true;
self.occupy = function (villager) {
LK.setTimeout(function () {
villager.moveTo(villager.workplace.x, villager.workplace.y, 'goingToWork');
}, 5000);
};
});
var EmployingWorkPlace = Container.expand(function () {
var self = Container.call(this);
var workplaceGraphics = self.createAsset('workplace', 'Workplace Graphics', .5, .5);
self.isEmploying = true;
self.employ = function (villager) {
LK.setTimeout(function () {
villager.collectResource();
}, 5000);
};
});
var House = Container.expand(function () {
var self = Container.call(this);
var houseGraphics = self.createAsset('house', 'House Graphics', .5, .5);
self.isOccupiable = true;
self.occupy = function (villager) {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
this.handleVillagersFallingInLove = (function (villagers, houses, resources) {
for (var i = 0; i < villagers.length; i++) {
for (var j = i + 1; j < villagers.length; j++) {
var villagerA = villagers[i];
var villagerB = villagers[j];
if (villagerA.canFallInLove(villagerB)) {
var newVillager = new Villager(resources);
newVillager.x = villagerA.home.x;
newVillager.y = villagerA.home.y;
newVillager.home = villagerA.home;
newVillager.workplace = houses[Math.floor(Math.random() * houses.length)];
villagers.push(newVillager);
this.addChild(newVillager);
villagerA.partner = villagerB;
villagerB.partner = villagerA;
break;
}
}
}
}).bind(this);
var resources = {
wood: new Resource('Wood', 100),
rock: new Resource('Rock', 100),
food: new Resource('Food', 100)
};
self.addChild(resources.wood);
self.addChild(resources.rock);
self.addChild(resources.food);
var resourceDisplayText = new Text2('Resources: Wood ' + resources.wood.amount + ' Rock ' + resources.rock.amount + ' Food ' + resources.food.amount, {
size: 50,
fill: "#ffffff"
});
resourceDisplayText.anchor.set(0.5, 0);
resourceDisplayText.x = 2048 / 2 - 800 - 500 + 100;
resourceDisplayText.y = 50;
LK.gui.topCenter.addChild(resourceDisplayText);
var background = self.createAsset('background', 'Background Graphics', 0, 0);
background.width = 4096 * 0.8;
background.height = 5464 * 0.8;
background.x = (2048 - background.width) / 2;
background.y = (2732 - background.height) / 2 - 400;
self.addChildAt(background, 0);
var villagers = [];
var villagerCountText = new Text2('Villagers: 0', {
size: 50,
fill: "#ffffff"
});
villagerCountText.anchor.set(0.5, 0);
villagerCountText.x = 2048 / 2;
villagerCountText.y = 50;
var houses = [new House()];
houses[0].x = 2048 / 2;
houses[0].y = 2732 / 2;
self.addChild(houses[0]);
var workplaces = [];
var workplace = new EmployingWorkPlace();
workplace.x = Math.random() * 2048;
workplace.y = Math.random() * 2732;
workplaces.push(workplace);
self.addChild(workplace);
var house = new OccupiableHouse();
house.x = 2048 / 2;
house.y = 2732 / 2;
houses.push(house);
self.addChild(house);
var workplace = new EmployingWorkPlace();
workplace.x = Math.random() * 2048;
workplace.y = Math.random() * 2732;
workplaces.push(workplace);
self.addChild(workplace);
LK.on('tick', function () {
villagerCountText.setText('Villagers: ' + villagers.length);
LK.gui.topCenter.addChild(villagerCountText);
for (var i = 0; i < villagers.length; i++) {
villagers[i].update();
}
});
LK.on('tick', function () {
this.handleVillagersFallingInLove(villagers, houses, resources);
for (var i = 0; i < villagers.length; i++) {
villagers[i].update();
}
});
});
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.