User prompt
Please fix the bug: 'TypeError: self.intersectRadius is not a function' in or related to this line: 'if (self.activated) {' Line Number: 609
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: midFrontContainer is not defined' in or related to this line: 'midFrontContainer.addChild(new ProjectileCross({' Line Number: 111
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
if a closest enemy was found, increase the baseAngle by the angle from the hero to the closestEnemy
User prompt
In the weaponCross class replace the TODO comment by finding the closest (square distance) child in the midgroundContainer, making sure that the child has tag TAG_ENEMY and not TAG_PROJECTILE
Code edit (2 edits merged)
Please save this source code
User prompt
Rename the midBackContainer to midgroundContainer
User prompt
Remove the midFrontContainer, replacing any occurrences with midBackContainer
Code edit (1 edits merged)
Please save this source code
Code edit (21 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: e is undefined' in or related to this line: 'LK.effects.flashObject(self.collision, 0xAA0000, 1000);' Line Number: 508
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 (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: heightDifference is not defined' in or related to this line: 'var dy = hero.y + heightDifference - self.y;' Line Number: 97
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self is undefined' in or related to this line: 'var updateBase = self.update;' Line Number: 117
User prompt
Please fix the bug: 'ReferenceError: WeaponFireball is not defined' in or related to this line: 'startingWeapons.push(backgroundContainer.addChild(new PickupWeapon({' Line Number: 525
Code edit (2 edits merged)
Please save this source code
User prompt
add a hero asset with anchor (0.5, 1.0) to the Hero class
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -55,9 +55,9 @@
var damage = WEAPON_CROSS_DAMAGE_BASE + WEAPON_CROSS_DAMAGE_SCALING * minorBoonLevels[BOON_DAMAGE];
var linger = WEAPON_CROSS_LINGER_BASE + WEAPON_CROSS_LINGER_SCALING * minorBoonLevels[BOON_DURATION];
var growthRate = WEAPON_CROSS_GROWTH_SCALING * majorBoonLevels[BOON_GROWTH];
var splitCount = 1 + majorBoonLevels[BOON_SPLIT];
- var baseAngle = splitCount * WEAPON_CROSS_SPLIT_INCREMENT / 2;
+ var baseAngle = splitCount <= 1 ? 0 : splitCount * WEAPON_CROSS_SPLIT_INCREMENT / 2;
var closestEnemy = null;
var minDistanceSqr = Infinity;
for (var i = 0; i < midgroundContainer.children.length; i++) {
var child = midgroundContainer.children[i];
@@ -146,13 +146,10 @@
fill: config.fill,
anchorX: .5,
anchorY: .4
}));
- button.on('down', function (x, y, obj) {
- obj.event = obj;
- config.callback(obj);
- });
- //self.visible = false;
+ button.on('down', config.callback);
+ self.visible = false;
self.setHidden = function (newHidden) {
hidden = newHidden;
self.checkHidden();
};
@@ -161,9 +158,9 @@
countTxt.setText(newCount);
self.checkHidden();
};
self.checkHidden = function () {
- // self.visible = !hidden && count > 0;
+ self.visible = !hidden && count > 0;
};
return self;
});
var UiBoonSelection = ConfigContainer.expand(function (config) {
@@ -357,13 +354,13 @@
var self = ConfigContainer.call(this, config);
self.graphics = undefined;
self.radius = config.radius || 0;
self.elevation = config.elevation || 0;
- var shadowGraphics = self.attachAsset('shapeEllipse', {
+ self.shadow = self.attachAsset('shapeEllipse', {
anchorX: 0.5,
anchorY: 0.5,
- width: self.radius,
- height: self.radius * GAME_PERSPECTIVE,
+ width: self.radius * 2,
+ height: self.radius * 2 * GAME_PERSPECTIVE,
tint: 0x000000,
alpha: 0.5
});
self.moveInDirection = function (direction, speed) {
@@ -385,10 +382,10 @@
return self.radius * self.radius >= dx * dx + dy * dy;
};
self.setRadius = function (newRadius) {
self.radius = newRadius;
- shadowGraphics.width = newRadius;
- shadowGraphics.height = newRadius * GAME_PERSPECTIVE;
+ self.shadow.width = newRadius * 2;
+ self.shadow.height = newRadius * 2 * GAME_PERSPECTIVE;
self.onRadiusChanged(newRadius);
};
self.setElevation = function (newElevation) {
self.elevation = newElevation;
@@ -443,9 +440,8 @@
});
self.update = function () {
self.graphics.rotation += WEAPON_CROSS_ROTATION;
self.moveInDirection(config.direction, speed);
- range -= Math.abs(speed);
// Grow the projectile
if (config.growthRate > 0) {
growth += config.growthRate;
scale = config.scale * growth;
@@ -461,9 +457,12 @@
speed -= WEAPON_CROSS_SPEED_DECREMENT;
}
} else {
speed = -WEAPON_CROSS_SPEED_BASE;
+ range -= Math.abs(speed);
}
+ } else {
+ range -= Math.abs(speed);
}
// Check for hits and deal damage
var currentTick = LK.ticks;
var damage = config.damage * (1 + (scale - 1) * WEAPON_CROSS_SCALE_DAMAGE_FACTOR);
@@ -488,19 +487,27 @@
self.tags[TAG_PICKUP] = true;
self.activated = false;
self.update = function () {
if (!isPaused && !self.activated && self.intersectsInstance(hero)) {
- self.activated = true;
- self.onActivate();
+ self.activate();
}
};
+ self.intersectRadius = function (x, y, radius) {
+ var dx = x - self.x;
+ var dy = (y - self.y) / GAME_PERSPECTIVE;
+ var distance = self.radius + radius;
+ return distance * distance >= dx * dx + dy * dy;
+ };
+ self.activate = function () {
+ self.activated = true;
+ self.onActivate();
+ };
self.onActivate = function () {};
return self;
});
var PickupWeapon = Pickup.expand(function (config) {
var self = Pickup.call(this, config);
var updateBase = self.update;
- var scaleBase = self.scale;
self.tags[TAG_WEAPON] = true;
self.graphics = self.attachAsset(config.graphics, {
anchorX: 0.5,
anchorY: 0.5,
@@ -511,8 +518,9 @@
self.setElevation(WEAPON_HEIGHT_BASE + Math.sin(LK.ticks / WEAPON_HEIGHT_PERIOD) * WEAPON_HEIGHT_MAGNITUDE);
};
self.onActivate = function () {
hero.addChild(new config.weaponClass());
+ // Destroy all other weapons
for (var i = backgroundContainer.children.length - 1; i >= 0; i--) {
var child = backgroundContainer.children[i];
if (child.tags[TAG_PICKUP] && child.tags[TAG_WEAPON]) {
child.callDestroy();
@@ -520,40 +528,81 @@
}
self.callDestroy();
};
self.setElevation(WEAPON_HEIGHT_BASE);
- self.setRadius(self.graphics.width);
+ self.setRadius(self.graphics.width / 2);
return self;
});
var PickupHealing = Pickup.expand(function (config) {
var self = Pickup.call(this, config);
var updateBase = self.update;
- self.attachAsset('pickupHealing', {
+ self.tags[TAG_HEALING] = true;
+ self.graphics = self.attachAsset('pickupHealing', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 1.0
});
self.update = function () {
if (hero.health < hero.healthMax) {
updateBase();
}
};
self.onActivate = function () {
hero.healPercentage(PICKUP_HEAL_MINOR);
+ self.callDestroy();
};
self.onDestroy = function () {
pickupHealthCount--;
};
pickupHealthCount++;
- // Enable inheritance
+ self.setRadius(self.graphics.width / 2);
return self;
});
+var PickupExperience = Pickup.expand(function (config) {
+ var self = Pickup.call(this, config);
+ self.experience = config.experience;
+ // Try combine experience
+ var combineCount = 1;
+ var combineX = self.x;
+ var combineY = self.y;
+ for (var i = backgroundContainer.children.length - 1; i >= 0; i--) {
+ var child = backgroundContainer.children[i];
+ if (child.tags[TAG_PICKUP] && child.tags[TAG_EXPERIENCE] && child.intersectRadius(self.x, self.y, PICKUP_XP_COMBINE_RANGE)) {
+ self.experience += child.experience;
+ combineX += child.x;
+ combineY += child.y;
+ child.callDestroy();
+ }
+ }
+ self.x = combineX / combineCount;
+ self.y = combineY / combineCount;
+ // Set the graphics
+ var size = self.experience >= PICKUP_XP_LARGE ? 'Large' : self.experience >= PICKUP_XP_MEDIUM ? 'Medium' : 'Small';
+ self.graphics = self.createAsset('pickupExperience' + size, {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.update = function () {
+ if (!isPaused) {
+ if (self.activated) {
+ var direction = Math.atan2(hero.y - self.y, hero.x - self.x);
+ self.moveInDirection(direction, PICKUP_XP_SPEED);
+ if (self.intersectsInstance(hero)) {
+ hero.addExperience(self.experience);
+ self.callDestroy();
+ }
+ } else if (self.intersectRadius(hero.x, hero.y, PICKUP_XP_ACTIVATE_RANGE)) {
+ self.activate();
+ }
+ }
+ };
+ self.setRadius(self.graphics.width / 2);
+});
var PickupCrucifix = Pickup.expand(function (config) {
var self = Pickup.call(this, config);
self.tags[TAG_CRUCIFIX] = true;
- self.pickupRange = PICKUP_CRUCIFIX_RANGE;
- self.attachAsset('pickupCrucifix', {
+ self.graphics = self.attachAsset('pickupCrucifix', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 1.0
});
self.onActivate = function () {
for (var i = midgroundContainer.children.length - 1; i >= 0; i--) {
var child = midgroundContainer.children[i];
@@ -563,17 +612,18 @@
}
for (var i = backgroundContainer.children.length - 1; i >= 0; i--) {
var child = backgroundContainer.children[i];
if (child.tags[TAG_PICKUP] && child.tags[TAG_EXPERIENCE]) {
- child.onActivate();
+ child.activate();
}
}
self.callDestroy();
};
self.onDestroy = function () {
pickupCrucifixCount--;
};
pickupCrucifixCount++;
+ self.setRadius(self.graphics.width / 2);
return self;
});
var Hero = GameInstance.expand(function (config) {
var self = GameInstance.call(this, config);
@@ -626,9 +676,15 @@
if (experience >= levelRequirement) {
level++;
experience -= levelRequirement;
levelRequirement = Math.floor(levelRequirement * 1.2);
- // onLevelUp(level);
+ levelTxt.setText(level);
+ if (level % BOON_MAJOR_LEVEL) {
+ minorBoonCount++;
+ } else {
+ majorBoonCount++;
+ }
+ upgradeButton.setCount(minorBoonCount + majorBoonCount);
}
experienceBar.setPercentage(experience / levelRequirement);
};
self.takeDamage = function (amount) {
@@ -642,9 +698,9 @@
};
self.healPercentage = function (percentage) {
if (percentage > 0) {
self.health = Math.min(self.healthMax, self.health + self.healthMax * percentage);
- LK.effects.flashObject(self.collision, HERO_COLOUR, 1000);
+ LK.effects.flashObject(self.graphics, HERO_COLOUR, 1000);
}
healthBar.updatePercentage(self.health / self.healthMax);
};
// Enable inheritance
@@ -719,33 +775,33 @@
self.takeDamage = function (amount) {
damageTaken += amount;
if (damageTaken >= self.health) {
self.callDestroy();
+ } else {
+ if (!self.healthBar) {
+ self.healthBar = self.addChild(new ProgressBar({
+ y: self.healthOffset,
+ tint: ENEMY_COLOUR
+ }));
+ }
+ self.healthBar.updatePercentage(Math.max(0, 1 - damageTaken / self.health));
+ LK.effects.flashObject(self.graphics, ENEMY_COLOUR, 1000);
}
- if (!healthBar) {
- healthBar = self.addChild(new ProgressBar({
- y: self.healthOffset,
- tint: ENEMY_COLOUR
- }));
- }
- healthBar.updatePercentage(Math.max(0, 1 - damageTaken / self.health));
- LK.effects.flashObject(self.graphics, ENEMY_COLOUR, 1000);
};
self.onDestroy = function () {
dropExperience();
enemyCount--;
- foregroundContainer.addChild(new EffectEnemyDeath({
- x: self.x,
- y: self.y
- }));
+ // foregroundContainer.addChild(new EffectEnemyDeath({
+ // x: self.x,
+ // y: self.y
+ // }));
};
self.onUpdate = function () {};
self.onAttack = function () {};
- // Private functions
function dropExperience() {
var amount = self.xpDropBase;
if (self.xpDropChance > 0) {
- for (var i = 0; i <= minorBoonLevels['Luck']; i++) {
+ for (var i = 0; i <= minorBoonLevels[BOON_LUCK]; i++) {
if (Math.random() < self.xpDropChance) {
amount++;
}
}
@@ -758,9 +814,8 @@
}));
}
}
enemyCount++;
- // Enable inheritance
return self;
});
var EnemyRanged = Enemy.expand(function (config) {
var self = Enemy.call(this, config);
@@ -852,9 +907,9 @@
}
}
};
self.setElevation(ENEMY_BASIC_GRAPHICS_OFFSET);
- self.setRadius(80);
+ self.setRadius(45);
return self;
});
/**
* config {
@@ -1018,8 +1073,9 @@
var TAG_PICKUP = 'Pickup';
var TAG_EXPERIENCE = 'Experience';
var TAG_CRUCIFIX = 'Crucifix';
var TAG_WEAPON = 'Weapon';
+var TAG_HEALING = 'Healing';
;
// Hero settings
var HERO_COLOUR = 0x0FA0FF;
var HERO_BORDER = 250;
@@ -1030,8 +1086,9 @@
var HERO_XP_REQUIRED = 20;
var HERO_XP_SCALING = 1.2;
;
// Boon settings
+var BOON_MAJOR_LEVEL = 5;
var BOON_LUCK = 'Luck';
var BOON_SCALE = 'Scale';
var BOON_RANGE = 'Range';
var BOON_DAMAGE = 'Damage';
@@ -1049,9 +1106,9 @@
var WEAPON_CROSS_SPLIT_INCREMENT = 20 / 180 * Math.PI;
var WEAPON_CROSS_RANGE_BASE = 200;
var WEAPON_CROSS_RANGE_SCALING = 100;
var WEAPON_CROSS_RANGE_VARIATION = 0.1;
-var WEAPON_CROSS_RADIUS_BASE = 80;
+var WEAPON_CROSS_RADIUS_BASE = 40;
var WEAPON_CROSS_SCALE_SCALING = 0.35;
var WEAPON_CROSS_SCALE_DAMAGE_FACTOR = 0.1;
var WEAPON_CROSS_COOLDOWN_HIT = GAME_TICKS / 6;
var WEAPON_CROSS_COOLDOWN_BASE = 120;
@@ -1075,24 +1132,26 @@
var ENEMY_SPAWN_DELAY = 2 * GAME_TICKS;
var ENEMY_SPAWN_RATE_BASE = 1 * GAME_TICKS;
var ENEMY_SPAWN_RATE_SCALE = 0.75 * GAME_TICKS;
var ENEMY_SPAWN_RATE_MIN = 0.25 * GAME_TICKS;
-var ENEMY_LIMIT = 1;
+var ENEMY_LIMIT = 40;
var ENEMY_XP_RANGE = 50;
var ENEMY_STATE_MOVE = 'Move';
var ENEMY_STATE_FLEE = 'Flee';
var ENEMY_STATE_ATTACK = 'Attack';
+;
var ENEMY_BASIC_SPEED = 2.5;
var ENEMY_BASIC_HEALTH_BASE = 10;
var ENEMY_BASIC_HEALTH_SCALE = 50;
var ENEMY_BASIC_HEALTH_OFFSET = 30;
var ENEMY_BASIC_ATTACK_RANGE = 100;
var ENEMY_BASIC_ATTACK_DAMAGE = 10;
var ENEMY_BASIC_ATTACK_COOLDOWN = GAME_TICKS / 6;
-var ENEMY_BASIC_GRAPHICS_OFFSET = 100;
+var ENEMY_BASIC_GRAPHICS_OFFSET = 175;
var ENEMY_BASIC_BOB_MAGNITUDE = 20;
var ENEMY_BASIC_BOB_PERIOD = 10;
var ENEMY_BASIC_XP_DROP_CHANCE = 0.3; // Per level of Luck
+;
var ENEMY_RANGED_SPEED = 1.5;
var ENEMY_RANGED_HEALTH_BASE = 20;
var ENEMY_RANGED_HEALTH_SCALE = 60;
var ENEMY_RANGED_HEALTH_OFFSET = 20;
@@ -1120,8 +1179,13 @@
var PICKUP_HEALTH_CHANCE = 0.02; // Per level of luck
var PICKUP_CRUCIFIX_COUNT = 1;
var PICKUP_CRUCIFIX_RANGE = 200;
var PICKUP_WEAPON_RANGE = 200;
+var PICKUP_XP_MEDIUM = 5;
+var PICKUP_XP_LARGE = 10;
+var PICKUP_XP_SPEED = 20;
+var PICKUP_XP_COMBINE_RANGE = 150;
+var PICKUP_XP_ACTIVATE_RANGE = 300;
;
//==============================================================================
// Instances & variables
//==============================================================================
@@ -1170,11 +1234,11 @@
var interfaceContainer = game.addChild(new Container());
var hero = midgroundContainer.addChild(new Hero({
x: GAME_WIDTH / 2,
y: GAME_HEIGHT / 2,
- radius: 150
+ radius: 75
}));
-/*
+/*
backgroundContainer.addChild(new PickupWeapon({
x: GAME_WIDTH / 4 * 2,
y: GAME_HEIGHT / 4,
scale: 1.25,
@@ -1201,9 +1265,9 @@
y: GAME_HEIGHT - 750,
size: 200,
callback: function callback() {
if (minorBoonCount + majorBoonCount > 0) {
- showBoonSelection();
+ // showBoonSelection();
}
}
}));
var countdownTimer = interfaceContainer.addChild(new UiCountdownTimer({
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