User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'destroyEnemy')' in this line: 'gameInstance.destroyEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'destroyEnemy')' in this line: 'self.game.destroyEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'destroyEnemy')' in this line: 'gameInstance.destroyEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'destroyEnemy')' in this line: 'self.game.destroyEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'gameInstance.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Make the bullet kill the enemy
User prompt
Fix the bullet
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'gameInstance.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'gameInstance.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 76
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'gameInstance.removeEnemy(self);' Line Number: 76
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 76
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'gameInstance.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'gameInstance.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 75
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeEnemy')' in this line: 'self.game.removeEnemy(self);' Line Number: 76
User prompt
Fix the bad fluidity
User prompt
Add only 4 more soldier every roubd
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: '#000000'
});
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();
self.frameCount++;
var elapsedTime = (currentTime - self.lastTime) / 1000;
if (elapsedTime >= 1) {
self.framerate = self.frameCount / elapsedTime;
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 = 0;
self.shoot = function (enemies, bulletsContainer) {
if (self.cooldownTimer <= 0 && enemies.length > 0) {
var bullet = new Bullet(self);
bullet.x = self.x;
bullet.y = self.y;
bulletsContainer.addChild(bullet);
self.cooldownTimer = self.cooldown;
}
self.cooldownTimer--;
};
});
var Tower = Container.expand(function (gameInstance) {
var self = Container.call(this);
self.game = gameInstance;
var towerGraphics = self.createAsset('tower', 'Tower Graphics', .5, .5);
self.cooldown = 0.625 / 0.7 * (1 / 0.6) * 1.3;
self.cooldownTimer = 0;
self.shoot = function (enemies, bullets) {
this.handleShooting(enemies, bullets);
};
self.handleShooting = function (enemies, bullets) {
self.cooldownTimer--;
if (self.cooldownTimer <= 0 && enemies.length > 0) {
self.fireBullet(bullets);
}
};
self.fireBullet = function (bullets) {
var bullet = new Bullet(self.game);
bullet.x = self.x;
bullet.y = self.y;
gameInstance.bulletsContainer.addChild(bullet);
gameInstance.bullets.push(bullet);
self.cooldownTimer = self.cooldown;
};
});
var Enemy = Container.expand(function (gameInstance) {
var self = Container.call(this);
self.game = gameInstance;
var enemyGraphics = self.createAsset('enemy', 'Enemy Graphics', .5, .5);
var enemySpeed = 25.6 * 0.7 * 0.6;
self.move = function () {
self.y += enemySpeed;
};
});
var Bullet = Container.expand(function (gameInstance) {
var self = Container.call(this);
self.game = gameInstance;
var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', .5, .5);
self.move = function () {
self.x += 240;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.incrementScore = function () {
self.score++;
};
self.spawnEnemies = function () {
this.generateEnemies();
};
self.generateEnemies = function () {
enemiesSpawnedLastRound += 4;
for (var i = 0; i < enemiesSpawnedLastRound; i++) {
var newEnemy = new Enemy();
newEnemy.x = Math.random() * 2048;
newEnemy.y = -25 * (i + 1);
self.enemies.push(newEnemy);
self.addChild(newEnemy);
}
self.enemyCounterTxt.setText('Enemies: ' + self.enemies.length.toString());
};
self.updateEnemyCounter = function () {};
self.score = 0;
self.frameRateCounter = new FrameRateCounter();
LK.gui.topRight.addChild(self.frameRateCounter.display);
var enemiesSpawnedLastRound = 1;
self.enemies = [];
self.enemyCounterTxt = new Text2('Enemies: ' + self.enemies.length.toString(), {
size: 150,
fill: "#ff0000"
});
self.enemyCounterTxt.anchor.set(0, 1);
LK.gui.bottomLeft.addChild(self.enemyCounterTxt);
LK.stageContainer.setBackgroundColor(0xFFFFFF);
var towers = [];
self.bullets = [];
self.bulletsContainer = self.addChild(new Container());
self.enemies = [];
var initialTower = new Tower(self);
initialTower.x = 0 + initialTower.width / 2 - 260;
initialTower.y = 500 + initialTower.height / 2 + 300 + 800 + 500;
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);
var newTower = new Tower(self);
newTower.x = pos.x;
newTower.y = pos.y;
self.addChild(newTower);
towers.push(newTower);
});
LK.on('tick', function () {
self.frameRateCounter.update(enemiesSpawnedLastRound);
if (self.enemies.length === 0) {
self.spawnEnemies();
} else {
towers.forEach(function (tower) {
tower.shoot(self.enemies, self.bullets);
});
}
self.enemies.forEach(function (enemy) {
enemy.move();
});
self.bullets.forEach(function (bullet, index) {
bullet.move();
for (var j = self.enemies.length - 1; j >= 0; j--) {
if (bullet.intersects(self.enemies[j])) {
self.enemies[j].destroy();
self.enemies.splice(j, 1);
self.incrementScore();
bullet.destroy();
self.enemyCounterTxt.setText('Enemies: ' + self.enemies.length.toString());
break;
}
}
if (bullet.x > 2048) {
bullet.destroy();
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.