User prompt
when villager kiss they make a baby
User prompt
make the villager kiss more
User prompt
when villager fall in love and kiss each other their create a child who spawn a new villager
User prompt
improve viller IQ to be 10 time smarter
User prompt
update the resource text
User prompt
start with 100 resource of each
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'wood')' in this line: 'resourceDisplayText.setText('Resources: Wood ' + self.gameResources.wood.amount + ' Rock ' + self.gameResources.rock.amount + ' Food ' + self.gameResources.food.amount);' Line Number: 263
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in this line: 'self.resourceDisplay.update(self.resources);' Line Number: 324
User prompt
update resource text base on current resource
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'food')' in this line: 'if (self.resources.food.amount >= 10) {' Line Number: 404
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'food')' in this line: 'if (Game.prototype.resources.food.amount >= 10) {' Line Number: 404
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'food')' in this line: 'if (self.resources.food.amount >= 10) {' Line Number: 404
User prompt
spawn a villager by using 10 fonnd resource if available
User prompt
create 10 villager every ms
User prompt
create a viller every ms
User prompt
add a villager every 0.001 second
User prompt
add a vilager very 0.01 second
User prompt
Fix Bug: 'ReferenceError: timerText is not defined' in this line: 'timerText.setText('Time: ' + elapsedTime);' Line Number: 410
User prompt
Fix Bug: 'ReferenceError: timerText is not defined' in this line: 'timerText.setText('Time: ' + elapsedTime);' Line Number: 410
User prompt
Fix Bug: 'ReferenceError: startTime is not defined' in this line: 'var elapsedTime = Math.floor((currentTime - startTime) / 1000);' Line Number: 408
User prompt
Fix Bug: 'ReferenceError: startTime is not defined' in this line: 'var elapsedTime = Math.floor((currentTime - startTime) / 1000);' Line Number: 400
User prompt
Fix Bug: 'framerateText is not defined' in this line: 'framerateText.anchor.set(0, 1);' Line Number: 285
User prompt
Fix Bug: 'Uncaught ReferenceError: framerateText is not defined' in this line: 'framerateText.anchor.set(0, 1);' Line Number: 285
User prompt
show a timer
User prompt
a new villager is spawn every 0.1 second
var HouseBuilder = Container.expand(function () {
var self = Container.call(this);
self.build = function (villager) {
var newHouse = new House();
newHouse.initializeRandomPosition();
villager.parent.addChild(newHouse);
villager.state = 'atHome';
villager.home = newHouse;
newHouse.scheduleVillagerWork(villager);
};
});
var ResourceCollector = Container.expand(function () {
var self = Container.call(this);
self.collect = function (villager) {
if (villager.workplace) {
if (villager.workplace instanceof Tree) {
villager.gameResources.food.amount += 1;
villager.carriedFood += 1;
} else if (villager.workplace.resourceType) {
var resource = villager.workplace.resourceType;
resource.amount += 1;
}
villager.moveTo(villager.home.x, villager.home.y, 'goingHome');
villager.game.updateResourceDisplay();
}
};
});
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.continuousMove = function () {
if (this.x < this.speed || this.x > 2048 - this.speed) this.directionX *= -1;
if (this.y < this.speed || this.y > 2732 - this.speed) this.directionY *= -1;
this.x = Math.max(this.speed, Math.min(2048 - this.speed, this.x + this.speed * this.directionX));
this.y = Math.max(this.speed, Math.min(2732 - this.speed, this.y + this.speed * this.directionY));
if (Math.random() < 0.05) {
this.directionX = Math.random() < 0.5 ? -1 : 1;
this.directionY = Math.random() < 0.5 ? -1 : 1;
}
};
Villager.prototype.directionX = 1;
Villager.prototype.directionY = 1;
Villager.prototype.restAtHome = function () {
this.state = 'resting';
this.tiredness = Math.max(0, this.tiredness - 0.1);
if (this.home) {
this.home.occupy(this);
}
if (this.tiredness <= 0) {
this.state = 'atHome';
}
};
Villager.prototype.isDoingSomething = function () {
return this.state === 'goingToWork' || this.state === 'working' || this.state === 'goingHome' || this.state === 'resting' || this.state === 'plantingTree' || this.state === 'buildingHouse';
};
Villager.prototype.carriedWood = 0;
Villager.prototype.carriedRock = 0;
Villager.prototype.carriedFood = 0;
Villager.prototype.tiredness = 0;
Villager.prototype.canBuildHouse = function () {
return this.gameResources && this.gameResources.wood.amount >= 200 && this.gameResources.rock.amount >= 200 && this.gameResources.food.amount >= 200;
};
Villager.prototype.calculateBuildUtility = function () {
return this.canBuildHouse() ? 0.8 : 0;
};
Villager.prototype.hasResources = function () {
return this.carriedWood > 0 || this.carriedRock > 0 || this.carriedFood > 0;
};
Villager.prototype.canFallInLove = function (otherVillager) {
return this.state === 'atHome' && otherVillager.state === 'atHome' && !this.partner && !otherVillager.partner;
};
self.gameResources = resources;
Villager.prototype.buildHouse = function (houseBuilder) {
if (this.canBuildHouse(this.gameResources)) {
houseBuilder.build(this);
this.gameResources.wood.amount -= 200;
this.gameResources.rock.amount -= 200;
this.gameResources.food.amount -= 200;
}
};
self.collectResource = function () {
self.resourceCollector.collect(self);
};
self.arriveHome = function () {
self.restAtHome();
};
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.speed = 12;
self.moveTo = function (x, y, state) {
self.targetX = x;
self.targetY = y;
if (state) self.state = state;
};
self.update = function () {
self.continuousMove();
if (!self.isDoingSomething()) {
self.decideNextAction();
}
self.executeCurrentAction();
};
self.decideNextAction = function () {
var utilities = [{
action: 'work',
utility: self.calculateWorkUtility()
}, {
action: 'home',
utility: self.calculateHomeUtility()
}, {
action: 'plant',
utility: self.calculatePlantUtility(self.gameResources)
}, {
action: 'buildHouse',
utility: self.calculateBuildUtility()
}];
utilities.sort(function (a, b) {
return b.utility - a.utility;
});
var chosenAction = utilities[0].action;
self.state = chosenAction;
if (chosenAction === 'work' && self.workplace && self.workplace.x !== null && self.workplace.y !== null) {
self.moveTo(self.workplace.x, self.workplace.y, 'goingToWork');
}
};
self.executeCurrentAction = function () {
switch (self.state) {
case 'goingToWork':
if (self.workplace && self.workplace.x !== null && self.workplace.y !== null) {
self.moveTowards(self.workplace.x, self.workplace.y);
if (self.intersects(self.workplace)) {
self.state = 'working';
self.startWorking();
}
}
break;
case 'working':
self.collectResource();
break;
case 'goingHome':
if (self.home) {
self.moveTowards(self.home.x, self.home.y);
if (self.intersects(self.home)) {
self.arriveHome();
}
}
break;
case 'resting':
self.restAtHome();
break;
case 'plantingTree':
self.plantTree();
break;
case 'buildingHouse':
self.buildHouse();
break;
}
};
self.plantTree = function () {
if (!self.workplace) {
var tree = new Tree();
tree.x = Math.random() * 2048;
tree.y = Math.random() * 2732;
self.parent.addChild(tree);
self.workplace = tree;
self.gameResources.food.amount -= 100;
}
};
self.calculateWorkUtility = function () {
return self.workplace && self.workplace.resourceType && self.workplace.resourceType.amount > 0 ? 0.8 : 0.2;
};
self.calculateHomeUtility = function () {
return self.tiredness > 0.7 || self.hasResources() ? 0.8 : 0.2;
};
self.calculatePlantUtility = function (gameResources) {
return self.gameResources && self.gameResources.food.amount > 100 && !self.workplace ? 0.7 : 0;
};
self.moveTowards = function (x, y) {
if (self.x !== x || self.y !== y) {
self.moveTo(x, y);
self.moveTowardsTarget();
}
};
self.moveTowardsTarget = function () {
if (self.targetX !== null && self.targetY !== null) {
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < self.speed) {
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) * Math.min(self.speed, distance);
self.y += Math.sin(angle) * Math.min(self.speed, distance);
}
}
};
});
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) {};
});
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) {};
});
var House = Container.expand(function () {
var self = Container.call(this);
House.prototype.scheduleVillagerWork = function (villager) {
LK.setTimeout(function () {
villager.state = 'goingToWork';
villager.moveTo(villager.workplace.x, villager.workplace.y);
}, 5000);
};
House.prototype.initializeRandomPosition = function () {
this.x = Math.random() * 2048;
this.y = Math.random() * 2732;
};
var houseGraphics = self.createAsset('house', 'House Graphics', .5, .5);
self.isOccupiable = true;
House.prototype.occupy = function (villager) {
if (!this.isOccupiable) return;
this.isOccupiable = false;
villager.home = this;
this.scheduleVillagerWork(villager);
};
});
var ResourceDisplay = Container.expand(function (resources) {
var self = Container.call(this);
var resourceDisplayText = new Text2('', {
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);
self.update = function () {
resourceDisplayText.setText('Resources: Wood ' + resources.wood.amount + ' Rock ' + resources.rock.amount + ' Food ' + resources.food.amount);
};
});
var VillagerAndFramerateDisplay = Container.expand(function (game) {
var self = Container.call(this);
self.villagers = game.villagers;
var villagerCountText = new Text2('', {
size: 50,
fill: "#ffffff"
});
villagerCountText.anchor.set(0.5, 0);
villagerCountText.x = 2048 / 2 - 200;
villagerCountText.y = 50;
LK.gui.topCenter.addChild(villagerCountText);
var framerateText = new Text2('', {
size: 100,
fill: "#ffffff"
});
framerateText.anchor.set(0, 1);
framerateText.x = 500;
framerateText.y = 2732;
LK.gui.topCenter.addChild(framerateText);
var lastTick = LK.ticks;
var frameCount = 0;
var lastSecond = Math.floor(lastTick / 60);
self.update = function () {
var currentTick = LK.ticks;
var currentSecond = Math.floor(currentTick / 60);
frameCount++;
if (currentSecond > lastSecond) {
framerateText.setText('FPS: ' + frameCount);
framerateText.visible = true;
frameCount = 0;
lastSecond = currentSecond;
}
villagerCountText.setText('Villagers: ' + (self.villagers ? self.villagers.length : 0));
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.villagers = [];
self.villagerAndFramerateDisplay = new VillagerAndFramerateDisplay(self);
self.updateResourceDisplay = function () {
var resourceDisplay = new ResourceDisplay(resources);
resourceDisplay.update();
};
self.handleVillagersFallingInLove = function () {
for (var i = 0; i < self.villagers.length; i++) {
for (var j = i + 1; j < self.villagers.length; j++) {
var villagerA = self.villagers[i];
var villagerB = self.villagers[j];
if (villagerA.canFallInLove(villagerB)) {
var newVillager = self.createAndAddVillager(villagerA.home.x, villagerA.home.y);
newVillager.home = villagerA.home;
newVillager.workplace = houses[Math.floor(Math.random() * houses.length)];
villagers.push(newVillager);
villagerA.partner = villagerB;
villagerB.partner = villagerA;
break;
}
}
}
};
function createResources() {
return {
wood: new Resource('Wood', 100),
rock: new Resource('Rock', 100),
food: new Resource('Food', 100)
};
}
var resources = createResources();
self.addChild(resources.wood);
self.addChild(resources.rock);
self.addChild(resources.food);
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 resourceCollector = new ResourceCollector();
Game.prototype.createAndAddVillager = function (x, y) {
var villager = new Villager(this.resources);
villager.x = x;
villager.y = y;
this.addChild(villager);
this.villagers.push(villager);
return villager;
};
self.villagers = [];
self.houses = [];
self.villagers.push(self.createAndAddVillager(1024, 1366));
self.villagers.push(self.createAndAddVillager(1024, 1500));
Game.prototype.createAndAddHouse = function (x, y) {
var house = new House();
house.x = x;
house.y = y;
this.addChild(house);
this.houses.push(house);
return house;
};
var houses = [];
houses.push(self.createAndAddHouse(2048 / 2, 2732 / 2));
Game.prototype.createAndAddWorkplace = function () {
var workplace = new EmployingWorkPlace();
workplace.x = Math.random() * 2048;
workplace.y = Math.random() * 2732;
this.addChild(workplace);
this.workplaces.push(workplace);
return workplace;
};
self.workplaces = [];
self.workplaces.push(self.createAndAddWorkplace());
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;
self.workplaces.push(workplace);
self.addChild(workplace);
self.villagerCreationInterval = LK.setInterval(function () {
self.createAndAddVillager(Math.random() * 2048, Math.random() * 2732);
}, 100);
LK.on('tick', function () {
self.villagerAndFramerateDisplay.update();
self.updateResourceDisplay();
for (var i = 0; i < self.villagers.length; i++) {
self.villagers[i].update();
}
self.handleVillagersFallingInLove();
});
});
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.