User prompt
the soldiers move faster and a bit randomly
User prompt
add 10 soldiers of each team in random position at start of the game
User prompt
red soldiers shoot toward blue soldiers
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'bullets[i].targetTeam.forEach(function (target, index) {' Line Number: 163
User prompt
Fix Bug: 'Timeout.tick error: opposingTeam is not defined' in this line: 'bullet.targetTeam = opposingTeam;' Line Number: 56
User prompt
Fix Bug: 'Timeout.tick error: opposingTeam is not defined' in this line: 'bullet.targetTeam = opposingTeam;' Line Number: 56
User prompt
when the battle start the soldiers move toward each other and shoot at the other team soldiers
User prompt
when the battle start the soldiers start shooting at each other
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'color')' in this line: 'self.color = 'red';' Line Number: 15
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', 0.5, 0.5);
self.speed = 60;
self.move = function () {
self.x += self.speed;
};
});
var Soldier = Container.expand(function () {
var self = Container.call(this);
});
var RedSoldier = Soldier.expand(function () {
var self = Container.call(this);
var self = Soldier.call(this);
self.color = 'red';
var soldierGraphics = self.createAsset(self.color + 'Soldier', self.color.charAt(0).toUpperCase() + self.color.slice(1) + ' Soldier Graphics', .5, .5);
self.move = function (opposingTeam) {};
});
var BlueSoldier = Soldier.expand(function () {
var self = Container.call(this);
Soldier.call(this);
self.color = 'blue';
var soldierGraphics = self.createAsset(self.color + 'Soldier', self.color.charAt(0).toUpperCase() + self.color.slice(1) + ' Soldier Graphics', .5, .5);
self.move = function (opposingTeam) {};
});
Soldier.prototype.destroy = function () {
if (this.shootInterval) {
LK.clearInterval(this.shootInterval);
}
Container.prototype.destroy.call(this);
};
Soldier.prototype.startFighting = function (opposingTeam) {
this.isFighting = true;
this.shootInterval = LK.setInterval((function () {
this.shoot(opposingTeam);
}).bind(this), 1400);
};
Soldier.prototype.move = function (opposingTeam) {};
Soldier.prototype.shoot = function (targetTeam) {};
Soldier.prototype.destroy = function () {
if (this.shootInterval) {
LK.clearInterval(this.shootInterval);
}
Container.prototype.destroy.call(this);
};
Soldier.prototype.startFighting = function (opposingTeam) {
this.isFighting = true;
this.shootInterval = LK.setInterval((function () {
this.shoot(opposingTeam);
}).bind(this), 1400);
};
Soldier.prototype.move = function (opposingTeam) {};
Soldier.prototype.shoot = function (targetTeam) {};
var Game = Container.expand(function () {
var self = Container.call(this);
var frameRateText = new Text2('FPS: Calculating...', {
size: 100,
fill: '#ffffff',
align: 'center'
});
frameRateText.x = 2048 / 2;
frameRateText.y = 2732 / 2;
frameRateText.anchor.set(0.5, 0.5);
self.addChild(frameRateText);
var lastTick = Date.now();
var frameCount = 0;
LK.on('tick', function () {
var now = Date.now();
frameCount++;
if (now - lastTick >= 1000) {
frameRateText.setText('FPS: ' + frameCount);
frameCount = 0;
lastTick = now;
}
});
LK.on('soldierHit', function (event) {
var bulletIndex = bullets.indexOf(event.detail.bullet);
var targetIndex = event.detail.targetTeam ? event.detail.targetTeam.indexOf(event.detail.target) : -1;
if (bulletIndex !== -1) {
bullets.splice(bulletIndex, 1);
}
if (targetIndex !== -1) {
event.detail.target.team.splice(targetIndex, 1);
}
event.detail.target.destroy();
event.detail.bullet.destroy();
});
LK.on('bulletFired', function (event) {
bullets.push(event.detail);
self.addChild(event.detail);
});
var battleStarted = false;
var background = self.createAsset('battlePlain', 'Background Battle Plain', 0, 0);
background.anchor.set(0.5, 0.5);
background.x = 2048 / 2;
background.y = 2732 / 2;
background.scale.set(1.4);
self.addChild(background);
var startBattleButton = self.createAsset('startBattleButton', 'Start Battle Button', 0.5, 0.5);
startBattleButton.x = 2048 / 2;
startBattleButton.y = 2732 / 2 - startBattleButton.height / 2 + 1200;
self.addChild(startBattleButton);
startBattleButton.on('down', function () {
if (!battleStarted) {
battleStarted = true;
startBattleButton.destroy();
soldiers.forEach(function (soldier) {
soldier.startFighting(enemies);
});
enemies.forEach(function (enemy) {
enemy.startFighting(soldiers);
});
}
});
var soldiers = [];
var enemies = [];
var bullets = [];
var spawnSoldier = function (position) {
var soldier = new BlueSoldier();
soldier.x = position.x;
soldier.y = position.y;
soldiers.push(soldier);
self.addChild(soldier);
};
var spawnEnemy = function (position) {
var redSoldier = new RedSoldier();
redSoldier.x = position.x;
redSoldier.y = position.y;
enemies.push(redSoldier);
self.addChild(redSoldier);
};
var handleTick = function () {
for (var i = 0; i < soldiers.length; i++) {
soldiers[i].move(enemies);
}
for (var i = 0; i < enemies.length; i++) {
enemies[i].move(soldiers);
}
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].move();
bullets[i].targetTeam.forEach(function (target, index) {
if (bullets[i] && bullets[i].intersects(target)) {
LK.emit('soldierHit', {
detail: {
bullet: bullets[i],
target: target
}
});
target.destroy();
if (bullets[i]) {
bullets[i].destroy();
}
bullets.splice(i, 1);
}
});
if (bullets[i] && bullets[i].y < 0) {
bullets[i].destroy();
bullets.splice(i, 1);
}
}
};
LK.on('tick', handleTick);
var handleTouch = function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
var buttonBounds = startBattleButton.getBounds();
if (!battleStarted && !buttonBounds.contains(pos.x, pos.y) && Math.abs(pos.y - startBattleButton.y) > 400) {
if (pos.x < 2048 / 2) {
spawnSoldier(pos);
} else {
spawnEnemy(pos);
}
}
};
stage.on('down', handleTouch);
});
a big plain show from the top with a line right at the center of the plain to the top from the botom Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a blue toy soldier Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a red toy soldier Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A start Battle button Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A blue soldier toy Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A red soldier toy Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a bullet in an anime style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.