User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 83
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.parent.incrementScore();' Line Number: 83
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 83
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.parent.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.parent.incrementScore();' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.game.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.parent.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'incrementScore')' in this line: 'self.parent.incrementScore();' Line Number: 82
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'self.game.gold += 50;' Line Number: 84
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'game.gold += 50;' Line Number: 84
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'self.game.gold += 50;' Line Number: 83
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'self.game.gold += 50;' Line Number: 84
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'game.gold += 50;' Line Number: 84
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'self.game.gold += 50;' Line Number: 83
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'self.game.gold += 50;' Line Number: 83
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'gold')' in this line: 'self.game.gold += 50;' Line Number: 84
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'scoreTxt')' in this line: 'self.game.scoreTxt.setText(self.game.score.toString());' Line Number: 83
var FrameRateCounter = Container.expand(function () {
var self = Container.call(this);
self.lastTime = Date.now();
self.frameCount = 0;
self.framerate = 0;
self.display = new Text2('FPS: 0', {
size: 150,
fill: '#ffffff'
});
self.display.anchor.set(1, 0);
self.updateDisplay = function () {
self.display.setText('FPS: ' + Math.round(self.framerate).toString());
};
self.update = function () {
var currentTime = Date.now();
var deltaTime = (currentTime - self.lastTime) / 1000;
self.frameCount++;
if (deltaTime >= 1) {
self.framerate = self.frameCount / deltaTime;
self.updateDisplay();
self.frameCount = 0;
self.lastTime = currentTime;
}
};
});
var Plain = Container.expand(function () {
var self = Container.call(this);
var plainGraphics = self.createAsset('correct_plain_asset_id', 'Correct Plain Graphics Description', .5, .5);
plainGraphics.scale.x = 2;
plainGraphics.scale.y = 2;
plainGraphics.alpha = 1;
self.shoot = function (enemies, bulletsContainer) {
if (self.cooldownTimer <= 0 && enemies.length > 0) {
var bullet = new Bullet(self, self.game);
bullet.x = self.x;
bullet.y = self.y;
bulletsContainer.addChild(bullet);
self.cooldownTimer = self.cooldown;
}
self.cooldownTimer--;
};
});
var Tower = Container.expand(function () {
var self = Container.call(this);
self.game = game;
var towerGraphics = self.createAsset('tower', 'Tower Graphics', .5, .5);
self.cooldown = 30;
self.cooldownTimer = 0;
self.shoot = function (enemies, bulletsContainer) {
if (self.cooldownTimer <= 0 && enemies.length > 0) {
var bullet = new Bullet(self, self.game);
bullet.x = self.x;
bullet.y = self.y;
bulletsContainer.addChild(bullet);
bulletsContainer.bullets.push(bullet);
self.cooldownTimer = self.cooldown;
}
self.cooldownTimer--;
};
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
self.game = game;
var enemyGraphics = self.createAsset('enemy', 'Enemy Graphics', .5, .5);
self.move = function () {
self.y += 2;
if (self.y > 2732) {
self.destroy();
}
};
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
self.game = game;
self.game = game;
self.update = function (enemies, scoreTxt) {
self.move();
for (var j = enemies.length - 1; j >= 0; j--) {
if (self.intersects(enemies[j])) {
enemies[j].destroy();
enemies.splice(j, 1);
self.parent.incrementScore();
self.parent.scoreTxt.setText(self.parent.score.toString());
self.game.gold += 50;
self.destroy();
break;
}
}
if (self.isDestroyed) {
var index = self.parent.bullets.indexOf(self);
if (index > -1) {
self.parent.bullets.splice(index, 1);
}
}
};
var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', .5, .5);
self.move = function () {
self.x += 10;
if (self.x > 2048) {
self.destroy();
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
this.moveEnemies = function () {
if (this.enemies) {
this.enemies.forEach(function (enemy) {
enemy.move();
});
}
};
self.score = 0;
self.gold = 100;
self.incrementScore = function () {
this.score++;
};
self.frameRateCounter = new FrameRateCounter();
LK.gui.topRight.addChild(self.frameRateCounter.display);
var enemiesSpawnedLastRound = 1;
self.scoreTxt = new Text2(self.score.toString(), {
size: 150,
fill: "#ffffff"
});
self.scoreTxt.anchor.set(0.5, 0);
LK.gui.topCenter.addChild(self.scoreTxt);
self.goldTxt = new Text2(self.gold.toString(), {
size: 150,
fill: "#ffff00"
});
self.goldTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(self.goldTxt);
LK.stageContainer.setBackgroundColor(0xFFFFFF);
var towers = [];
self.enemies = [];
self.bullets = [];
var initialTower = new Tower();
initialTower.x = 0 + initialTower.width / 2 - 50;
initialTower.y = 500 + initialTower.height / 2 - 400;
towers.push(initialTower);
self.addChild(initialTower);
var plain = self.addChild(new Plain());
plain.x = 2048 / 2;
plain.y = 2732 / 2;
self.addChild(plain);
var enemy = new Enemy();
enemy.x = 2048 / 2;
enemy.y = -enemy.height / 2;
self.enemies.push(enemy);
self.addChild(enemy);
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
if (self.gold >= 50) {
var newTower = new Tower(this);
newTower.x = pos.x;
newTower.y = pos.y;
self.addChild(newTower);
towers.push(newTower);
self.gold -= 50;
self.goldTxt.setText(self.gold.toString());
}
});
LK.on('tick', function () {
self.frameRateCounter.update();
if (self.enemies.length === 0) {
var enemyCount = Math.max(2, enemiesSpawnedLastRound * 2);
for (var i = 0; i < enemyCount; i++) {
var newEnemy = new Enemy();
newEnemy.x = Math.random() * 2048;
newEnemy.y = -50 * (i + 1);
self.enemies.push(newEnemy);
self.addChild(newEnemy);
}
enemiesSpawnedLastRound = enemyCount;
} else {
towers.forEach(function (tower) {
tower.shoot(self.enemies, self);
});
}
self.moveEnemies();
self.bullets.forEach(function (bullet, index) {
bullet.update(self.enemies);
if (bullet.isDestroyed) {
self.score++;
self.gold += 50;
self.scoreTxt.setText(self.score.toString());
self.goldTxt.setText(self.gold.toString());
self.bullets.splice(index, 1);
}
});
});
});
A plain in a comic style with a dirt road with 4 turn staring to top to the botom see from a top and 50 meter high view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tower shooting at enemy in a modern style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A single soldat walking downard in a 16 bit style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.