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
User prompt
Add a hitbox to the monster. After updating a monster, check if its hitbox intersects the player's hitbox, causing the player to lose a life
User prompt
The changeScore function should additionally call the LK.setScore function after adjusting the score
User prompt
ensure the score cannot go below zero
User prompt
instead of losing a life when colliding with an obstacle, reduce the score by 1, but keep the invulnerability system
User prompt
instead of losing a life when colliding with an obstacle, reduce the score by 1
Code edit (8 edits merged)
Please save this source code
User prompt
pickups should also have a shadow
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
the monsters have shadow assets underneath them
Code edit (5 edits merged)
Please save this source code
User prompt
after traveling 10000 distance, spawn a new Monster class at the bottom of the screen that heads towards the player, but is also affected by the VelocityX and VelocityY in it's update function
User prompt
add a monsters array variable to the game class
Code edit (1 edits merged)
Please save this source code
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.
===================================================================
--- original.js
+++ change.js
@@ -1,30 +1,27 @@
-var BloodsplatterEffect = Container.expand(function (parent, x, y, velocityX, velocityY) {
+var BloodsplatterEffect = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
- var startTime = LK.ticks;
var duration = 60;
- var maxSize = 200;
+ var remaining = duration;
+ var maxScale = 2.0;
var startAlpha = 0.75;
- self.update = function () {
- var elapsedTime = LK.ticks - startTime;
- var progress = elapsedTime / duration;
- if (progress >= 1) {
+ self.update = function (velocityX, velocityY) {
+ var progress = --remaining / duration;
+ if (progress < 0) {
self.destroy();
- return;
+ return true;
}
- var size = maxSize * progress;
+ var scale = 1 + (1 - maxScale) * progress;
var alpha = startAlpha * (1 - progress);
var graphics = self.createAsset('bloodsplatter', 'Bloodsplatter graphics', 0.5, 0.5);
- graphics.width = size;
- graphics.height = size;
+ graphics.scale.set(scale);
graphics.alpha = alpha;
self.x += velocityX;
self.y += velocityY;
};
- return self;
});
var Monster = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
@@ -51,9 +48,9 @@
shadow.width = graphics.width * 0.9;
shadow.height = graphics.width * 0.45;
shadow.tint = 0x000000;
shadow.alpha = 0.5;
- function update(player, velocityX, velocityY) {
+ function update(velocityX, velocityY, player) {
var dx = player.x - self.x;
var dy = player.y - self.y;
var distSqr = dx * dx + dy * dy;
var updateCurve = (-Math.sin(++updateTick / updatePeriod) + 0.5) / 1.5;
@@ -103,9 +100,9 @@
backShadow.width = graphics.width;
backShadow.height = graphics.width * 0.25;
backShadow.tint = 0x000000;
backShadow.y = -3;
- function update(player, velocityX, velocityY) {
+ function update(velocityX, velocityY, player) {
var dx = player.x - self.x;
var dy = player.y + collectOffset - self.y;
var distSqr = dx * dx + dy * dy;
if (self.active) {
@@ -477,9 +474,9 @@
}
}
for (var i = pickups.length - 1; i >= 0; i--) {
var pickup = pickups[i];
- if (pickup.update(player, velocityX, velocityY)) {
+ if (pickup.update(velocityX, velocityY, player)) {
interface.changeScore(1);
pickup.destroy();
pickups.splice(i, 1);
} else if (pickup.y < -(tileSize / 2 + tileMargin) || pickup.active && player.hitbox.intersects(pickup.hitbox)) {
@@ -487,17 +484,16 @@
pickups.splice(i, 1);
}
}
for (var i = effects.length - 1; i >= 0; i--) {
- effects[i].update();
- if (!effects[i].parent) {
+ if (effects[i].update(velocityX, velocityY)) {
effects.splice(i, 1);
}
}
for (var i = monsters.length - 1; i >= 0; i--) {
var monster = monsters[i];
- if (monster.update(player, velocityX, velocityY)) {
- effects.push(new BloodsplatterEffect(self.parent, self.x, self.y, velocityX, velocityY));
+ if (monster.update(velocityX, velocityY, player)) {
+ effects.push(new BloodsplatterEffect(self, monster.x, monster.y));
monster.destroy();
monsters.splice(i, 1);
} else if (!monster.jumping && monster.hitbox.intersects(player.hitbox)) {
interface.changeLives(-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.