Code edit (4 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: removedElement is null' in this line: 'removedElement.destroy();' Line Number: 249
Code edit (8 edits merged)
Please save this source code
User prompt
the new trailelement should be scaled and rotated to match the velocity
User prompt
Add an update function that takes in a velocityX and velocityY to the Trail class. The update function creates a `blank` asset and adds it to a list, if the list has more than 60 elements the first element is removed. All elements have their x and y adjusted by the velocityX and velocityY
User prompt
Create a Trail class that takes a `parent`, `x`, and `y` parameters
User prompt
Create a Trail class that takes a `parent`, `x`, `y`, and `args` parameters.
Code edit (1 edits merged)
Please save this source code
User prompt
make the player invulnerable for 3 seconds after landscapeTile.checkCollision returns true
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
flash the screen red when losing a life instead of on game over
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: scoreText is not defined' in this line: 'scoreText.setText(score);' Line Number: 328
User prompt
Move the displayed score, score icon and lives into its own Interface class. This class should have changeLives(amount) and changeScore(amount) functions which change the score and lives values by the amount
User prompt
Fix Bug: 'TypeError: self.gameInstance.lifeIcons is undefined' in this line: 'var lifeIcon = self.gameInstance.lifeIcons[self.gameInstance.lives];' Line Number: 191
User prompt
Fix Bug: 'TypeError: self.parent.lifeIcons is undefined' in this line: 'var lifeIcon = self.parent.lifeIcons[self.parent.lives];' Line Number: 190
User prompt
The player should have 3 lives, displayed as three icons under the score. The player should lose 1 life when colliding with an obstacle, and the obstacle should become inactive
User prompt
Fix Bug: 'ReferenceError: velocityX is not defined' in this line: 'playerGraphics.scale.x = velocityX < 0 ? -1 : 1;' Line Number: 193
Code edit (1 edits merged)
Please save this source code
User prompt
landscapeTiles should create the pickup before the obstructions, additionally, if a pickup is created, prevent spawning obstructions within 200 distance from the pickup
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
when a pickup is within 200*200 distance squared from the player, the pickup becomes active, flying towards the player at a speed of 5
Code edit (4 edits merged)
Please save this source code
var Pickup = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
var graphics = self.createAsset('pickup', 'Pickup graphics', 0.5, 0.5);
self.hitbox = self.createAsset('hitbox', 'Pickup hitbox', 0.5, 0.5);
self.hitbox.width = graphics.width;
self.hitbox.height = graphics.height;
self.hitbox.alpha = 0;
});
var LandscapeTile = Container.expand(function (parent, x, y, args) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
var landscapeTiles = args.landscapeTiles;
var lookup = args.lookup;
var xIndex = args.xIndex;
var yIndex = args.yIndex;
var width = args.width;
var height = args.height;
var density = args.density;
var pickups = args.pickups;
var key = args.key;
self.checkCollision = checkCollision;
self.activate = activate;
self.width = width;
self.height = height;
self.active = false;
self.key = key;
var obstructions = [];
var visual = self.createAsset('hitbox', 'Landscape area', 0.5, 0.5);
visual.alpha = 0;
visual.width = width;
visual.height = height;
function checkCollision(player) {
var reach = 100;
var dx = Math.abs(player.x - self.x);
var dy = Math.abs(player.y - self.y);
if (dx < width / 2 + reach && dy < height / 2 + reach) {
for (var i = 0; i < obstructions.length; i++) {
if (player.hitbox.intersects(obstructions[i].hitbox)) {
return true;
}
}
}
return false;
}
function activate() {
if (!self.active) {
self.active = true;
var densityChance = Math.pow(1 + density, 3) / 100;
var obstructionTypes = ['largeTree', 'smallTree', 'deadTree', 'rock', 'stump'];
var spawnBorder = 10;
var cellSize = 100;
var cols = Math.ceil(width / cellSize);
var rows = Math.ceil(height / cellSize);
var cellWidth = width / cols;
var cellHeight = height / rows;
var cellInnerWidth = Math.max(0, cellWidth - 2 * spawnBorder);
var cellInnerHeight = Math.max(0, cellHeight - 2 * spawnBorder);
for (i = 0; i < cols; i++) {
for (j = 0; j < rows; j++) {
if (Math.random() <= densityChance) {
var obsX = cellWidth * i + spawnBorder + Math.random() * cellInnerWidth - width / 2;
var obsY = cellHeight * j + spawnBorder + Math.random() * cellInnerHeight - height / 2;
var type = obstructionTypes[Math.floor(Math.random() * obstructionTypes.length)];
obstructions.push(new Obstruction(self, obsX, obsY, type));
}
}
}
if (Math.random() <= 0.1) {
var pickupX = self.x + Math.random() * width - width / 2;
var pickupY = self.y + Math.random() * height - height / 2;
pickups.push(new Pickup(parent, pickupX, pickupY));
}
}
var leftKey = xIndex - 1 + ':' + yIndex;
var rightKey = xIndex + 1 + ':' + yIndex;
var downKey = xIndex + ':' + (yIndex + 1);
if (!lookup[leftKey]) {
landscapeTiles.push(lookup[leftKey] = new LandscapeTile(parent, self.x - width, self.y, {
key: leftKey,
density: Math.random(),
xIndex: xIndex - 1,
yIndex,
landscapeTiles,
width,
height,
lookup,
pickups
}));
}
if (!lookup[rightKey]) {
landscapeTiles.push(lookup[rightKey] = new LandscapeTile(parent, self.x + width, self.y, {
key: rightKey,
density: Math.random(),
xIndex: xIndex + 1,
yIndex,
landscapeTiles,
width,
height,
lookup,
pickups
}));
}
if (!lookup[downKey]) {
landscapeTiles.push(lookup[downKey] = new LandscapeTile(parent, self.x, self.y + height, {
key: downKey,
density: Math.random(),
yIndex: yIndex + 1,
xIndex,
landscapeTiles,
width,
height,
lookup,
pickups
}));
}
}
});
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 randomScale = 0.9 + Math.random() * 0.2;
self.scale.set(randomScale, randomScale);
self.hitbox = self.createAsset('hitbox', 'Obstruction hitbox', 0.5, 0.5);
self.hitbox.y = -25;
self.hitbox.alpha = 0;
self.hitbox.width = graphics.width * 0.8;
self.hitbox.height = graphics.width * 0.45;
});
var Player = Container.expand(function () {
var self = Container.call(this);
self.playerGraphics = self.createAsset('player', 'Player character', 0.575, 1);
self.platformGraphics = self.createAsset('platform', 'Platform image', 0.5, 0.5);
self.addChild(self.playerGraphics);
self.hitbox = self.createAsset('hitbox', 'Player Hitbox', 0.5, 0.5);
self.hitbox.width = 25;
self.hitbox.height = 25;
self.hitbox.alpha = 0;
self.addChild(self.hitbox);
});
var Game = Container.expand(function () {
var self = Container.call(this);
var stageWidth = 2048;
var stageHeight = 2732;
var tileSize = 512;
var tileMargin = tileSize / 2 + 100;
var background = self.createAsset('background', 'Fullscreen background', 0, 0);
var landscapeLookup = {};
var landscapeTiles = [];
var pickups = [];
var direction = {
x: 0,
y: 0
};
var speed = 0;
background.width = stageWidth;
background.height = stageHeight;
var targetPosition = {
x: 0,
y: 0
};
var player = new Player();
self.addChild(player);
player.x = stageWidth / 2;
player.y = stageHeight / 5;
var speedText = new Text2('Speed: 0', {
size: 50,
fill: "#000000",
align: 'right'
});
speedText.anchor.set(1, 0);
speedText.x = stageWidth;
speedText.y = 0;
landscapeTiles.push(landscapeLookup['0:0'] = new LandscapeTile(self, player.x, player.y, {
width: tileSize,
height: tileSize,
density: -1,
lookup: landscapeLookup,
xIndex: 0,
yIndex: 0,
key: '0:0',
landscapeTiles
}));
var score = 0;
var scoreIcon = LK.getAsset('scoreIcon', 'Score icon', 1, 0);
var scoreText = new Text2(score, {
size: 80,
fill: "#000000",
align: 'left'
});
scoreIcon.x = -10;
scoreIcon.y = 20;
scoreText.x = 10;
scoreText.y = 20;
scoreText.anchor.set(0, 0);
LK.gui.topCenter.addChild(scoreIcon);
LK.gui.topCenter.addChild(scoreText);
var isMouseDown = false;
stage.on('down', function (obj) {
isMouseDown = true;
updatePosition(obj.event);
});
stage.on('up', function (obj) {
isMouseDown = false;
});
stage.on('move', function (obj) {
if (isMouseDown) {
updatePosition(obj.event);
}
});
LK.on('tick', function () {
var dx = targetPosition.x - player.x;
var dy = targetPosition.y - player.y;
var angle = angleClamp(Math.atan2(dy, dx));
var acceleration = (Math.sin(angle) - 0.1) * 2.0;
speed = Math.max(0, speed * 0.95 + acceleration);
player.platformGraphics.rotation = angle + Math.PI / 2;
var velocityX = Math.cos(angle) * speed;
var velocityY = Math.sin(angle) * speed;
for (var i = landscapeTiles.length - 1; i >= 0; i--) {
var landscapeTile = landscapeTiles[i];
landscapeTile.x -= velocityX;
landscapeTile.y -= velocityY;
if (landscapeTile.y < -(tileSize / 2 + tileMargin)) {
landscapeTile.destroy();
landscapeTiles.splice(i, 1);
landscapeLookup[landscapeTile.key] = undefined;
} else if (!landscapeTile.active && landscapeTile.x > -tileMargin && landscapeTile.x < stageWidth + tileMargin && landscapeTile.y < stageHeight + tileMargin) {
landscapeTile.activate();
} else if (landscapeTile.checkCollision(player)) {
LK.showGameOver();
}
}
for (var i = pickups.length - 1; i >= 0; i--) {
var pickup = pickups[i];
pickup.x -= velocityX;
pickup.y -= velocityY;
if (pickup.y < -(tileSize / 2 + tileMargin)) {
pickup.destroy();
pickups.splice(i, 1);
} else if (player.hitbox.intersects(pickup.hitbox)) {
score++;
pickup.destroy();
pickups.splice(i, 1);
}
}
scoreText.setText(score);
});
function angleClamp(angle) {
return angle >= 0 ? angle : angle < -Math.PI / 2 ? Math.PI : 0;
}
function updatePosition(event) {
var pos = event.getLocalPosition(self);
targetPosition.x = pos.x;
targetPosition.y = pos.y;
player.playerGraphics.scale.x = targetPosition.x < player.x ? -1 : 1;
}
});
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.