User prompt
increase the spawn rate of enemies every 10 points
User prompt
Remove the hero's targetPos assignment in mouse down event
User prompt
adjust the bloodsplatter lifetime to be 0.5
User prompt
Replace the update function in the bloodsplatter with a timeout instead
User prompt
after an enemy is destroyed, display a bloodsplatter for 500ms
User prompt
Fix Bug: 'Timeout.tick error: enemies[i] is undefined' in this line: 'enemies[i].destroy();' Line Number: 156
User prompt
before an enemy is destroyed, display a bloodsplatter for 500ms
User prompt
move the healing pickup logic to before the enemy is destroyed and remove the check to see if the enemy exists
User prompt
Make the hero show above all other sprites
User prompt
after an enemy has moved assign its y position to the z-index
User prompt
double the hero's bullet speed rotation
User prompt
Fix Bug: 'TypeError: enemies[i] is undefined' in this line: 'pickup.x = enemies[i].x;' Line Number: 139
User prompt
health pickups should spawn where the enemy was destroyed rather than by the hero
User prompt
Fix Bug: 'TypeError: hero.enemies is undefined' in this line: 'hero.enemies.splice(i, 1);' Line Number: 134
User prompt
Fix Bug: 'TypeError: hero.enemies is undefined' in this line: 'hero.enemies[i].destroy();' Line Number: 133
User prompt
Fix Bug: 'TypeError: hero.enemies is undefined' in this line: 'if (heroBullets[j].intersects(hero.enemies[i])) {' Line Number: 130
User prompt
Fix Bug: 'TypeError: hero.enemies is undefined' in this line: 'if (hero.intersects(hero.enemies[i])) {' Line Number: 147
User prompt
Fix Bug: 'TypeError: hero.enemies is undefined' in this line: 'hero.enemies[i].move();' Line Number: 128
User prompt
hero should not hold the list of enemies, put that in the game
User prompt
enemies should record the tick they were created on, and reduce the bobbing tick counter by that
User prompt
on mouseup set the hero's targetPos to null
User prompt
On mouse move only update the hero's targetPos if canMove is true
User prompt
remove line 78
User prompt
On mouse up set canMove variable to false
User prompt
stage.isDown is not a variable
var HealingPickup = Container.expand(function () {
var self = Container.call(this);
var pickupGraphics = self.createAsset('healingPickup', 'Healing Pickup', .5, .5);
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', .5, .5);
self.speed = 20;
self.move = function () {
self.x += self.speed * Math.cos(self.angle);
self.y += self.speed * Math.sin(self.angle);
self.rotation += 0.1;
};
});
var Enemy = Container.expand(function (hero) {
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy character', .5, .5);
self.move = function () {
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 50) {
self.x += dx / distance * 1.8;
self.y += dy / distance * 1.8 + Math.sin(LK.ticks / 10) * 2;
}
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5);
self.health = 100;
self.healthBarBorder = self.createAsset('healthBarBorder', 'Health Bar Border', 0.5, 1);
self.healthBarBorder.y = -115;
self.healthBar = self.createAsset('healthBar', 'Health Bar', 0.5, 1);
self.healthBar.y = -120;
self.healthBarBorder.x = self.healthBar.x;
self.healthBarBorder.width = self.healthBar.width + 10;
self.healthBarBorder.height = self.healthBar.height + 10;
self.move = function () {
self.healthBar.scale.x = self.health / 100;
if (self.targetPos) {
var dx = self.targetPos.x - self.x;
var dy = self.targetPos.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * 10;
self.y += dy / distance * 10;
} else {
self.x = self.targetPos.x;
self.y = self.targetPos.y;
self.targetPos = null;
}
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var grass = self.createAsset('grass', 'Grass Background', 0, 0);
grass.width = 2048;
grass.height = 2732;
self.addChild(grass);
var hero = self.addChild(new Hero());
var canMove = false;
var score = 0;
var scoreTxt = new Text2('Score: ' + score, {
size: 150,
fill: '#ffffff'
});
LK.gui.topCenter.addChild(scoreTxt);
hero.enemies = [];
var heroBullets = [];
var enemyBullets = [];
hero.x = 2048 / 2;
hero.y = 2732 / 2;
self.targetPos = null;
stage.on('down', function (obj) {
canMove = true;
hero.targetPos = obj.event.getLocalPosition(self);
});
stage.on('move', function (obj) {
hero.targetPos = obj.event.getLocalPosition(self);
});
var spawnEnemy = function () {
var side = Math.floor(Math.random() * 4);
var enemy = new Enemy(hero);
switch (side) {
case 0:
enemy.x = Math.random() * 2048;
enemy.y = 0;
break;
case 1:
enemy.x = 2048;
enemy.y = Math.random() * 2732;
break;
case 2:
enemy.x = Math.random() * 2048;
enemy.y = 2732;
break;
case 3:
enemy.x = 0;
enemy.y = Math.random() * 2732;
break;
}
hero.enemies.push(enemy);
self.addChild(enemy);
};
LK.on('tick', function () {
hero.move();
for (var i = 0; i < heroBullets.length; i++) {
heroBullets[i].move();
if (heroBullets[i].x < 0 || heroBullets[i].x > 2048 || heroBullets[i].y < 0 || heroBullets[i].y > 2732) {
heroBullets[i].destroy();
heroBullets.splice(i, 1);
i--;
}
}
for (var i = 0; i < enemyBullets.length; i++) {
enemyBullets[i].move();
}
for (var i = 0; i < hero.enemies.length; i++) {
hero.enemies[i].move();
for (var j = 0; j < heroBullets.length; j++) {
if (heroBullets[j].intersects(hero.enemies[i])) {
heroBullets[j].destroy();
heroBullets.splice(j, 1);
hero.enemies[i].destroy();
hero.enemies.splice(i, 1);
score++;
scoreTxt.setText('Score: ' + score);
if (Math.random() < 0.1) {
var pickup = new HealingPickup();
pickup.x = hero.x;
pickup.y = hero.y;
self.addChild(pickup);
}
i--;
j--;
}
}
if (hero.intersects(hero.enemies[i])) {
hero.health -= 1;
if (hero.health <= 0) {
LK.showGameOver();
}
}
}
for (var i = 0; i < self.children.length; i++) {
if (self.children[i] instanceof HealingPickup && hero.intersects(self.children[i])) {
hero.health = Math.min(100, hero.health + 10);
self.children[i].destroy();
}
}
if (LK.ticks % 30 === 0) {
spawnEnemy();
}
if (LK.ticks % 20 === 0 && hero.targetPos) {
var bullet = new Bullet();
bullet.x = hero.x;
bullet.y = hero.y;
var dx = hero.targetPos.x - hero.x;
var dy = hero.targetPos.y - hero.y;
bullet.angle = Math.atan2(dy, dx);
heroBullets.push(bullet);
self.addChild(bullet);
}
});
});
pixel art cross with blue accents Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a white orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a white orb with a halo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a pulsating white heart with a halo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a dark goo projectile with red highlights. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art tall blue fireball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of an evil fantasy sword facing downward. Minor red details. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
backgroundAmbient
Sound effect
heroHealed
Sound effect
pickupExperience
Sound effect
heroLeveled
Sound effect
weaponCrossImpact
Sound effect
heroImpact
Sound effect
enemyDeath
Sound effect
pickupWeapon
Sound effect
pickupCrucifix
Sound effect
weaponCrossLaunch
Sound effect
heroDeath
Sound effect
enemyRoar
Sound effect
clockChime
Sound effect