Code edit (3 edits merged)
Please save this source code
User prompt
change the slightly brown tint to #FFEADB instead
User prompt
change the slightly brown tint to #FFD9BD instead
User prompt
change the slightly brown tint to #f5cfb3 instead
User prompt
change the slightly brown tint to C7AD99
Code edit (1 edits merged)
Please save this source code
User prompt
tint the uiBoonBackground and uiBoonUpgrade assets of the UiBoonSelection class slightly brown
Code edit (2 edits merged)
Please save this source code
User prompt
Rename the uiBoonButton asset to uiBoonSelection and update all usages in the code
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: ENEMY_RANGED_ATTACK_COOLDOWN is not defined' in or related to this line: 'self.attackCooldown = ENEMY_RANGED_ATTACK_COOLDOWN;' Line Number: 855
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.updatePercentage is not a function' in or related to this line: 'self.updatePercentage(config.percentage);' Line Number: 282
User prompt
rename the progressBar class's updatePercentage function to setPercentage and update all usages in other classes
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -77,9 +77,9 @@
}
for (var i = 0; i < splitCount; i++) {
var splitAngle = WEAPON_CROSS_SPLIT_INCREMENT / 2 * (splitCount <= 1 ? 1 : Math.random() - 0.5);
var direction = baseAngle + i * WEAPON_CROSS_SPLIT_INCREMENT + splitAngle;
- midFrontContainer.addChild(new ProjectileCross({
+ midgroundContainer.addChild(new ProjectileCross({
x: hero.x,
y: hero.y,
direction: direction,
linger: linger + Math.floor(WEAPON_CROSS_LINGER_VARIANCE * Math.random()),
@@ -96,9 +96,8 @@
var self = ConfigContainer.call(this, config);
var countdown = config.countdown;
var ticker = 60;
var countdownTxt = self.addChild(new BorderedText('', {
- size: 80,
anchorX: .5,
anchorY: 0
}));
self.update = function () {
@@ -142,23 +141,17 @@
anchorY: 0.5,
tint: 0x000000
});
var countTxt = self.addChild(new BorderedText('0', {
- y: config.size / 4,
fill: config.fill,
anchorX: .5,
- anchorY: .5
+ anchorY: .4
}));
button.on('down', function (x, y, obj) {
obj.event = obj;
config.callback(obj);
});
//self.visible = false;
- self.update = function () {
- var scaleFactor = 1 + Math.sin(LK.ticks / 10) * 0.1;
- countTxt.scale.x = scaleFactor;
- countTxt.scale.y = scaleFactor;
- };
self.setHidden = function (newHidden) {
hidden = newHidden;
self.checkHidden();
};
@@ -234,39 +227,8 @@
}));
}
return self;
});
-var ProjectileEnemy = ConfigContainer.expand(function (config) {
- var self = ConfigContainer.call(this, config);
- var speedX = ENEMY_RANGED_SPEED_PROJECTILE * Math.cos(self.rotation);
- var speedY = ENEMY_RANGED_SPEED_PROJECTILE * Math.sin(self.rotation);
- var radiusSqr = ENEMY_RANGED_PROJECTILE_RADIUS * ENEMY_RANGED_PROJECTILE_RADIUS;
- var projectileAsset = self.attachAsset('projectileEnemy', {
- anchorX: 0.5,
- anchorY: 0.5,
- rotation: -MATH_QUARTER_PI
- });
- self.update = function () {
- if (!isPaused) {
- self.x += speedX;
- self.y += speedY;
- var dx = hero.x - self.x;
- var dy = hero.y + heightDifference - self.y;
- var distanceSqr = dx * dx + dy * dy;
- if (LK.ticks % 15 === 0) {
- projectileAsset.scale.x *= -1;
- projectileAsset.scale.y *= -1;
- projectileAsset.rotation += Math.PI;
- }
- if (distanceSqr <= radiusSqr) {
- hero.takeDamage(damage);
- self.callDestroy();
- } else if (!checkBounds(self.x, self.y, ENEMY_BORDER_SPAWN)) {
- self.callDestroy();
- }
- }
- };
-});
var ProgressBar = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var width = config.width || 120;
var height = config.height || 15;
@@ -292,106 +254,8 @@
self.updatePercentage(config.percentage);
}
return self;
});
-var Pickup = ConfigContainer.expand(function (config) {
- var self = ConfigContainer.call(this, config);
- self.tags[TAG_PICKUP] = true;
- self.activated = false;
- self.pickupRange = 0;
- self.update = function () {
- if (!isPaused && !self.activated) {
- var dx = hero.x - self.x;
- var dy = hero.y - self.y;
- var distanceSqr = dx * dx + dy * dy;
- if (distanceSqr <= self.pickupRange * self.pickupRange) {
- 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.pickupRange = PICKUP_WEAPON_RANGE;
- var graphics = self.attachAsset(config.graphics, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- updateBase();
- var scaleFactor = 1 + Math.sin(LK.ticks / 10) * 0.1;
- graphics.scale.x = scaleBase.x * scaleFactor;
- graphics.scale.y = scaleBase.y * scaleFactor;
- };
- self.onActivate = function () {
- hero.addChild(new config.weaponClass());
- 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();
- }
- }
- self.callDestroy();
- };
- return self;
-});
-var PickupHealing = Pickup.expand(function (config) {
- var self = Pickup.call(this, config);
- var updateBase = self.update;
- self.attachAsset('pickupHealing', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- if (hero.health < hero.healthMax) {
- updateBase();
- }
- };
- self.onActivate = function () {
- hero.healPercentage(PICKUP_HEAL_MINOR);
- };
- self.onDestroy = function () {
- pickupHealthCount--;
- };
- pickupHealthCount++;
- // Enable inheritance
- return self;
-});
-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', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.onActivate = function () {
- for (var i = midgroundContainer.children.length - 1; i >= 0; i--) {
- var child = midgroundContainer.children[i];
- if (child.tags[TAG_ENEMY]) {
- child.callDestroy();
- }
- }
- 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();
- }
- }
- self.callDestroy();
- };
- self.onDestroy = function () {
- pickupCrucifixCount--;
- };
- pickupCrucifixCount++;
- return self;
-});
var JoystickKnob = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
self.attachAsset('shapeEllipse', {
width: config.size,
@@ -504,8 +368,22 @@
self.moveInDirection = function (direction, speed) {
self.x += Math.cos(direction) * speed;
self.y += Math.sin(direction) * speed * GAME_PERSPECTIVE;
};
+ self.intersectsInstance = function (instance) {
+ return self.intersectsRadius(instance.x, instance.y, instance.radius);
+ };
+ self.intersectsRadius = function (pointX, pointY, radius) {
+ var dx = pointX - self.x;
+ var dy = (pointY - self.y) / GAME_PERSPECTIVE;
+ var distance = self.radius + radius;
+ return distance * distance >= dx * dx + dy * dy;
+ };
+ self.intersectsPoint = function (pointX, pointY) {
+ var dx = pointX - self.x;
+ var dy = (pointY - self.y) / GAME_PERSPECTIVE;
+ return self.radius * self.radius >= dx * dx + dy * dy;
+ };
self.setRadius = function (newRadius) {
self.radius = newRadius;
shadowGraphics.width = newRadius;
shadowGraphics.height = newRadius * GAME_PERSPECTIVE;
@@ -521,8 +399,124 @@
self.onRadiusChanged = function (newRadius) {};
self.onElevationChanged = function (newElevation) {};
return self;
});
+var ProjectileEnemy = GameInstance.expand(function (config) {
+ var self = GameInstance.call(this, config);
+ var projectileAsset = self.attachAsset('projectileEnemy', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ rotation: config.direction - MATH_QUARTER_PI
+ });
+ self.update = function () {
+ if (!isPaused) {
+ self.moveInDirection(config.direction, ENEMY_RANGED_SPEED_PROJECTILE);
+ if (LK.ticks % 15 === 0) {
+ projectileAsset.scale.x *= -1;
+ projectileAsset.scale.y *= -1;
+ projectileAsset.rotation += Math.PI;
+ }
+ if (self.intersectsInstance(hero)) {
+ hero.takeDamage(config.damage);
+ self.callDestroy();
+ } else if (!checkBounds(self.x, self.y, ENEMY_BORDER_SPAWN)) {
+ self.callDestroy();
+ }
+ }
+ };
+});
+var Pickup = GameInstance.expand(function (config) {
+ var self = GameInstance.call(this, config);
+ self.tags[TAG_PICKUP] = true;
+ self.activated = false;
+ self.update = function () {
+ if (!isPaused && !self.activated && self.intersectsInstance(hero)) {
+ 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,
+ rotation: -Math.PI / 8
+ });
+ self.update = function () {
+ updateBase();
+ self.setElevation(WEAPON_HEIGHT_BASE + Math.sin(LK.ticks / WEAPON_HEIGHT_PERIOD) * WEAPON_HEIGHT_MAGNITUDE);
+ };
+ self.onActivate = function () {
+ hero.addChild(new config.weaponClass());
+ 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();
+ }
+ }
+ self.callDestroy();
+ };
+ self.setElevation(WEAPON_HEIGHT_BASE);
+ self.setRadius(self.graphics.width);
+ return self;
+});
+var PickupHealing = Pickup.expand(function (config) {
+ var self = Pickup.call(this, config);
+ var updateBase = self.update;
+ self.attachAsset('pickupHealing', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ if (hero.health < hero.healthMax) {
+ updateBase();
+ }
+ };
+ self.onActivate = function () {
+ hero.healPercentage(PICKUP_HEAL_MINOR);
+ };
+ self.onDestroy = function () {
+ pickupHealthCount--;
+ };
+ pickupHealthCount++;
+ // Enable inheritance
+ return self;
+});
+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', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.onActivate = function () {
+ for (var i = midgroundContainer.children.length - 1; i >= 0; i--) {
+ var child = midgroundContainer.children[i];
+ if (child.tags[TAG_ENEMY]) {
+ child.callDestroy();
+ }
+ }
+ 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();
+ }
+ }
+ self.callDestroy();
+ };
+ self.onDestroy = function () {
+ pickupCrucifixCount--;
+ };
+ pickupCrucifixCount++;
+ return self;
+});
var Hero = GameInstance.expand(function (config) {
var self = GameInstance.call(this, config);
// Private variables
var level = 1;
@@ -949,9 +943,9 @@
var TEXT_DEFAULT_WEIGHT = 4; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
var TEXT_DEFAULT_BORDER = '#000000'; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
var TEXT_DEFAULT_FILL = '#FFFFFF'; // Required by: BorderedText, SymbolText
var TEXT_DEFAULT_FONT = 'Consolas'; // Required by: BorderedText, SymbolText
-var TEXT_DEFAULT_SIZE = 50; // Required by: BorderedText, SymbolText
+var TEXT_DEFAULT_SIZE = 100; // Required by: BorderedText, SymbolText
;
// Game constants
var GAME_TICKS = 60;
var GAME_WIDTH = 2048;
@@ -988,8 +982,11 @@
var BOON_GROWTH = 'Growth';
var BOON_SPLIT = 'Split';
;
// Weapon settings
+var WEAPON_HEIGHT_BASE = 50;
+var WEAPON_HEIGHT_PERIOD = 10;
+var WEAPON_HEIGHT_MAGNITUDE = 10;
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;
@@ -1128,9 +1125,8 @@
backgroundContainer.addChild(new PickupWeapon({
x: GAME_WIDTH / 4 * 2,
y: GAME_HEIGHT / 4 * 3,
scale: 1.25,
- rotation: -Math.PI / 8,
graphics: 'weaponCross',
weaponClass: WeaponCross
}));
;
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