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
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.
===================================================================
--- 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