User prompt
Please fix the bug: 'ReferenceError: tint is not defined' in or related to this line: 'var bar = self.attachAsset('shapeBox', {' Line Number: 73
Code edit (7 edits merged)
Please save this source code
User prompt
add an outlineSmall asset to the joystickKnob and an outlineLarge asset to the joystick
Code edit (2 edits merged)
Please save this source code
User prompt
add a new sorting container (inheriting from Container) that has an update function that sorts it's children array by their ascending y value
Code edit (3 edits merged)
Please save this source code
User prompt
Replace all usages of the 'blank' asset with the 'shapeBox' asset
User prompt
Migrate to the latest version of LK
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
flash the CrossWeapon's aimArrow and the FireballWeapon's projectileLaunchers white during the launch function
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: tryUpdateLaunchers is not defined' in this line: 'tryUpdateLaunchers(args);' Line Number: 1024
Code edit (14 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: existingEffect.refresh is not a function' in this line: 'existingEffect.refresh({' Line Number: 803
Code edit (5 edits merged)
Please save this source code
User prompt
when a fireballProjectile explodes, it should attach a BurningEffect class to the nearbyEnemies which deals damage to the enemy every second for 2 seconds. The application should be done in the nearbyEnemy foreach loop.
User prompt
when a fireballProjectile explodes, it should attach a BurningEffect class to the nearbyEnemies which deals damage to the enemy every second for 2 seconds
Code edit (1 edits merged)
Please save this source code
Code edit (13 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: args.effects is undefined' in this line: 'args.effects.push(new FireballExplosion(args.foregroundContainer, self.x, self.y, 100));' Line Number: 771
User prompt
when a FireballProjectile impacts an enemy, add all enemies in 100 range to the hitlist and create a FireballExplosion effect
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
The fireballprojectiles enemy for-loop should use the LinkedList foreach instead
/**** * Classes ****/ var ConfigContainer = Container.expand(function (config) { var self = Container.call(this); config = config || {}; // Private variables var destroyCalled = false; // Public variables self.x = config.x || 0; self.y = config.y || 0; self.rotation = config.rotation || 0; self.alpha = config.alpha !== undefined ? config.alpha : 1.0; if (config.scale !== undefined || config.scaleX !== undefined || config.scaleY !== undefined) { var scaleX = config.scaleX !== undefined ? config.scaleX : config.scale !== undefined ? config.scale : 1; var scaleY = config.scaleY !== undefined ? config.scaleY : config.scale !== undefined ? config.scale : 1; self.scale.set(scaleX, scaleY); } // Public functions self.callDestroy = function () { if (!destroyCalled) { destroyCalled = true; self.onDestroy(); destroy(); } }; self.onDestroy = function () {}; // Enable inheritance return self; }); var ProgressBar = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var width = config.width || 100; var height = config.height || 10; var weight = config.weight || 4; self.attachAsset('shapeBox', { width: width + 2 * weight, height: height + 2 * weight, anchorX: 0.5, anchorY: 0.5, tint: 0x000000 }); var tint = config.tint || 0xFFFFFF; var bar = self.attachAsset('shapeBox', { x: -width, width: width, height: height, anchorX: 0.5, anchorY: 0.5, tint: tint }); self.updatePercentage = function (percentage) { bar.scale.x = Math.min(1.0, Math.max(0, percentage)); }; if (config.percentage !== undefined) { self.updatePercentage(config.percentage); } }); var JoystickKnob = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); self.attachAsset('shapeEllipse', { width: config.size, height: config.size, anchorX: 0.5, anchorY: 0.5, tint: 0x808080, alpha: 0.5 }); self.attachAsset('joystickKnob', { width: config.size * 0.65, height: config.size * 0.65, anchorX: 0.5, anchorY: 0.5, tint: 0x000000 }); self.attachAsset('outlineSmall', { width: config.size + 5, height: config.size + 5, anchorX: 0.5, anchorY: 0.5, tint: 0x000000 }); return self; }); var Joystick = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var size = config.size || 100; var maxDistance = size / 2; var base = self.attachAsset('shapeEllipse', { width: size, height: size, anchorX: 0.5, anchorY: 0.5, tint: 0xA0A0A0, alpha: 0.5 }); self.attachAsset('outlineLarge', { width: size + 5, height: size + 5, anchorX: 0.5, anchorY: 0.5, tint: 0x000000 }); var knob = self.addChild(new JoystickKnob({ size: size / 2 })); var pressed = false; self.magnitude = 0; self.direction = undefined; self.down = function (x, y, obj) { if (x === 0 && y === 0) { self.magnitude = 0; self.direction = undefined; } else { var distance = Math.sqrt(x * x + y * y); if (distance <= size / 2) { pressed = true; knob.x = x; knob.y = y; self.magnitude = distance / maxDistance; self.direction = Math.atan2(y, x); } } }; self.movement = function (x, y, obj) { if (pressed) { if (x === 0 && y === 0) { self.magnitude = 0; self.direction = undefined; } else { var distance = Math.sqrt(x * x + y * y); var direction = Math.atan2(y, x); if (distance > maxDistance) { x = Math.cos(direction) * maxDistance; y = Math.sin(direction) * maxDistance; distance = maxDistance; } knob.x = x; knob.y = y; self.magnitude = distance / maxDistance; self.direction = direction; } } }; self.release = function (x, y, obj) { pressed = false; self.magnitude = 0; self.direction = undefined; knob.x = 0; knob.y = 0; }; return self; }); var Hero = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); self.speed = HERO_SPEED_BASE; self.healthMax = HERO_HEALTH_BASE; self.health = self.healthMax; var healthBar = self.addChild(new ProgressBar({ y: -self.height / 2 - 10, tint: HERO_COLOUR })); self.update = function () { if (!isPaused && joystick.direction !== undefined) { self.rotation = joystick.direction; var speedX = Math.cos(joystick.direction) * joystick.magnitude * self.speed; var speedY = Math.sin(joystick.direction) * joystick.magnitude * self.speed; self.x += speedX; self.y += speedY; if (self.x < HERO_BORDER) { self.x = HERO_BORDER; } else if (self.x > GAME_WIDTH - HERO_BORDER) { self.x = GAME_WIDTH - HERO_BORDER; } if (self.y < HERO_BORDER) { self.y = HERO_BORDER; } else if (self.y > GAME_WIDTH - HERO_BORDER) { self.y = GAME_WIDTH - HERO_BORDER; } self.scale.x = speedX < 0 ? -1 : 1; } }; self.takeDamage = function (amount) { self.health = Math.max(0, self.health - amount); healthBar.updatePercentage(self.health / self.healthMax); LK.effects.flashObject(self.collision, 0xAA0000, 1000); if (self.health <= 0) { LK.effects.flashScreen(0xAA0000, 1000); LK.showGameOver(); } }; 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); } healthBar.updatePercentage(self.health / self.healthMax); }; }); var SortingContainer = Container.expand(function () { var self = Container.call(this); self.update = function () { self.children.sort(function (a, b) { return a.y - b.y; }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ ; //============================================================================== // Global constants & settings //============================================================================== ; var GAME_TICKS = 60; var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; ; // Hero settings var HERO_COLOUR = 0x0FA0FF; var HERO_BORDER = 200; var HERO_HEALTH_BASE = 100; var HERO_HEALTH_BONUS = 30; var HERO_SPEED_BASE = 8; var HERO_SPEED_BONUS = 2; var HERO_XP_REQUIRED = 20; var HERO_XP_SCALING = 1.2; // Enemy settings var ENEMY_COLOUR = 0xAA0000; var ENEMY_BORDER = 50; // Forced minimum move distance from the edge of the screen var ENEMY_BORDER_SPAWN = -100; 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_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_BOB_MAGNITUDE = 2; 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; var ENEMY_RANGED_RANGE_MIN = 500; var ENEMY_RANGED_RANGE_VAR = 250; var ENEMY_RANGED_ATTACK_DAMAGE = 5; var ENEMY_RANGED_MOVE_COOLDOWN_ADJUSTMENT = -0.5; var ENEMY_RANGED_GRAPHICS_OFFSET = -100; var ENEMY_RANGED_FLEE_DISTANCE_FACTOR = 0.35; var ENEMY_RANGED_FLEE_SPEED_FACTOR = 1.5; var ENEMY_RANGED_SCALE_PERIOD = 20; var ENEMY_RANGED_SCALE_MAGNITUDE = 0.05; var ENEMY_RANGED_XP_DROP_BASE = 2; var ENEMY_RANGED_XP_DROP_CHANCE = 0.5; // Per level of Luck var ENEMY_RANGED_DIFFICULTY = 0.2; var ENEMY_RANGED_SPAWN_CHANCE_MIN = 0.4; var ENEMY_RANGED_SPAWN_CHANCE_FACTOR = 0.5; // Pickup settings var PICKUP_HEAL_MINOR = 0.1; var PICKUP_HEAL_MAJOR = 1.0; var PICKUP_HEALTH_COUNT = 3; var PICKUP_HEALTH_CHANCE = 0.02; // Per level of luck var PICKUP_CRUCIFIX_COUNT = 1; var PICKUP_CRUCIFIX_RANGE = 100; var PICKUP_WEAPON_RANGE = 100; ; //============================================================================== // Instances & variables //============================================================================== ; // Variables var isPaused = false; var level = 1; var experience = 0; var levelRequirement = HERO_XP_REQUIRED; var enemyCount = 0; var minorBoonCount = 0; var majorBoonCount = 0; var pickupHealthCount = 0; var pickupCrucifixCount = 0; var difficultyScale = 0; var startingWeapons = []; var minorBoonLevels = { 'Luck': 0, 'Scale': 0, 'Range': 0, 'Damage': 0, 'Rearm': 0, 'Duration': 0, 'Health': 0, 'Speed': 0 }; var majorBoonLevels = { 'Growth': 0, 'Split': 0 }; ; // Game instances game.attachAsset('grassTop', { y: HERO_BORDER - 100, x: GAME_WIDTH / 2, anchorX: 0.5 }); game.attachAsset('grassBot', { y: GAME_HEIGHT - HERO_BORDER + 100, x: GAME_WIDTH / 2, anchorX: 0.5, anchorY: 1.0 }); var backgroundContainer = game.addChild(new Container()); var midBackContainer = game.addChild(new SortingContainer()); var hero = game.addChild(new Hero({ x: GAME_WIDTH / 2, y: GAME_HEIGHT / 2 })); var midFrontContainer = game.addChild(new SortingContainer()); var foregroundContainer = game.addChild(new Container()); var joystick = game.addChild(new Joystick({ size: 400, x: GAME_WIDTH - 400, y: GAME_HEIGHT - 400 })); ; //============================================================================== // Global events //============================================================================== ; // Add event listeners for the joystick game.move = function (x, y, obj) { joystick.movement(x - joystick.x, y - joystick.y, obj); }; game.up = function (x, y, obj) { joystick.release(x, y, obj); }; ; //============================================================================== // Global helper functions //============================================================================== ; function checkBounds(x, y) { var borderOrBorderX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var borderY = arguments.length > 3 ? arguments[3] : undefined; return x < borderOrBorderX || x > 2048 - borderOrBorderX || y < (borderY || borderOrBorderX) || y > 2732 - (borderY || borderOrBorderX); } function addExperience(amount) { experience += amount; if (experience >= levelRequirement) { level++; experience -= levelRequirement; levelRequirement = Math.floor(levelRequirement * 1.2); // onLevelUp(level); } progressBar.setPercentage(experience / levelRequirement); }
===================================================================
--- original.js
+++ change.js
@@ -27,33 +27,59 @@
self.onDestroy = function () {};
// Enable inheritance
return self;
});
+var ProgressBar = ConfigContainer.expand(function (config) {
+ var self = ConfigContainer.call(this, config);
+ var width = config.width || 100;
+ var height = config.height || 10;
+ var weight = config.weight || 4;
+ self.attachAsset('shapeBox', {
+ width: width + 2 * weight,
+ height: height + 2 * weight,
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0x000000
+ });
+ var tint = config.tint || 0xFFFFFF;
+ var bar = self.attachAsset('shapeBox', {
+ x: -width,
+ width: width,
+ height: height,
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: tint
+ });
+ self.updatePercentage = function (percentage) {
+ bar.scale.x = Math.min(1.0, Math.max(0, percentage));
+ };
+ if (config.percentage !== undefined) {
+ self.updatePercentage(config.percentage);
+ }
+});
var JoystickKnob = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
self.attachAsset('shapeEllipse', {
width: config.size,
height: config.size,
anchorX: 0.5,
anchorY: 0.5,
- tint: 0xA0A0A0,
+ tint: 0x808080,
alpha: 0.5
});
self.attachAsset('joystickKnob', {
width: config.size * 0.65,
height: config.size * 0.65,
anchorX: 0.5,
anchorY: 0.5,
- tint: 0x000000,
- alpha: 0.75
+ tint: 0x000000
});
self.attachAsset('outlineSmall', {
- width: config.size,
- height: config.size,
+ width: config.size + 5,
+ height: config.size + 5,
anchorX: 0.5,
anchorY: 0.5,
- tint: 0x000000,
- alpha: 0.75
+ tint: 0x000000
});
return self;
});
var Joystick = ConfigContainer.expand(function (config) {
@@ -64,18 +90,17 @@
width: size,
height: size,
anchorX: 0.5,
anchorY: 0.5,
- tint: 0x808080,
+ tint: 0xA0A0A0,
alpha: 0.5
});
self.attachAsset('outlineLarge', {
- width: size,
- height: size,
+ width: size + 5,
+ height: size + 5,
anchorX: 0.5,
anchorY: 0.5,
- tint: 0x000000,
- alpha: 0.75
+ tint: 0x000000
});
var knob = self.addChild(new JoystickKnob({
size: size / 2
}));
@@ -125,8 +150,54 @@
knob.y = 0;
};
return self;
});
+var Hero = ConfigContainer.expand(function (config) {
+ var self = ConfigContainer.call(this, config);
+ self.speed = HERO_SPEED_BASE;
+ self.healthMax = HERO_HEALTH_BASE;
+ self.health = self.healthMax;
+ var healthBar = self.addChild(new ProgressBar({
+ y: -self.height / 2 - 10,
+ tint: HERO_COLOUR
+ }));
+ self.update = function () {
+ if (!isPaused && joystick.direction !== undefined) {
+ self.rotation = joystick.direction;
+ var speedX = Math.cos(joystick.direction) * joystick.magnitude * self.speed;
+ var speedY = Math.sin(joystick.direction) * joystick.magnitude * self.speed;
+ self.x += speedX;
+ self.y += speedY;
+ if (self.x < HERO_BORDER) {
+ self.x = HERO_BORDER;
+ } else if (self.x > GAME_WIDTH - HERO_BORDER) {
+ self.x = GAME_WIDTH - HERO_BORDER;
+ }
+ if (self.y < HERO_BORDER) {
+ self.y = HERO_BORDER;
+ } else if (self.y > GAME_WIDTH - HERO_BORDER) {
+ self.y = GAME_WIDTH - HERO_BORDER;
+ }
+ self.scale.x = speedX < 0 ? -1 : 1;
+ }
+ };
+ self.takeDamage = function (amount) {
+ self.health = Math.max(0, self.health - amount);
+ healthBar.updatePercentage(self.health / self.healthMax);
+ LK.effects.flashObject(self.collision, 0xAA0000, 1000);
+ if (self.health <= 0) {
+ LK.effects.flashScreen(0xAA0000, 1000);
+ LK.showGameOver();
+ }
+ };
+ 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);
+ }
+ healthBar.updatePercentage(self.health / self.healthMax);
+ };
+});
var SortingContainer = Container.expand(function () {
var self = Container.call(this);
self.update = function () {
self.children.sort(function (a, b) {
@@ -161,8 +232,10 @@
var HERO_HEALTH_BASE = 100;
var HERO_HEALTH_BONUS = 30;
var HERO_SPEED_BASE = 8;
var HERO_SPEED_BONUS = 2;
+var HERO_XP_REQUIRED = 20;
+var HERO_XP_SCALING = 1.2;
// Enemy settings
var ENEMY_COLOUR = 0xAA0000;
var ENEMY_BORDER = 50; // Forced minimum move distance from the edge of the screen
var ENEMY_BORDER_SPAWN = -100;
@@ -218,8 +291,11 @@
//==============================================================================
;
// Variables
var isPaused = false;
+var level = 1;
+var experience = 0;
+var levelRequirement = HERO_XP_REQUIRED;
var enemyCount = 0;
var minorBoonCount = 0;
var majorBoonCount = 0;
var pickupHealthCount = 0;
@@ -242,20 +318,24 @@
};
;
// Game instances
game.attachAsset('grassTop', {
- y: HERO_BORDER,
+ y: HERO_BORDER - 100,
x: GAME_WIDTH / 2,
anchorX: 0.5
});
game.attachAsset('grassBot', {
- y: GAME_HEIGHT - HERO_BORDER,
+ y: GAME_HEIGHT - HERO_BORDER + 100,
x: GAME_WIDTH / 2,
anchorX: 0.5,
anchorY: 1.0
});
var backgroundContainer = game.addChild(new Container());
var midBackContainer = game.addChild(new SortingContainer());
+var hero = game.addChild(new Hero({
+ x: GAME_WIDTH / 2,
+ y: GAME_HEIGHT / 2
+}));
var midFrontContainer = game.addChild(new SortingContainer());
var foregroundContainer = game.addChild(new Container());
var joystick = game.addChild(new Joystick({
size: 400,
@@ -273,5 +353,24 @@
};
game.up = function (x, y, obj) {
joystick.release(x, y, obj);
};
-;
\ No newline at end of file
+;
+//==============================================================================
+// Global helper functions
+//==============================================================================
+;
+function checkBounds(x, y) {
+ var borderOrBorderX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
+ var borderY = arguments.length > 3 ? arguments[3] : undefined;
+ return x < borderOrBorderX || x > 2048 - borderOrBorderX || y < (borderY || borderOrBorderX) || y > 2732 - (borderY || borderOrBorderX);
+}
+function addExperience(amount) {
+ experience += amount;
+ if (experience >= levelRequirement) {
+ level++;
+ experience -= levelRequirement;
+ levelRequirement = Math.floor(levelRequirement * 1.2);
+ // onLevelUp(level);
+ }
+ progressBar.setPercentage(experience / levelRequirement);
+}
\ No newline at end of file
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