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
@@ -62,26 +62,27 @@
for (var i = 0; i < midgroundContainer.children.length; i++) {
var child = midgroundContainer.children[i];
if (child.tags[TAG_ENEMY] && !child.tags[TAG_PROJECTILE]) {
var dx = hero.x - child.x;
- var dy = hero.y - child.y;
+ var dy = (hero.y - child.y) / GAME_PERSPECTIVE;
var distanceSqr = dx * dx + dy * dy;
if (distanceSqr < minDistanceSqr) {
minDistanceSqr = distanceSqr;
closestEnemy = child;
}
}
}
if (closestEnemy) {
- var angleToEnemy = Math.atan2(closestEnemy.y - hero.y, closestEnemy.x - hero.x);
+ var angleToEnemy = Math.atan2((closestEnemy.y - hero.y) / GAME_PERSPECTIVE, closestEnemy.x - hero.x);
baseAngle += angleToEnemy;
}
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;
midgroundContainer.addChild(new ProjectileCross({
x: hero.x,
y: hero.y,
+ elevation: WEAPON_CROSS_ELEVATION,
direction: direction,
linger: linger + Math.floor(WEAPON_CROSS_LINGER_VARIANCE * Math.random()),
range: range * (1 + WEAPON_CROSS_RANGE_VARIATION * (1 - 2 * Math.random())),
growthRate: growthRate,
@@ -431,11 +432,10 @@
var scale = config.scale;
var hitMap = {};
var growth = 1;
var speed = WEAPON_CROSS_SPEED_BASE;
- var height = WEAPON_CROSS_HEIGHT * scale;
self.graphics = self.attachAsset('projectileCross', {
- y: -height,
+ y: -config.elevation,
anchorX: 0.5,
anchorY: 0.5,
scaleX: config.scale,
scaleY: config.scale,
@@ -451,9 +451,8 @@
scale = config.scale * growth;
self.graphics.scale.x = scale;
self.graphics.scale.y = scale;
self.setRadius(WEAPON_CROSS_RADIUS_BASE * scale);
- self.setElevation(WEAPON_CROSS_HEIGHT * scale);
}
if (range <= 0) {
if (speed > -WEAPON_CROSS_SPEED_BASE) {
if (speed <= 0 && linger-- > 0) {
@@ -467,31 +466,22 @@
}
// Check for hits and deal damage
var currentTick = LK.ticks;
var damage = config.damage * (1 + (scale - 1) * WEAPON_CROSS_SCALE_DAMAGE_FACTOR);
- for (var i = midgroundContainer.length - 1; i >= 0; i--) {
- var child = midgroundContainer[i];
+ for (var i = midgroundContainer.children.length - 1; i >= 0; i--) {
+ var child = midgroundContainer.children[i];
var lastHitTick = hitMap[child.id];
- if (child.tags[TAG_ENEMY] && !child.tags[TAG_PROJECTILE] && !lastHitTick || currentTick - lastHitTick > WEAPON_CROSS_COOLDOWN_HIT) {
- var dx = child.x - self.x;
- var dy = child.y - self.y;
- var distanceSqr = dx * dx + dy * dy;
- if (distanceSqr <= self.radius * self.radius) {
- hitMap[child["if"]] = currentTick;
- enemy.takeDamage(damage);
- }
+ if (child.tags[TAG_ENEMY] && !child.tags[TAG_PROJECTILE] && (!lastHitTick || currentTick - lastHitTick > WEAPON_CROSS_COOLDOWN_HIT) && self.intersectsInstance(child)) {
+ hitMap[child.id] = currentTick;
+ child.takeDamage(damage);
}
}
// Destroy the projectile
- var dx = hero.x - self.x;
- var dy = hero.y - self.y;
- var distanceSqr = dx * dx + dy * dy;
- if (distanceSqr <= self.radius * self.radius || !checkBounds(self.x, self.y, WEAPON_CROSS_BORDER) && range < -config.range) {
+ if (speed <= 0 && self.intersectsInstance(hero) || range < -config.range && !checkBounds(self.x, self.y, WEAPON_CROSS_BORDER)) {
self.callDestroy();
}
};
self.setRadius(WEAPON_CROSS_RADIUS_BASE * config.scale);
- self.setElevation(WEAPON_CROSS_HEIGHT * config.scale);
return self;
});
var Pickup = GameInstance.expand(function (config) {
var self = GameInstance.call(this, config);
@@ -665,8 +655,9 @@
// Private variables
var damageTaken = 0;
var cooldown = 0;
// Public variables
+ self.tags[TAG_ENEMY] = true;
self.healthBar;
self.health = 0;
self.healthOffset = 0;
self.speed = 0;
@@ -684,11 +675,11 @@
var dx = hero.x - self.x;
var dy = hero.y - self.y;
var distanceSqr = dx * dx + dy * dy;
if (checkBounds(self.x, self.y, ENEMY_BORDER)) {
- if (self.fleeRange > 0 && distanceSqr < self.fleeRange * self.fleeRange) {
+ if (self.fleeRange > 0 && self.intersectsRadius(hero.x, hero.y, self.fleeRange)) {
state = ENEMY_STATE_FLEE;
- } else if (self.attackRange > 0 && distanceSqr <= self.attackRange * self.attackRange) {
+ } else if (self.attackRange > 0 && self.intersectsRadius(hero.x, hero.y, self.attackRange)) {
state = ENEMY_STATE_ATTACK;
}
}
var stateValues = self.adjustState(state, {
@@ -1012,9 +1003,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 = 100; // Required by: BorderedText, SymbolText
+var TEXT_DEFAULT_SIZE = 120; // Required by: BorderedText, SymbolText
;
// Game constants
var GAME_TICKS = 60;
var GAME_WIDTH = 2048;
@@ -1072,9 +1063,9 @@
var WEAPON_CROSS_LINGER_SCALING = 0.25 * GAME_TICKS;
var WEAPON_CROSS_GROWTH_SCALING = 0.15 / GAME_TICKS;
var WEAPON_CROSS_SPEED_BASE = 30;
var WEAPON_CROSS_SPEED_DECREMENT = 1;
-var WEAPON_CROSS_HEIGHT = 50;
+var WEAPON_CROSS_ELEVATION = 175;
var WEAPON_CROSS_ROTATION = 0.2;
var WEAPON_CROSS_BORDER = -1000;
;
// Enemy settings
@@ -1084,9 +1075,9 @@
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 = 40;
+var ENEMY_LIMIT = 1;
var ENEMY_XP_RANGE = 50;
var ENEMY_STATE_MOVE = 'Move';
var ENEMY_STATE_FLEE = 'Flee';
var ENEMY_STATE_ATTACK = 'Attack';
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