User prompt
projectiles should record in a map which enemies it hit (by the enemy id) and the last tick they were hit. Enemies cannot get hit more than once every 10 ticks
Code edit (11 edits merged)
Please save this source code
User prompt
instead of generating a unique id, use an integer which is incremented
User prompt
Fix Bug: 'TypeError: LK.generateUniqueId is not a function' in this line: 'enemies.push(new BasicEnemy(self, x, y, {' Line Number: 704
User prompt
Fix Bug: 'TypeError: LK.generateUniqueId is not a function' in this line: 'enemies.push(new BasicEnemy(self, x, y, {' Line Number: 704
User prompt
add a unique id to enemies, passed through in the constructor args object
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: t.setStageReference is not a function' in this line: 'parent.addChild(self);' Line Number: 138
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
in the CrossWeapon's launch function, create additional projectiles based on the hero's "Extra" major boon. These additional projectiles should have their angle uniformally distributed in a radius around the hero
Code edit (3 edits merged)
Please save this source code
User prompt
make the screen flash red when a basicenemy deals damage to the hero
Code edit (4 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: updateButton is not defined' in this line: 'updateButton.visible = bool;' Line Number: 595
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: availableBoonsTxt.anchor is undefined' in this line: 'availableBoonsTxt.anchor.set(.5, .5);' Line Number: 389
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: setting is not defined' in this line: 'if (setting.anchor) {' Line Number: 55
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: setting is not defined' in this line: 'text.anchor.set(settings.anchor.x, setting.anchor.y);' Line Number: 51
===================================================================
--- original.js
+++ change.js
@@ -6,12 +6,13 @@
i--;
}
}
}
-var SectionalContainer = Container.expand(function (parent, x, y, difficultyScale) {
+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 = [];
@@ -82,10 +83,13 @@
var secondsString = (seconds < 10 ? '0' : '') + seconds;
countdownTxt.setText(minutesString + ':' + secondsString);
}
});
-var ExperiencePickup = Container.expand(function (experience) {
+var ExperiencePickup = Container.expand(function (parent, x, y, experience) {
var self = Container.call(this);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
var pickupGraphics = self.createAsset('experiencePickup', 'Experience Pickup', .5, .5);
var active = false;
self.update = update;
function update(vars) {
@@ -105,14 +109,20 @@
self.y += dy / distance * 20;
}
}
});
-var CrucifixPickup = Container.expand(function () {
+var CrucifixPickup = Container.expand(function (parent, x, y) {
var self = Container.call(this);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
var pickupGraphics = self.createAsset('crucifixPickup', 'Crucifix Pickup', .5, .5);
});
-var HealingPickup = Container.expand(function () {
+var HealingPickup = Container.expand(function (parent, x, y) {
var self = Container.call(this);
+ parent.addChild(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) {
@@ -124,14 +134,14 @@
}
});
var BasicBloodSplatter = Container.expand(function (parent, x, y) {
var self = Container.call(this);
- var splatterGraphics = self.createAsset('bloodSplatter', 'Blood Splatter', .5, .5);
- var initialLifetime = Math.floor(0.2 * 60);
- var remainingLifetime = initialLifetime;
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;
LK.setInterval(function () {
remainingLifetime -= 1;
var lifetime = remainingLifetime / initialLifetime;
splatterGraphics.alpha = lifetime;
@@ -145,32 +155,32 @@
}, 0);
});
var BasicEnemy = Container.expand(function (parent, x, y, difficultyScale) {
var self = Container.call(this);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
var enemyGraphics = self.createAsset('enemy', 'Enemy character', .5, .5);
- var damageDistance = 120;
+ var damageDistance = 100;
var speed = 1.8;
var damage = 5;
var initialCooldown = 20;
var cooldown = initialCooldown;
var bobMagnitude = 2;
var bobPeriod = 10;
var creationTick = LK.ticks;
- var health = 5 + 25 * difficultyScale;
var parent = parent;
- self.x = x;
- self.y = x;
+ self.health = 5 + 25 * difficultyScale;
self.update = update;
- parent.addChild(self);
- function update(vars) {
- if (health <= 0) {}
- var hero = vars.hero;
- var game = vars.game;
- var healthPickups = vars.healthPickups;
- var crucifixPickups = vars.crucifixPickups;
- var projectiles = vars.projectiles;
- var backgroundContainer = vars.backgroundContainer;
- var foregroundContainer = vars.foregroundContainer;
+ function update(args) {
+ var hero = args.hero;
+ var game = args.game;
+ var backgroundContainer = args.backgroundContainer;
+ var foregroundContainer = args.foregroundContainer;
+ if (self.health <= 0) {
+ kill(args);
+ return true;
+ }
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > damageDistance) {
@@ -193,109 +203,115 @@
if (parent !== newParent) {
newParent.addChild(self);
parent = newParent;
}
- for (var j = 0; j < projectiles.length; j++) {
- var projectile = hero.projectiles[j];
- if (self.intersects(projectile)) {
- self.health -= projectile.damage;
- if (self.health.health <= 0) {
- if (crucifixPickups.length < 1 && Math.random() < Math.sqrt(hero.minorBoonLevels['Luck']) / 100) {
- var crucifixPickup = new CrucifixPickup();
- crucifixPickup.x = self.x;
- crucifixPickup.y = self.y;
- game.addChild(crucifixPickup);
- crucifixPickups.push(crucifixPickup);
- } else if (healthPickups.length < 5) {
- for (var k = 0; k <= hero.minorBoonLevels['Luck']; k++) {
- if (Math.random() < 0.02) {
- var pickup = new HealingPickup();
- pickup.x = self.x;
- pickup.y = self.y;
- game.addChild(pickup);
- healthPickups.push(pickup);
- break;
- }
- }
- }
- var experience = 0;
- for (var k = 0; k <= hero.minorBoonLevels['Luck'] + 1; k++) {
- if (Math.random() < 0.3) {
- experience++;
- }
- }
- if (experience > 0) {
- var experiencePickup = new ExperiencePickup(experience);
- experiencePickup.x = enemies[i].x + Math.random() * 100 - 50;
- experiencePickup.y = enemies[i].y + Math.random() * 100 - 50;
- self.addChild(experiencePickup);
- experiencePickups.push(experiencePickup);
- }
- var bloodSplatter = new BloodSplatter(game, self.x, self.y);
- return true;
+ }
+ function kill(args) {
+ var hero = args.hero;
+ var game = args.game;
+ 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 < 5) {
+ for (var k = 0; k <= hero.minorBoonLevels['Luck']; k++) {
+ if (Math.random() < 0.02) {
+ healthPickups.push(new HealingPickup(game, self.x, self.y));
+ break;
}
}
}
+ var experience = 0;
+ for (var k = 0; k <= hero.minorBoonLevels['Luck'] + 1; k++) {
+ if (Math.random() < 0.3) {
+ experience++;
+ }
+ }
+ if (experience > 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));
+ }
+ var bloodSplatter = new BasicBloodSplatter(game, self.x, self.y);
}
});
-var CrossProjectile = Container.expand(function (parent, x, y) {
+var CrossProjectile = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
var projectileAsset = self.createAsset('crossProjectile', 'Projectile Asset', .5, .5);
- self.speed = 30;
- self.range = null;
- self.damage = null;
- self.destroyRange = -1200;
- self.travelDistance = 200;
- self.targetPos = {
- x,
- y
+ var speed = 30;
+ var range = args.range;
+ var damage = args.damage;
+ var destroyRange = -1200;
+ var angle = args.angle;
+ self.scale = {
+ x: args.scale,
+ y: args.scale
};
- self.update = function (args) {
+ self.update = update;
+ function update(args) {
var hero = args.hero;
- self.x += self.speed * Math.cos(self.angle);
- self.y += self.speed * Math.sin(self.angle);
+ var enemies = args.enemies;
+ self.x += speed * Math.cos(angle);
+ self.y += speed * Math.sin(angle);
self.rotation += 0.2;
- self.travelDistance -= Math.abs(self.speed);
- if (self.travelDistance <= 0 && self.speed > -30) {
- self.speed -= 1;
+ range -= Math.abs(speed);
+ if (range <= 0 && speed > -30) {
+ speed -= 1;
}
- return (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) && self.travelDistance < self.destroyRange || self.intersects(hero) && self.speed < 0;
- };
+ for (var i = 0; i < enemies.length; i++) {
+ var enemy = enemies[i];
+ if (self.intersects(enemy)) {
+ enemy.health -= damage;
+ }
+ }
+ return (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) && range < destroyRange || self.intersects(hero) && speed < 0;
+ }
});
-var CrossWeapon = Container.expand(function (hero) {
+var CrossWeapon = Container.expand(function (parent) {
var self = Container.call(this);
- self.initialCooldown = 120;
- self.cooldown = self.initialCooldown;
+ parent.addChild(self);
+ self.x = 0;
+ self.y = 0;
+ var initialCooldown = 120;
+ var cooldown = self.initialCooldown;
self.update = update;
- self.launch = launch;
function update(args) {
- if (self.cooldown > 0) {
- self.cooldown--;
+ var hero = args.hero;
+ if (cooldown > 0) {
+ cooldown--;
} else {
- self.launch(args);
+ launch(args);
var attackSpeed = 1 + 0.25 * hero.minorBoonLevels['Rearm'];
- self.cooldown = self.initialCooldown / attackSpeed;
+ cooldown = initialCooldown / attackSpeed;
}
}
function launch(args) {
+ var hero = args.hero;
var game = args.game;
- var projectile = new CrossProjectile(hero);
+ var projectiles = args.projectiles;
+ var dx = hero.shootPos.x - hero.x;
+ var dy = hero.shootPos.y - hero.y;
+ var angle = Math.atan2(dy, dx);
var scale = 1 + 0.25 * hero.minorBoonLevels['Scale'];
var range = 200 + 50 * hero.minorBoonLevels['Range'];
var damage = 10 + 5 * hero.minorBoonLevels['Damage'];
- var dx = hero.shootPos.x - hero.x;
- var dy = hero.shootPos.y - hero.y;
- projectile.x = hero.x;
- projectile.y = hero.y;
- projectile.angle = Math.atan2(dy, dx);
- projectile.range = range;
- projectile.initialRange = range;
- hero.projectiles.push(projectile);
- game.addChild(projectile);
+ projectiles.push(new CrossProjectile(game, hero.x, hero.y, {
+ scale,
+ range,
+ damage,
+ angle
+ }));
}
});
var Hero = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
+ parent.addChild(self);
+ self.x = x;
+ self.y = y;
var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5);
var progressBar = args.progressBar;
var onLevelUp = args.onLevelUp;
var experience = 0;
@@ -315,25 +331,19 @@
self.shootPos = {
x,
y
};
- self.x = x;
- self.y = y;
- self.weapons = [];
- self.projectiles = [];
- self.crossWeapon = new CrossWeapon(self);
- self.weapons.push(self.crossWeapon);
- self.addChild(self.crossWeapon);
- self.health = 100;
+ self.healthMax = 100;
+ self.health = self.healthMax;
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.update = update;
- parent.addChild(self);
+ self.addExperience = addExperience;
function update(args) {
var game = args.game;
self.healthBar.scale.x = Math.max(0, self.health / self.healthMax);
if (self.health <= 0) {
@@ -356,14 +366,8 @@
self.scale.x = -1;
} else {
self.scale.x = 1;
}
- updateIteration(self.weapons, {
- game
- });
- updateIteration(self.projectiles, {
- hero: self
- });
}
function addExperience(amount) {
if (experience >= levelRequirement) {
level++;
@@ -471,14 +475,14 @@
y: 0
},
size: 80
});
- var foregroundContainer = new SectionalContainer();
- var backgroundContainer = new SectionalContainer();
var selectingBoon = false;
var progressBarBorder = LK.getAsset('progressBarBorder', 'Progress Bar Border', 0, .5);
var progressBar = LK.getAsset('progressBar', 'Progress Bar', 0, .5);
+ var heroProjectiles = [];
var enemyProjectiles = [];
+ var weapons = [];
var enemies = [];
var healthPickups = [];
var crucifixPickups = [];
var experiencePickups = [];
@@ -494,14 +498,15 @@
progressBar.y = levelTxt.y + levelTxt.height / 2;
progressBar.scale.x = 0;
self.targetPos = null;
self.addChild(grass);
- self.addChild(backgroundContainer);
+ var backgroundContainer = new SectionalContainer(self);
var hero = new Hero(self, 2048 / 2, 2732 / 2, {
progressBar,
onLevelUp
});
- self.addChild(foregroundContainer);
+ weapons.push(new CrossWeapon(self));
+ var foregroundContainer = new SectionalContainer(self);
refreshBoonUpgradeButton();
stage.on('down', function (obj) {
canMove = true;
hero.targetPos = obj.event.getLocalPosition(self);
@@ -528,24 +533,33 @@
difficultyScale = countdownTimer.update();
hero.update({
game: self
});
- updateIteration(healthPickups, {
+ updateIteration(weapons, {
+ projectiles: heroProjectiles,
+ game: self,
hero
});
+ updateIteration(heroProjectiles, {
+ enemies,
+ hero
+ });
updateIteration(enemyProjectiles);
updateIteration(enemies, {
- hero,
game: self,
- healthPickups,
- crucifixPickups,
- projectiles: hero.projectiles,
backgroundContainer,
- foregroundContainer
+ foregroundContainer,
+ crucifixPickups,
+ healthPickups,
+ experiencePickups,
+ hero
});
updateIteration(experiencePickups, {
hero
});
+ updateIteration(healthPickups, {
+ hero
+ });
for (var i = 0; i < crucifixPickups.length; i++) {
if (hero.intersects(crucifixPickups[i])) {
for (var j = 0; j < enemies.length; j++) {
enemies[j].destroy();
@@ -620,26 +634,25 @@
var distance = Math.random();
var x, y;
switch (side) {
case 0:
- x = distance * 2048;
+ x = 2048 * distance;
y = 0;
break;
case 1:
x = 2048;
- y = distance * 2732;
+ y = 2732 * distance;
break;
case 2:
- x = distance * 2048;
+ x = 2048 * distance;
y = 2732;
break;
case 3:
x = 0;
- y = distance * 2732;
+ y = 2732 * distance;
break;
}
- var enemy = new BasicEnemy(self, x, y, difficultyScale);
- enemies.push(enemy);
+ enemies.push(new BasicEnemy(self, x, y, difficultyScale));
}
function onLevelUp(level) {
levelTxt.setText('Level ' + level + ' • XP');
if (level % 5) {
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