Code edit (1 edits merged)
Please save this source code
User prompt
The fireballprojectiles enemy for-loop should use the LinkedList foreach instead
User prompt
fireballprojectiles should check in their update function if they collide with an enemy, and deal damage to it and destroy itself
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: hero is undefined' in this line: 'hero.rotation += rotationSpeed;' Line Number: 82
User prompt
add a new weapon type called FireballWeapon that slowly rotates, firing FireballProjectiles in the direction it's facing.
Code edit (13 edits merged)
Please save this source code
User prompt
RangedEnemies scale back and forth slightly during their update
User prompt
ranged enemies flash black when they attack
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Add a RangedEnemy class which moves towards the hero, periodically shooting EnemyProjectiles towards the hero when it's within 500 range
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: midgroundContainer is not defined' in this line: 'var enemy = new BasicEnemy(midgroundContainer, x, y, {' Line Number: 95
User prompt
make an EnemySpawner class that handles the spawning of enemies instead of the tick event
Code edit (1 edits merged)
Please save this source code
User prompt
countdown timer should continue counting down even after reaching zero
User prompt
when the countdowntimer reaches zero, perform a once-off update that changes the text to red
Code edit (8 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: bool is not defined' in this line: 'if (bool === 'Health') {' Line Number: 862
Code edit (5 edits merged)
Please save this source code
User prompt
healing pickups first check if the hero is at max health already before applying the heal and destroying itself
User prompt
Fix Bug: 'ReferenceError: health is not defined' in this line: 'if (health <= 0) {' Line Number: 684
User prompt
change the hero's `var health` and `var healthMax` to `self.health` and `self.healthMax` and update any references to these variables found within the hero class
Code edit (1 edits merged)
Please save this source code
function Node(data) {
this.data = data;
this.prev = null;
this.next = null;
}
function LinkedList() {
this.head = null;
this.tail = null;
this.length = 0;
}
LinkedList.prototype.push = function (data) {
var node = new Node(data);
if (!this.head) {
this.head = node;
this.tail = node;
} else {
node.prev = this.tail;
this.tail.next = node;
this.tail = node;
}
this.length++;
};
LinkedList.prototype.remove = function (node) {
if (node.prev) {
node.prev.next = node.next;
} else {
this.head = node.next;
}
if (node.next) {
node.next.prev = node.prev;
} else {
this.tail = node.prev;
}
node.prev = null;
node.next = null;
this.length--;
return node.data;
};
LinkedList.prototype.popEach = function (callback) {
while (this.head) {
callback(this.remove(this.head));
}
};
LinkedList.prototype.forEach = function (callback) {
var node = this.head;
while (node) {
var next = node.next;
callback(node.data, node);
node = next;
}
};
function updateIteration(list, args) {
list.forEach(function (item, node) {
if (item.update(args)) {
item.destroy();
list.remove(node);
}
});
}
var Point = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
var collision = self.createAsset('blank', 'Collision', .5, .5);
collision.tint = 0xff0000;
collision.width = 10;
collision.height = 10;
collision.opacity = 1;
});
var HealthBar = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
var border = self.createAsset('blank', 'Health Bar Border', .5, .5);
var bar = LK.getAsset('blank', 'Health Bar', .5, .5);
var defaultTint = 0xffffff;
var defaultWidth = 100;
var defaultHeight = 10;
var defaultWeight = 4;
self.addChild(bar);
bar.width = args.width || defaultWidth;
bar.height = args.height || defaultHeight;
bar.tint = args.tint || defaultTint;
border.width = bar.width + 2 * (args.weight || defaultWeight);
border.height = bar.height + 2 * (args.weight || defaultWeight);
border.tint = 0x000000;
self.updatePercentage = updatePercentage;
function updatePercentage(percentage) {
bar.scale.x = Math.max(0, percentage);
}
});
var SectionalContainer = Container.expand(function (parent) {
var self = Container.call(this);
self.x = 0;
self.y = 0;
parent.addChild(self);
});
var BorderedText = Container.expand(function (string, settings) {
var self = Container.call(this);
var textList = [];
var defaultFill = '#ffffff';
var defaultBorder = '#000000';
var defaultFont = 'bold monospace';
var defaultSize = 50;
var defaultWeight = 2;
var offsets = [[-1, -1], [-1, 1], [1, 1], [1, -1], [0, 0]];
var borderSettings = {
fill: settings.border || defaultBorder,
font: settings.font || defaultFont,
size: settings.size || defaultSize
};
var textSettings = {
fill: settings.fill || defaultFill,
font: settings.font || defaultFont,
size: settings.size || defaultSize
};
self.x = settings.x;
self.y = settings.y;
for (var i = 0; i < offsets.length; i++) {
var localSettings = i === offsets.length - 1 ? textSettings : borderSettings;
var text = new Text2(string, localSettings);
text.x += offsets[i][0] * defaultWeight;
text.y += offsets[i][1] * defaultWeight;
if (settings.anchor) {
text.anchor.set(settings.anchor.x, settings.anchor.y);
}
textList.push(text);
self.addChild(text);
}
self.setText = function (string) {
for (var i = 0; i < textList.length; i++) {
textList[i].setText(string);
}
};
self.setFill = function (newFill) {
textList[textList.length - 1].fill = newFill;
};
});
var CountdownTimer = Container.expand(function (initialCountdown) {
var self = Container.call(this);
var countdown = initialCountdown;
var ticker = 60;
var countdownTxt = new BorderedText('', {
size: 60,
anchor: {
x: .5,
y: 0
}
});
self.update = update;
self.addChild(countdownTxt);
adjustLabel();
function update() {
ticker -= 1;
if (ticker <= 0) {
ticker = 60;
countdown--;
if (countdown >= 0) {
adjustLabel();
}
}
return 1 - countdown / initialCountdown;
}
function adjustLabel() {
var minutes = Math.floor(countdown / 60);
var seconds = countdown % 60;
var minutesString = (minutes < 10 ? '0' : '') + minutes;
var secondsString = (seconds < 10 ? '0' : '') + seconds;
countdownTxt.setText(minutesString + ':' + secondsString);
}
});
var BoonUpgradeButton = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
var fill = args.fill;
var hidden = false;
var count = 0;
var button = self.createAsset('boonButton', 'Boon Upgrade Button', 0.5, 0.4);
var countTxt = new BorderedText('0', {
fill: '#ff0000',
anchor: {
x: .5,
y: .5
}
});
button.on('down', args.callback);
self.addChild(countTxt);
self.visible = false;
self.setHidden = setHidden;
self.setCount = setCount;
function setHidden(newHidden) {
hidden = newHidden;
checkHidden();
}
function setCount(newCount) {
count = newCount;
countTxt.setText(newCount);
checkHidden();
}
function checkHidden() {
self.visible = !hidden && count > 0;
}
});
var BoonSelection = Container.expand(function (boons, type, count, callback) {
var self = Container.call(this);
var availableBoons = Object.keys(boons).filter(function (boon) {
return boons[boon] < 3;
});
if (!availableBoons.length) {
self.destroy();
callback();
}
var selectedBoons = [];
while (selectedBoons.length < 3 && availableBoons.length > 0) {
var boonIndex = Math.floor(Math.random() * availableBoons.length);
selectedBoons.push(availableBoons.splice(boonIndex, 1)[0]);
}
var background = self.createAsset('boonBackground', 'Boon Selection Popup', 0.5, 0.5);
var boonMessageTitle = new BorderedText('Choose ' + count, {
y: -220,
size: 60,
anchor: {
x: .5,
y: 0
}
});
background.y = 50;
self.addChild(boonMessageTitle);
var boonMessageSubtitle = new BorderedText(type + ' Boon' + (count === 1 ? '' : 's'), {
y: -150,
anchor: {
x: .5,
y: 0
}
});
self.addChild(boonMessageSubtitle);
for (var i = 0; i < selectedBoons.length; i++) {
var boon = selectedBoons[i];
var boonButton = self.createAsset('boonButton', 'Boon Button', 0.5, 0.4);
boonButton.y = i * 120;
boonButton.x = -120;
boonButton.boon = boon;
boonButton.on('down', function () {
self.destroy();
callback(this.boon);
});
var boonLevel = new BorderedText(boons[boon], {
x: boonButton.x,
y: boonButton.y,
anchor: {
x: .5,
y: .5
}
});
var boonName = new BorderedText(boon, {
x: boonButton.x + 60,
y: boonButton.y,
anchor: {
x: 0,
y: .5
}
});
self.addChild(boonLevel);
self.addChild(boonName);
}
});
var ExperiencePickup = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
var activeDist = 300;
var activeDistSqr = activeDist * activeDist;
var collectDistance = 80;
var collectDistanceSqr = collectDistance * collectDistance;
var combineDist = 100;
var combineDistSqr = combineDist * combineDist;
self.experience = args.experience;
args.experiencePickups.forEach(function (experiencePickup, node) {
if (args.experiencePickup !== self) {
var dx = experiencePickup.x - self.x;
var dy = experiencePickup.y - self.y;
var distanceSqr = dx * dx + dy * dy;
if (distanceSqr <= combineDistSqr) {
self.experience += experiencePickups.remove(node).experience;
self.x += dx / 2;
self.y += dy / 2;
}
}
});
var size = 'small';
if (self.experience > 5) {
size = 'medium';
if (self.experience > 10) {
size = 'large';
}
}
var pickupGraphics = self.createAsset(size + 'ExperiencePickup', 'Experience Pickup', .5, .5);
var active = false;
var speed = 20;
self.update = update;
function update(args) {
var hero = args.hero;
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distanceSqr = dx * dx + dy * dy;
if (distanceSqr <= activeDistSqr) {
self.active = true;
if (distanceSqr <= collectDistanceSqr) {
hero.addExperience(self.experience);
return true;
}
}
if (self.active) {
var distance = Math.sqrt(distanceSqr);
self.x += dx / distance * speed;
self.y += dy / distance * speed;
}
}
});
var CrucifixPickup = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.collisionPoint = new Point(self);
self.x = x;
self.y = y;
var pickupGraphics = self.createAsset('crucifixPickup', 'Crucifix Pickup', .5, .5);
self.update = update;
function update(args) {
var hero = args.hero;
if (hero.collision.intersects(self.collisionPoint)) {
args.enemies.popEach(function (enemy) {
enemy.destroy();
});
args.enemyProjectiles.popEach(function (enemyProjectile) {
enemyProjectile.destroy();
});
args.experiencePickups.forEach(function (experiencePickup) {
experiencePickup.active = true;
});
LK.effects.flashScreen(0xffffff, 1000);
}
}
});
var HealingPickup = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.collisionPoint = new Point(self);
self.x = x;
self.y = y;
var pickupGraphics = self.createAsset('healingPickup', 'Healing Pickup', .5, .5);
var healPercentage = 0.1;
self.update = update;
function update(args) {
var hero = args.hero;
if (hero.collision.intersects(self.collisionPoint)) {
hero.onHealPercentage(0.1);
return true;
}
}
});
var BasicBloodSplatter = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
var splatterGraphics = self.createAsset('bloodSplatter', 'Blood Splatter', .5, .5);
var initialLifetime = Math.floor(0.2 * 60);
var remainingLifetime = initialLifetime;
self.update = update;
function update() {
if (--remainingLifetime <= 0) {
return true;
}
var lifetime = remainingLifetime / initialLifetime;
var newScale = 2 - lifetime;
splatterGraphics.alpha = lifetime;
splatterGraphics.scale = {
x: newScale,
y: newScale
};
}
});
var BasicEnemy = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.collision = self.createAsset('enemy', 'Basic Enemy', .5, .5);
self.id = args.id;
self.x = x;
self.y = y;
var healthBar = null;
var damageDistance = 100;
var heightDifference = 25;
var speed = 2.5;
var damage = 10;
var initialCooldown = 10;
var cooldown = initialCooldown;
var bobMagnitude = 2;
var bobPeriod = 10;
var creationTick = LK.ticks;
var parent = parent;
var healthMax = 5 + 25 * args.difficultyScale;
var health = healthMax;
self.update = update;
self.onTakeDamage = onTakeDamage;
function update(args) {
if (health <= 0) {
kill(args);
return true;
}
var hero = args.hero;
var game = args.game;
var backgroundContainer = args.backgroundContainer;
var foregroundContainer = args.foregroundContainer;
var dx = hero.x - self.x;
var dy = hero.y + heightDifference - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > damageDistance) {
self.x += dx / distance * speed;
self.y += dy / distance * speed + Math.sin((LK.ticks - creationTick) / bobPeriod) * bobMagnitude;
cooldown = initialCooldown;
} else {
cooldown -= 1;
if (cooldown <= 0) {
cooldown = initialCooldown;
hero.onTakeDamage(damage);
}
}
var newParent;
if (self.y <= hero.y + heightDifference) {
newParent = backgroundContainer;
} else {
newParent = foregroundContainer;
}
if (parent !== newParent) {
newParent.addChild(self);
parent = newParent;
}
}
function kill(args) {
var hero = args.hero;
var game = args.game;
var effects = args.effects;
var healthPickups = args.healthPickups;
var crucifixPickups = args.crucifixPickups;
var experiencePickups = args.experiencePickups;
if (crucifixPickups.length < 1 && Math.random() < Math.sqrt(hero.minorBoonLevels['Luck']) / 100) {
crucifixPickups.push(new CrucifixPickup(game, self.x, self.y));
} else if (healthPickups.length < 3) {
for (var k = 0; k <= 1 + hero.minorBoonLevels['Luck']; k++) {
if (Math.random() < 0.02) {
healthPickups.push(new HealingPickup(game, self.x, self.y));
break;
}
}
}
var droppedExperience = 0;
for (var k = 0; k <= 2 + hero.minorBoonLevels['Luck']; k++) {
if (Math.random() < 0.3) {
droppedExperience++;
}
}
if (droppedExperience > 0) {
var x = self.x + Math.random() * 100 - 50;
var y = self.y + Math.random() * 100 - 50;
experiencePickups.push(new ExperiencePickup(game, x, y, {
experience: droppedExperience,
experiencePickups
}));
}
effects.push(new BasicBloodSplatter(game, self.x, self.y));
}
function onTakeDamage(takenDamage) {
health -= takenDamage;
if (health > 0) {
if (!healthBar) {
healthBar = new HealthBar(self, 0, -self.collision.height / 2 - 50, {
tint: 0xaa0000
});
}
healthBar.updatePercentage(health / healthMax);
LK.effects.flashObject(self.collision, 0xaa0000, 1000);
}
}
});
var CrossProjectile = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
self.collisionPoint = new Point(self);
var projectileAsset = self.createAsset('crossProjectile', 'Projectile Asset', .5, .5);
var hitMap = {};
var initialSpeed = 30;
var speed = initialSpeed;
var speedDecrement = 1;
var destroyRange = -1200;
var growth = 1;
var growthRate = args.growthRate;
var initialScale = args.scale;
var currentScale = initialScale;
var scaleDamageFactor = 0.25;
var range = args.range;
var damage = args.damage;
var linger = args.linger;
var angle = args.angle;
self.rotation = Math.random() * Math.PI * 2;
self.scale = {
x: currentScale,
y: currentScale
};
self.update = update;
function update(args) {
var hero = args.hero;
var enemies = args.enemies;
self.x += speed * Math.cos(angle);
self.y += speed * Math.sin(angle);
self.rotation += 0.2;
if (growthRate > 0) {
growth += growthRate;
currentScale = initialScale * growth;
self.scale = {
x: currentScale,
y: currentScale
};
}
if (range <= 0) {
if (speed > -initialSpeed) {
if (speed <= 0 && linger > 0) {
speed = 0;
linger--;
} else {
speed -= speedDecrement;
}
} else {
speed = -initialSpeed;
}
}
range -= Math.abs(speed);
var tick = LK.ticks;
enemies.forEach(function (enemy) {
if (enemy.collision.intersects(self)) {
var lastHitTick = hitMap[enemy.id];
if (!lastHitTick || tick - lastHitTick > 10) {
hitMap[enemy.id] = tick;
enemy.onTakeDamage(damage * (1 + (currentScale - 1) * scaleDamageFactor));
}
}
});
return (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) && range < destroyRange || hero.collision.intersects(self.collisionPoint) && speed < 0;
}
});
var CrossWeapon = Container.expand(function (parent) {
var self = Container.call(this);
parent.addChild(self);
self.x = 0;
self.y = 0;
var initialCooldown = 120;
var cooldown = self.initialCooldown;
var spreadIncrement = 20 * Math.PI / 180;
self.update = update;
function update(args) {
var hero = args.hero;
if (cooldown > 0) {
cooldown--;
} else {
launch(args);
var attackSpeed = 1 + 0.25 * hero.minorBoonLevels['Rearm'];
cooldown = initialCooldown / attackSpeed;
}
}
function launch(args) {
var hero = args.hero;
var game = args.game;
var projectiles = args.projectiles;
var scale = 1 + 0.35 * hero.minorBoonLevels['Scale'];
var range = (200 + 100 * hero.minorBoonLevels['Range']) * (0.9 + 0.2 * Math.random());
var damage = 15 + 10 * hero.minorBoonLevels['Damage'];
var linger = 0 + 15 * hero.minorBoonLevels['Duration'] + Math.floor(10 * Math.random());
var growthRate = 0.25 * hero.majorBoonLevels['Growth'] / 60;
var spreadCount = 1 + hero.majorBoonLevels['Split'];
var dx = hero.shootPos.x - hero.x;
var dy = hero.shootPos.y - hero.y;
var baseAngle = Math.atan2(dy, dx) - spreadCount * spreadIncrement / 2;
for (var i = 0; i < spreadCount; i++) {
var spreadAngle = spreadCount <= 1 ? 0 : spreadIncrement / 2 * (Math.random() - 0.5);
var angle = baseAngle + i * spreadIncrement + spreadAngle;
projectiles.push(new CrossProjectile(game, hero.x, hero.y, {
growthRate,
damage,
angle,
scale,
range,
linger
}));
}
}
});
var Hero = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.collision = self.createAsset('hero', 'Hero character', .5, .5);
self.x = x;
self.y = y;
var progressBar = args.progressBar;
var onLevelUp = args.onLevelUp;
var baseMaxHealth = 100;
var healthMax = baseMaxHealth;
var health = baseMaxHealth;
var experience = 0;
var level = 1;
var levelRequirement = 20;
var healthBar = new HealthBar(self, 0, -self.height / 2 - 10, {
tint: 0x0fa0ff
});
self.minorBoonLevels = {
'Luck': 0,
'Scale': 0,
'Range': 0,
'Damage': 0,
'Rearm': 0,
'Duration': 0,
'Health': 0
};
self.majorBoonLevels = {
'Growth': 0,
'Split': 0
};
self.shootPos = {
x,
y
};
self.update = update;
self.addExperience = addExperience;
self.onTakeDamage = onTakeDamage;
self.onHealPercentage = onHealPercentage;
function update(args) {
var game = args.game;
var newMaxHealth = baseMaxHealth + 30 * self.minorBoonLevels['Health'];
if (healthMax < newMaxHealth) {
healthMax = newMaxHealth;
health = newMaxHealth;
healthBar.updatePercentage(health / healthMax);
}
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;
}
}
if (self.shootPos.x < self.x) {
self.scale.x = -1;
} else {
self.scale.x = 1;
}
}
function addExperience(amount) {
experience += amount;
if (experience >= levelRequirement) {
level++;
experience -= levelRequirement;
levelRequirement = Math.floor(levelRequirement * 1.2);
onLevelUp(level);
}
progressBar.scale.x = experience / levelRequirement;
}
function onTakeDamage(amount) {
health -= amount;
healthBar.updatePercentage(health / healthMax);
LK.effects.flashObject(self.collision, 0xaa0000, 1000);
if (health <= 0) {
LK.effects.flashScreen(0xaa0000, 1000);
LK.showGameOver();
}
}
function onHealPercentage(percentage) {
health = Math.min(healthMax, health + healthMax * percentage);
healthBar.updatePercentage(health / healthMax);
LK.effects.flashObject(self.collision, 0x0fa0ff, 1000);
}
});
var Game = Container.expand(function () {
var self = Container.call(this);
var isPaused = false;
var minorBoonCount = 0;
var majorBoonCount = 0;
var grass = LK.getAsset('grass', 'Grass Background', 0, 0);
var aimArrow = LK.getAsset('arrow', 'Directional Arrow', -2.5, 0.5);
var canMove = false;
var difficultyScale = 0;
var upgradeButton = new BoonUpgradeButton(LK.gui.topRight, -80, 60, {
fill: '#ff0000',
callback: function () {
if (minorBoonCount + majorBoonCount > 0) {
showBoonSelection();
}
}
});
var levelTxt = new BorderedText('Level 1 • XP', {
anchor: {
x: 1.0,
y: 0
},
size: 80
});
var selectingBoon = false;
var progressBarBorder = LK.getAsset('progressBarBorder', 'Progress Bar Border', 0, .5);
var progressBar = LK.getAsset('progressBar', 'Progress Bar', 0, .5);
var enemyIdCounter = -1;
var heroProjectiles = new LinkedList();
var enemyProjectiles = new LinkedList();
var weapons = new LinkedList();
var enemies = new LinkedList();
var healthPickups = new LinkedList();
var crucifixPickups = new LinkedList();
var experiencePickups = new LinkedList();
var effects = new LinkedList();
var countdownTimer = new CountdownTimer(300);
LK.gui.topCenter.addChild(countdownTimer);
LK.gui.topCenter.addChild(progressBarBorder);
LK.gui.topCenter.addChild(progressBar);
LK.gui.topCenter.addChild(levelTxt);
countdownTimer.y = levelTxt.height + 10;
progressBarBorder.x = 20;
progressBarBorder.y = levelTxt.y + levelTxt.height / 2;
progressBar.x = 24;
progressBar.y = levelTxt.y + levelTxt.height / 2;
progressBar.scale.x = 0;
grass.width = 2048;
grass.height = 2732;
self.addChild(grass);
self.addChild(aimArrow);
var backgroundContainer = new SectionalContainer(self);
var hero = new Hero(self, 2048 / 2, 2732 / 2, {
progressBar,
onLevelUp
});
weapons.push(new CrossWeapon(self));
var foregroundContainer = new SectionalContainer(self);
stage.on('down', function (obj) {
canMove = true;
hero.targetPos = obj.event.getLocalPosition(self);
});
stage.on('up', function (obj) {
canMove = false;
hero.targetPos = null;
});
stage.on('move', function (obj) {
if (!isPaused) {
if (canMove) {
hero.targetPos = obj.event.getLocalPosition(self);
}
hero.shootPos = obj.event.getLocalPosition(self);
if (hero.shootPos.x < hero.x) {
hero.scale.x = -1;
} else {
hero.scale.x = 1;
}
}
});
LK.on('tick', function () {
if (!isPaused) {
difficultyScale = countdownTimer.update();
hero.update({
game: self
});
aimArrow.x = hero.x;
aimArrow.y = hero.y;
aimArrow.rotation = Math.atan2(hero.shootPos.y - hero.y, hero.shootPos.x - hero.x);
updateIteration(weapons, {
projectiles: heroProjectiles,
game: self,
hero
});
updateIteration(heroProjectiles, {
enemies,
hero
});
updateIteration(enemyProjectiles);
updateIteration(enemies, {
game: self,
backgroundContainer,
foregroundContainer,
experiencePickups,
crucifixPickups,
healthPickups,
effects,
hero
});
updateIteration(effects);
updateIteration(experiencePickups, {
hero
});
updateIteration(healthPickups, {
hero
});
updateIteration(crucifixPickups, {
experiencePickups,
enemyProjectiles,
enemies,
hero
});
if (LK.ticks % Math.max(10, 60 - Math.floor(50 * difficultyScale)) === 0) {
spawnEnemy();
}
}
});
function showBoonSelection() {
if (!selectingBoon) {
var boonSelection;
if (minorBoonCount) {
selectingBoon = true;
boonSelection = new BoonSelection(hero.minorBoonLevels, 'Minor', minorBoonCount, function (boon) {
if (boon) {
hero.minorBoonLevels[boon]++;
minorBoonCount--;
upgradeButton.setCount(minorBoonCount + majorBoonCount);
selectingBoon = false;
showBoonSelection();
}
});
} else if (majorBoonCount) {
selectingBoon = true;
boonSelection = new BoonSelection(hero.majorBoonLevels, 'Major', majorBoonCount, function (boon) {
if (boon) {
hero.majorBoonLevels[boon]++;
majorBoonCount--;
upgradeButton.setCount(minorBoonCount + majorBoonCount);
selectingBoon = false;
showBoonSelection();
}
});
}
if (boonSelection) {
isPaused = true;
LK.gui.center.addChild(boonSelection);
} else {
isPaused = false;
}
upgradeButton.setHidden(selectingBoon);
}
}
function spawnEnemy() {
var side = Math.floor(Math.random() * 4);
var distance = Math.random();
var x, y;
switch (side) {
case 0:
x = 2048 * distance;
y = 0;
break;
case 1:
x = 2048;
y = 2732 * distance;
break;
case 2:
x = 2048 * distance;
y = 2732;
break;
case 3:
x = 0;
y = 2732 * distance;
break;
}
enemies.push(new BasicEnemy(self, x, y, {
id: (++enemyIdCounter).toString(),
difficultyScale
}));
}
function onLevelUp(level) {
levelTxt.setText('Level ' + level + ' • XP');
if (level % 5) {
minorBoonCount++;
} else {
majorBoonCount++;
}
upgradeButton.setCount(minorBoonCount + majorBoonCount);
}
});
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