User prompt
Fix Bug: 'Uncaught TypeError: this.well.createAsset is not a function' in this line: 'this.wellGraphics = this.well.createAsset('well', 'Well Graphics', .5, .5);' Line Number: 299
User prompt
Improve
User prompt
Fix Bug: 'Uncaught ReferenceError: House is not defined' in this line: 'var house = new House();' Line Number: 489
User prompt
Improve
User prompt
Improve
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of null (reading 'addChild')' in this line: 'self.parent.addChild(villager);' Line Number: 273
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of null (reading 'addChild')' in this line: 'self.parent.addChild(villager);' Line Number: 273
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of null (reading 'addChild')' in this line: 'self.parent.addChild(villager);' Line Number: 271
User prompt
Improve
User prompt
Improve
User prompt
Improve the code
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeHouses is not a function' in this line: 'self.initializeHouses();' Line Number: 447
===================================================================
--- original.js
+++ change.js
@@ -230,14 +230,17 @@
});
var VillagerFactory = Container.expand(function (resources) {
var self = Container.call(this);
self.resources = resources;
- self.createVillager = function (x, y, isBaby, iq) {
+ self.createVillager = function (isBaby, iq) {
var villager = new Villager(self.resources, iq);
- villager.initializePosition(x, y);
villager.setAge(isBaby);
return villager;
};
+ self.initializeVillagerPosition = function (villager, x, y) {
+ villager.x = x;
+ villager.y = y;
+ };
});
Well.prototype.initialize = function () {
this.wellGraphics = this.createAsset('well', 'Well Graphics', .5, .5);
this.x = 2048 / 2 - 800;
@@ -301,9 +304,10 @@
Game.prototype.createAndAddVillagerIfPossible = function () {
if (this.resources && this.resources.food.amount >= 10) {
var x = Math.random() * 2048;
var y = Math.random() * 2732;
- this.addVillager(this.villagerFactory.createVillager(x, y, false, Math.random() * 50 + 50));
+ var villager = this.villagerFactory.createVillager(false, Math.random() * 50 + 50);
+ this.addVillager(villager, x, y);
this.resources.food.amount -= 10;
}
};
Game.prototype.zoomOnVillagers = function (villagerA, villagerB) {
@@ -389,9 +393,10 @@
this.scale.x = 1;
this.scale.y = 1;
}
};
- Game.prototype.addVillager = function (villager) {
+ Game.prototype.addVillager = function (villager, x, y) {
+ this.villagerFactory.initializeVillagerPosition(villager, x, y);
this.addChild(villager);
this.registerVillager(villager);
this.initializeVillager(villager);
};
@@ -409,30 +414,18 @@
self.villagers = [];
self.houses = [];
self.cloudLayer = new Container();
self.clouds = [];
- self.initializeClouds = function () {
- for (var i = 0; i < 5; i++) {
- var cloud = new Cloud();
- self.clouds.push(cloud);
- self.cloudLayer.addChild(cloud);
- }
- };
- self.initializeClouds();
+ for (var i = 0; i < 5; i++) {
+ var cloud = new Cloud();
+ self.clouds.push(cloud);
+ self.cloudLayer.addChild(cloud);
+ }
self.villagerFactory = new VillagerFactory(self.resources);
- self.populateVillage = function () {
- this.addVillager(this.villagerFactory.createVillager(1024, 1366, false, Math.random() * 50 + 50));
- for (var i = 0; i < 10; i++) {
- this.addVillager(this.villagerFactory.createVillager(Math.random() * 2048, Math.random() * 2732, false, Math.random() * 50 + 50));
- }
- };
- self.populateVillage();
- Game.prototype.populateVillage = function () {
- this.addVillager(this.villagerFactory.createVillager(1024, 1366, false, Math.random() * 50 + 50));
- for (var i = 0; i < 10; i++) {
- this.addVillager(this.villagerFactory.createVillager(Math.random() * 2048, Math.random() * 2732, false, Math.random() * 50 + 50));
- }
- };
+ self.addVillager(self.villagerFactory.createVillager(1024, 1366, false, Math.random() * 50 + 50));
+ for (var i = 0; i < 10; i++) {
+ self.addVillager(self.villagerFactory.createVillager(Math.random() * 2048, Math.random() * 2732, false, Math.random() * 50 + 50));
+ }
self.market = new Market();
self.addChild(self.market);
Game.prototype.createHouse = function (x, y) {
var house = new House();
@@ -441,21 +434,14 @@
return house;
};
Game.prototype.addHouse = function (house) {
this.addChild(house);
- this.self.houses.push(house);
+ this.houses.push(house);
};
- Game.prototype.initializeHouses = function () {
- var newHouse = this.createHouse(2048 / 2, 2732 / 2);
- this.addHouse(newHouse);
- this.houses.push(newHouse);
- };
- self.initializeHouses();
- Game.prototype.initializeHouses = function () {
- var newHouse = this.createHouse(2048 / 2, 2732 / 2);
- this.addHouse(newHouse);
- this.houses.push(newHouse);
- };
+ var houses = [];
+ var newHouse = self.createHouse(2048 / 2, 2732 / 2);
+ self.addHouse(newHouse);
+ houses.push(newHouse);
Game.prototype.createWorkplace = function () {
var workplace = new EmployingWorkPlace();
workplace.x = Math.random() * 2048;
workplace.y = Math.random() * 2732;
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.