Code edit (9 edits merged)
Please save this source code
User prompt
add an update function to the Interface class that takes in the player's `distanceTravelled` variable as a parameter, and displays (just the numerical value) the value to the right of the class
User prompt
Fix Bug: 'ReferenceError: DIFFICULTY_FACTOR_DIST is not defined' in this line: 'var newDensity = (1 + Math.pow(Math.log(player.distanceTravelled / DIFFICULTY_FACTOR_DIST + 2), 2)) / 100;' Line Number: 251
User prompt
Fix Bug: 'ReferenceError: MONSTER_SPAWN_DIST is not defined' in this line: 'if (player.distanceTravelled > MONSTER_SPAWN_DIST && Math.random() <= SPAWN_MONSTER_CHANCE) {' Line Number: 223
User prompt
Replace LandscapeTile's distanceFactor and monsterDistance variables with globals called DIFFICULTY_FACTOR_DIST and MONSTER_SPAWN_DIST respectively. Make sure to update all usages of these variables within the LandscapeTile class
Code edit (4 edits merged)
Please save this source code
User prompt
in the ramp update function, return true if the ramp's y becomes less than -200
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: rampList is undefined' in this line: 'rampList.push(landmark = self.parent.addChild(new Ramp(pointX, pointY)));' Line Number: 223
User prompt
Fix Bug: 'TypeError: rampList is undefined' in this line: 'rampList.push(landmark = self.parent.addChild(new Ramp(pointX, pointY)));' Line Number: 223
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: parent.addChild is not a function' in this line: 'parent.addChild(self);' Line Number: 342
Code edit (4 edits merged)
Please save this source code
User prompt
create a rampList variable, and iterate through each ramp, calling it's update function
Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: graphics is not defined' in this line: 'rampPillar.y = graphics.height;' Line Number: 320
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: playerGraphics is undefined' in this line: 'playerShadow.y = playerGraphics.height * 0.5;' Line Number: 366
User prompt
the player has a `shadow` asset underneath it
User prompt
ramps have a `rampShadow` asset underneath them
User prompt
ramps have a `rampPillar` asset underneath them
User prompt
if a landscape tile fails to create a pickup (in it's activate method), try create a ramp with a 5% chance
User prompt
add a ramp class with an update method that checks for a collision with the player
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,9 +1,6 @@
-var DropEffect = Container.expand(function (parent, x, y) {
+var DropEffect = Container.expand(function (x, y) {
var self = Container.call(this);
- parent.addChild(self);
- self.x = x;
- self.y = y;
var angle = Math.random() * Math.PI;
var speed = 10 + Math.random() * 5;
var speedX = Math.cos(angle) * speed;
var speedY = Math.sin(angle) * speed;
@@ -12,9 +9,13 @@
var scaleDecrement = 1 / 60;
var variant = Math.floor(Math.random() * 3);
var graphics = self.createAsset('pickup' + variant, 'Drop graphics', 0.5, 0.95);
graphics.rotation = Math.random() * Math.PI * 2;
+ ;
+ self.x = x;
+ self.y = y;
self.update = update;
+ ;
function update(velocityX, velocityY) {
self.x += speedX - velocityX;
self.y += speedY - velocityY;
scale -= scaleDecrement;
@@ -22,21 +23,22 @@
graphics.scale.set(scale);
return scale <= 0;
}
});
-var BloodsplatterEffect = Container.expand(function (parent, x, y) {
+var BloodsplatterEffect = Container.expand(function (x, y) {
var self = Container.call(this);
- parent.addChild(self);
- self.x = x;
- self.y = y;
var duration = 15;
var remaining = duration;
var maxScale = 2.0;
var startAlpha = 0.5;
var graphics = self.createAsset('bloodsplatter', 'Bloodsplatter graphics', 0.5, 0.5);
graphics.alpha = startAlpha;
graphics.y = -graphics.height / 2;
+ ;
+ self.x = x;
+ self.y = y;
self.update = update;
+ ;
function update(velocityX, velocityY) {
var progress = 1 - remaining-- / duration;
if (remaining <= 0) {
return true;
@@ -46,13 +48,10 @@
self.x -= velocityX;
self.y -= velocityY;
}
});
-var Monster = Container.expand(function (parent, x, y) {
+var Monster = Container.expand(function (x, y) {
var self = Container.call(this);
- parent.addChild(self);
- self.x = x;
- self.y = y;
var active = false;
var updateTick = 0;
var updatePeriod = 30;
var jumpSpeedMax = 30;
@@ -73,11 +72,15 @@
shadow.width = graphics.width * 0.9;
shadow.height = graphics.width * 0.45;
shadow.tint = 0x000000;
shadow.alpha = 0.5;
+ ;
+ self.x = x;
+ self.y = y;
self.jumping = false;
self.hitbox = shadow;
self.update = update;
+ ;
function update(velocityX, velocityY, player) {
if (!active) {
var dx = player.x - self.x;
var dy = player.y - self.y;
@@ -118,13 +121,10 @@
self.y += jumpVelocityY - velocityY;
return self.y < despawnY;
}
});
-var Pickup = Container.expand(function (parent, x, y) {
+var Pickup = Container.expand(function (x, y) {
var self = Container.call(this);
- parent.addChild(self);
- self.x = x;
- self.y = y;
var activeDist = 300;
var activeDistSqr = activeDist * activeDist;
var collectDist = 50;
var collectDistSqr = collectDist * collectDist;
@@ -140,9 +140,13 @@
backShadow.width = graphics.width;
backShadow.height = graphics.width * 0.25;
backShadow.tint = 0x000000;
backShadow.y = -3;
+ ;
+ self.x = x;
+ self.y = y;
self.update = update;
+ ;
function update(velocityX, velocityY, player) {
var dx = player.x - self.x;
var dy = player.y + collectOffset - self.y;
var distSqr = dx * dx + dy * dy;
@@ -212,16 +216,16 @@
var cellHeight = height / rows;
var landmark;
if (Math.random() <= 0.1) {
var {pointX, pointY} = randomPointInRect(self.x, self.y, width, height, clearanceDist);
- pickups.push(landmark = new Pickup(parent, pointX, pointY));
+ pickups.push(landmark = self.parent.addChild(new Pickup(pointX, pointY)));
} else if (Math.random() <= 0.05) {
var {pointX, pointY} = randomPointInRect(self.x, self.y, width, height, clearanceDist);
- rampList.push(landmark = self.parent.addChild(new Ramp(parent, pointX, pointY)));
+ rampList.push(landmark = self.parent.addChild(new Ramp(pointX, pointY)));
}
if (player.distanceTravelled > monsterDistance && Math.random() <= monsterChance) {
var {pointX, pointY} = randomPointInRect(self.x, self.y, width, height, clearanceDist);
- monsters.push(new Monster(parent, self.x, self.y));
+ monsters.push(self.parent.addChild(new Monster(self.x, self.y)));
}
for (i = 0; i < cols; i++) {
for (j = 0; j < rows; j++) {
if (Math.random() <= densityChance) {
@@ -236,9 +240,9 @@
}
}
if (canPlace) {
var type = obstructionTypes[Math.floor(Math.random() * obstructionTypes.length)];
- obstructions.push(new Obstruction(self, pointX, pointY, type));
+ obstructions.push(self.addChild(new Obstruction(pointX, pointY, type)));
}
}
}
}
@@ -307,9 +311,9 @@
};
}
}
});
-var Ramp = Container.expand(function (parent, x, y) {
+var Ramp = Container.expand(function (x, y) {
var self = Container.call(this);
var rampPillar = self.createAsset('rampPillar', 'Ramp pillar graphics', 0.5, 0.5);
var rampShadow = self.createAsset('rampShadow', 'Ramp shadow graphics', 0.5, -0.2);
var rampGraphics = self.createAsset('ramp', 'Ramp graphics', 0.5, 0);
@@ -321,9 +325,8 @@
hitbox.width = rampGraphics.width;
hitbox.height = 50;
hitbox.alpha = 0;
;
- parent.addChild(self);
self.x = x;
self.y = y;
self.hitbox = hitbox;
self.update = update;
@@ -335,9 +338,8 @@
}
});
var Obstruction = Container.expand(function (parent, x, y, type) {
var self = Container.call(this);
- parent.addChild(self);
self.x = x;
self.y = y;
var graphics = self.createAsset(type, 'Obstruction graphics', 0.5, 1);
var hitbox = self.createAsset('hitbox', 'Obstruction hitbox', 0.5, 0.5);
@@ -443,13 +445,11 @@
}
}
}
});
-var Interface = Container.expand(function (parent, x, y) {
+var Interface = Container.expand(function (x, y) {
var self = Container.call(this);
- parent.addChild(self);
- self.x = x;
- self.y = y;
+ ;
var score = 0;
var lives = 3;
var lifeIcons = [];
var scoreIcon = self.createAsset('scoreIcon', 'Score icon', 0.5, 0);
@@ -467,8 +467,11 @@
}
scoreText.x = -5;
scoreText.y = scoreIcon.height;
scoreText.anchor.set(0, 0);
+ ;
+ self.x = x;
+ self.y = y;
self.changeScore = changeScore;
self.changeLives = changeLives;
function changeLives(amount) {
lives += amount;
@@ -511,9 +514,9 @@
background.height = stageHeight;
var interface = LK.gui.topCenter.addChild(new Interface(0, 10));
var trail = self.addChild(new Trail(playerPosX, playerPosY));
var player = self.addChild(new Player(playerPosX, playerPosY));
- landscapeTiles.push(self.addChild(landscapeLookup['0:0'] = new LandscapeTile(player.x, player.y, {
+ landscapeTiles.push(landscapeLookup['0:0'] = self.addChild(new LandscapeTile(player.x, player.y, {
width: tileSize,
height: tileSize,
density: -1,
lookup: landscapeLookup,
Pixel art of a Santa. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
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 christmas 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 of a christmas present counter. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a christmas present. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a blue christmas present. 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.