Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: LK.gui.topLeft.bottomCenter is undefined' in this line: 'var instructions = LK.gui.topLeft.bottomCenter.addChild(new Instructions());' Line Number: 679
User prompt
Fix Bug: 'TypeError: LK.gui.topLeft.bottomCenter is undefined' in this line: 'var instructions = LK.gui.topLeft.bottomCenter.addChild(new Instructions());' Line Number: 679
User prompt
add an instructions class which display the following text at the bottom of the screen: "Tap, click or drag to change direction and collect flags!"
Code edit (7 edits merged)
Please save this source code
User prompt
when calling the interface's update method, pass through the player's netSpeed and display it under the distance
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: playerGraphics is not defined' in this line: 'playerGraphics.y = -self.rampHeight;' Line Number: 444
User prompt
The playerGraphics should be split into two distinct graphics playerFront and playerSide graphics. In the update function, if the angle is roughly pointing downwards, then set the front alpha to 1 and the side to 0, otherwise invert the alphas
Code edit (1 edits merged)
Please save this source code
User prompt
add a banner asset to the interface
User prompt
tint the heart black when losing it, in the interface
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
visually set the scoreIcon to be on the right of the scoreText
Code edit (5 edits merged)
Please save this source code
User prompt
in the game on tick, iterate through the pickupProjectileList and calling it's update statement
Code edit (4 edits merged)
Please save this source code
User prompt
create a pickupProjectile class that has an update function to move towards the player at a speed of 20
Code edit (1 edits merged)
Please save this source code
User prompt
when the pickup decor flips, randomly scale the decor's x to be between PICKUP_FLIP_SCALE and 1
Code edit (1 edits merged)
Please save this source code
User prompt
remove any console.logs
Code edit (11 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,28 +1,19 @@
-var DropEffect = Container.expand(function (x, y) {
+var PickupProjectile = Container.expand(function (x, y, target) {
var self = Container.call(this);
- var angle = Math.random() * Math.PI;
- var speed = 10 + Math.random() * 5;
- var speedX = Math.cos(angle) * speed;
- var speedY = Math.sin(angle) * speed;
- var spinSpeed = Math.random() * 0.2 - 0.1;
- var scale = 1;
- var scaleDecrement = 1 / 60;
- var graphics = self.createAsset('pickupProjectile', 'Drop graphics', 0.5, 0.95);
- graphics.rotation = Math.random() * Math.PI * 2;
- ;
+ var speed = 20;
+ var graphics = self.createAsset('pickupProjectile', 'Pickup Projectile graphics', 0.5, 0.5);
self.x = x;
self.y = y;
- self.update = update;
- ;
- function update(velocityX, velocityY) {
- self.x += speedX - velocityX;
- self.y += speedY - velocityY;
- scale -= scaleDecrement;
- graphics.rotation += spinSpeed;
- graphics.scale.set(scale);
- return scale <= 0;
- }
+ self.update = function () {
+ var dx = target.x - self.x;
+ var dy = target.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ var velocityX = dx / distance * speed;
+ var velocityY = dy / distance * speed;
+ self.x += velocityX;
+ self.y += velocityY;
+ };
});
var BloodsplatterEffect = Container.expand(function (x, y) {
var self = Container.call(this);
var duration = 15;
@@ -150,9 +141,9 @@
activate();
} else if (--flipTickCounter <= 0) {
flipScaling *= -1;
decor.y += flipOffsetY * flipScaling;
- decor.scale.set(flipScaling, PICKUP_FLIP_SCALE + Math.random() * (1 - PICKUP_FLIP_SCALE));
+ decor.scale.set(PICKUP_FLIP_SCALE + Math.random() * (1 - PICKUP_FLIP_SCALE), flipScaling);
flipTickCounter = randomizeFlipTicks();
}
}
if (!tilted && !player.airborne && distSqr <= PICKUP_TILT_SQRDIST) {
@@ -380,9 +371,8 @@
var rampRemaining = 0;
var rampDuration = 0;
var rampHeight = 0;
var rampHeightMax = 0;
- var tiltSpeedFactor = 100;
var playerShadow = self.createAsset('shadow', 'Player shadow', 0.5, 0.5);
var platformGraphics = self.createAsset('platform', 'Platform image', 0.4, 0.5);
var playerGraphics = self.createAsset('player', 'Player character', 0.45, 1);
var hitbox = self.createAsset('hitbox', 'Player Hitbox', 0.5, 0.5);
@@ -423,21 +413,22 @@
var dx = targetPosition.x - self.x;
var dy = targetPosition.y - self.y;
angle = angleClamp(Math.atan2(dy, dx));
}
- var acceleration = (Math.sin(angle) - 0.1) * 2.0;
+ var acceleration = (Math.sin(angle) - PLAYER_ACCELERATION_ANGLE) * PLAYER_ACCELERATION_MAGNITUDE;
var boost = self.airborne ? RAMP_SPEED_BOOST : 1;
reduction = self.invulnerable ? 1 - self.invulnerableTimer / self.invulnerableTime : 1;
- speed = Math.max(0, speed * 0.95 + acceleration);
- var velocityX = Math.cos(angle) * reduction * boost * speed;
- var velocityY = Math.sin(angle) * reduction * boost * speed;
+ speed = Math.max(0, speed * PLAYER_DECELERATION_FACTOR + acceleration);
+ var totalSpeed = speed * reduction * boost;
+ var velocityX = Math.cos(angle) * totalSpeed;
+ var velocityY = Math.sin(angle) * totalSpeed;
travelDistX += velocityX;
travelDistY += velocityY;
self.distanceTravelled = Math.sqrt(travelDistX * travelDistX + travelDistY * travelDistY);
if (!self.airborne) {
var facingSide = targetPosition.x < self.x ? -1 : 1;
platformGraphics.rotation = angle;
- playerGraphics.rotation = speed * reduction / tiltSpeedFactor * (Math.PI / 2) * facingSide;
+ playerGraphics.rotation = totalSpeed * facingSide / PLAYER_TILT_SPEED_FACTOR;
playerGraphics.scale.x = facingSide;
}
return {
velocityX,
@@ -561,8 +552,12 @@
var DIFFICULTY_FACTOR_DIST = 150 / SCREEN_METERAGE;
var TILE_SIZE = 512;
var TILE_MARGIN = TILE_SIZE;
var TILE_BACKGROUND_OFFSET = 100;
+var PLAYER_ACCELERATION_ANGLE = 0.1;
+var PLAYER_ACCELERATION_MAGNITUDE = 2.0;
+var PLAYER_DECELERATION_FACTOR = 0.95;
+var PLAYER_TILT_SPEED_FACTOR = 110 * Math.PI / 2;
var PICKUP_FLIP_BASE = 10;
var PICKUP_FLIP_VARIANCE = 60;
var PICKUP_FLIP_SCALE = 0.8;
var PICKUP_COLLECT_DIST = 300;
pixel art of a tree stump covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a dead tree covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a spruce tree covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a rock covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art heart icon . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
two vertical lines with a blank background.
pixel art of a large, snow covered rock . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of skiis . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a floating grinch monster . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
single green firework explosion . Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a wooden board covered in snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a wooden pole with snow at it's base. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tileable white water texture pixel art.
pixel art of a red flag. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a red orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white
white
pixel art shape of a red arrow pointing downwards. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art banner of a pair of skis crossed. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white