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
User prompt
Create a particle effect class called DropEffect using the same graphics assets as the pickups (excluding shadows). When colliding with an obstruction, create a DropEffect particle which shoots away in a random direction from the player, spinning and shrinking.
Code edit (12 edits merged)
Please save this source code
User prompt
monsters start with a random x flip
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: jumpSpeed is not defined' in this line: 'jumpVelocityX = Math.cos(angle) * jumpSpeed;' Line Number: 65
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Add an effects array to the game class, and add a BloodsplatterEffect class, which lasts for 1s, growing larger and more transparent, and is also affected by the player velocity. When a monster is destroyed after taking a player life, create a BloodsplatterEffect
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -160,13 +160,10 @@
}
return distSqr <= collectDistSqr;
}
});
-var LandscapeTile = Container.expand(function (parent, x, y, {lookup, xIndex, yIndex, width, height, density, pickups, monsters, player, key, landscapeTiles}) {
+var LandscapeTile = Container.expand(function (x, y, {lookup, xIndex, yIndex, width, height, density, pickups, monsters, player, key, landscapeTiles, rampList}) {
var self = Container.call(this);
- parent.addChild(self);
- self.x = x;
- self.y = y;
var pickupChance = 0.1;
var monsterChance = 0.01;
var distanceFactor = 10000;
var monsterDistance = 20000;
@@ -174,14 +171,18 @@
var visual = self.createAsset('hitbox', 'Landscape area', 0.5, 0.5);
visual.alpha = 0;
visual.width = width;
visual.height = height;
+ ;
+ self.x = x;
+ self.y = y;
self.activate = activate;
self.width = width;
self.height = height;
self.active = false;
self.key = key;
self.checkCollision = checkCollision;
+ ;
function checkCollision(player) {
var reach = 100;
var dx = Math.abs(player.x - self.x);
var dy = Math.abs(player.y - self.y);
@@ -200,26 +201,23 @@
if (!self.active) {
self.active = true;
var densityChance = density * Math.random();
var obstructionTypes = ['largeTree', 'smallTree', 'smallTree', 'deadTree', 'smallRock', 'smallRock', 'largeRock', 'stump'];
- var clearanceDist = 150;
+ var clearanceDist = 300;
var clearanceDistSqr = clearanceDist * clearanceDist;
var spawnBorder = 25;
var cellSize = 150;
var cols = Math.ceil(width / cellSize);
var rows = Math.ceil(height / cellSize);
var cellWidth = width / cols;
var cellHeight = height / rows;
- var pickup;
- var pickupCreated = false;
+ var landmark;
if (Math.random() <= 0.1) {
var {pointX, pointY} = randomPointInRect(self.x, self.y, width, height, clearanceDist);
- pickups.push(pickup = new Pickup(parent, pointX, pointY));
- pickupCreated = true;
- }
- if (!pickupCreated && Math.random() <= 0.05) {
+ pickups.push(landmark = new Pickup(parent, pointX, pointY));
+ } else if (Math.random() <= 0.05) {
var {pointX, pointY} = randomPointInRect(self.x, self.y, width, height, clearanceDist);
- new Ramp(parent, pointX, pointY);
+ rampList.push(landmark = self.parent.addChild(new Ramp(parent, 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));
@@ -228,11 +226,11 @@
for (j = 0; j < rows; j++) {
if (Math.random() <= densityChance) {
var canPlace = true;
var {pointX, pointY} = randomPointInRect(cellWidth * i, cellHeight * j, cellWidth, cellHeight, spawnBorder);
- if (pickup) {
- var dx = pickup.x - pointX;
- var dy = pickup.y - pointY;
+ if (landmark) {
+ var dx = landmark.x - pointX;
+ var dy = landmark.y - pointY;
var distSqr = dx * dx + dy * dy;
if (distSqr <= clearanceDistSqr) {
canPlace = false;
}
@@ -249,39 +247,41 @@
var rightKey = xIndex + 1 + ':' + yIndex;
var downKey = xIndex + ':' + (yIndex + 1);
var newDensity = (1 + Math.pow(Math.log(player.distanceTravelled / distanceFactor + 2), 2)) / 100;
if (!lookup[leftKey]) {
- landscapeTiles.push(lookup[leftKey] = new LandscapeTile(parent, self.x - width, self.y, {
+ landscapeTiles.push(lookup[leftKey] = self.parent.addChild(new LandscapeTile(self.x - width, self.y, {
key: leftKey,
density: newDensity,
xIndex: xIndex - 1,
yIndex,
landscapeTiles,
+ rampList,
width,
height,
lookup,
pickups,
monsters,
player
- }));
+ })));
}
if (!lookup[rightKey]) {
- landscapeTiles.push(lookup[rightKey] = new LandscapeTile(parent, self.x + width, self.y, {
+ landscapeTiles.push(lookup[rightKey] = self.parent.addChild(new LandscapeTile(self.x + width, self.y, {
key: rightKey,
density: newDensity,
xIndex: xIndex + 1,
yIndex,
landscapeTiles,
+ rampList,
width,
height,
lookup,
pickups,
monsters,
player
- }));
+ })));
}
if (!lookup[downKey]) {
- landscapeTiles.push(lookup[downKey] = new LandscapeTile(parent, self.x, self.y + height, {
+ landscapeTiles.push(lookup[downKey] = self.parent.addChild(new LandscapeTile(self.x, self.y + height, {
key: downKey,
density: newDensity,
yIndex: yIndex + 1,
xIndex,
@@ -291,9 +291,9 @@
lookup,
pickups,
monsters,
player
- }));
+ })));
}
function randomPointInRect(centerX, centerY, width, height, border = 0) {
var startX = centerX - width / 2 + border;
var startY = centerY - height / 2 + border;
@@ -508,25 +508,25 @@
var rampList = [];
var speed = 0;
background.width = stageWidth;
background.height = stageHeight;
- var interface = new Interface(self, 0, 10);
- LK.gui.topCenter.addChild(interface);
+ 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(landscapeLookup['0:0'] = new LandscapeTile(self, player.x, player.y, {
+ landscapeTiles.push(self.addChild(landscapeLookup['0:0'] = new LandscapeTile(player.x, player.y, {
width: tileSize,
height: tileSize,
density: -1,
lookup: landscapeLookup,
xIndex: 0,
yIndex: 0,
key: '0:0',
landscapeTiles,
+ rampList,
monsters,
pickups,
player
- }));
+ })));
var isMouseDown = false;
var targetPosition = {
x: playerPosX,
y: playerPosY
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.