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
@@ -2,77 +2,79 @@
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
- var duration = 60;
+ var duration = 15;
var remaining = duration;
var maxScale = 2.0;
- var startAlpha = 0.75;
+ var startAlpha = 0.5;
+ var graphics = self.createAsset('bloodsplatter', 'Bloodsplatter graphics', 0.5, 0.5);
+ graphics.alpha = startAlpha;
+ graphics.y = -graphics.height / 2;
self.update = function (velocityX, velocityY) {
- var progress = --remaining / duration;
- if (progress < 0) {
- self.destroy();
+ var progress = 1 - remaining-- / duration;
+ if (remaining <= 0) {
return true;
}
- var scale = 1 + (1 - maxScale) * progress;
- var alpha = startAlpha * (1 - progress);
- var graphics = self.createAsset('bloodsplatter', 'Bloodsplatter graphics', 0.5, 0.5);
- graphics.scale.set(scale);
- graphics.alpha = alpha;
- self.x += velocityX;
- self.y += velocityY;
+ graphics.scale.set(1 + (maxScale - 1) * progress);
+ graphics.alpha = startAlpha * (1 - progress);
+ self.x -= velocityX;
+ self.y -= velocityY;
};
});
var Monster = Container.expand(function (parent, x, y) {
var self = Container.call(this);
parent.addChild(self);
self.x = x;
self.y = y;
- self.jumping = false;
- self.update = update;
var jumpVelocityX = 0;
var jumpVelocityY = 0;
var jumpSpeed = 30;
var jumpHeight = 200;
var despawnDist = 3000;
var despawnDistSqr = despawnDist * despawnDist;
var shadowReduction = 0.2;
+ var targetingTicks = 10;
var updateTick = 0;
var updatePeriod = 10;
var shadow = self.createAsset('shadow', 'Monster shadow', 0.5, 1);
var graphics = self.createAsset('monster', 'Monster graphics', 0.45, 1);
var hitbox = self.createAsset('hitbox', 'Monster hitbox', 0.5, 0.5);
hitbox.width = graphics.width * 0.8;
hitbox.height = graphics.height * 0.45;
hitbox.alpha = 0;
- self.hitbox = hitbox;
shadow.width = graphics.width * 0.9;
shadow.height = graphics.width * 0.45;
shadow.tint = 0x000000;
shadow.alpha = 0.5;
+ self.jumping = false;
+ self.hitbox = hitbox;
+ self.update = update;
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;
+ var updateCurve = (-Math.sin(++updateTick / updatePeriod * Math.PI) + 0.5) / 1.5;
if (self.jumping) {
if (updateCurve <= 0) {
self.jumping = false;
jumpVelocityX = 0;
jumpVelocityY = 0;
}
} else {
if (updateCurve > 0) {
- var angle = Math.atan2(dy, dx);
+ var targetPosX = player.x + velocityX * targetingTicks;
+ var targetPosY = player.y + velocityY * targetingTicks;
+ var angle = Math.atan2(targetPosY - self.y, targetPosX - self.x);
self.jumping = true;
jumpVelocityX = Math.cos(angle) * jumpSpeed;
jumpVelocityY = Math.sin(angle) * jumpSpeed;
}
}
self.x += jumpVelocityX - velocityX;
self.y += jumpVelocityY - velocityY;
graphics.y = -Math.max(0, updateCurve) * jumpHeight;
- graphics.scale.x = player.x < self.x ? 1 : -1;
+ graphics.scale.x = player.x < self.x ? -1 : 1;
graphics.scale.y = 1 + Math.min(0, updateCurve);
var shadowScale = 1 - shadowReduction * updateCurve;
shadow.scale.set(shadowScale);
return distSqr > despawnDistSqr;
@@ -278,19 +280,18 @@
self.invulnerable = false;
self.invulnerableTime = 3 * 60;
self.invulnerableTimer = 0;
var invulnerableReduction = 0.75;
- var platformGraphics = self.createAsset('platform', 'Platform image', 0.5, 0.6);
+ var platformGraphics = self.createAsset('platform', 'Platform image', 0.4, 0.5);
var playerGraphics = self.createAsset('player', 'Player character', 0.575, 1);
var hitbox = self.createAsset('hitbox', 'Player Hitbox', 0.5, 0.5);
hitbox.width = 25;
hitbox.height = 25;
hitbox.alpha = 0;
self.hitbox = hitbox;
function update(targetPosition) {
if (self.invulnerable) {
- self.invulnerableTimer--;
- if (self.invulnerableTimer <= 0) {
+ if (--self.invulnerableTimer <= 0) {
self.invulnerable = false;
}
self.alpha = self.invulnerableTimer % 60 < 30 ? 1 : 0.5;
}
@@ -302,9 +303,9 @@
var reduction = self.invulnerable ? 1 - self.invulnerableTimer / self.invulnerableTime : 1;
var velocityX = Math.cos(angle) * speed * reduction;
var velocityY = Math.sin(angle) * speed * reduction;
var facingSide = targetPosition.x < self.x ? -1 : 1;
- platformGraphics.rotation = angle + Math.PI / 2;
+ platformGraphics.rotation = angle;
playerGraphics.rotation = speed * reduction / 100 * (Math.PI / 2) * facingSide;
playerGraphics.scale.x = facingSide;
return {
velocityX,
@@ -326,13 +327,13 @@
self.update = update;
function update(velocityX, velocityY) {
var trailElement = null;
if (velocityX !== 0 || velocityY !== 0) {
- trailElement = self.createAsset('trail', 'Trail element', 0.5, 1);
- var angle = Math.atan2(velocityY, velocityX) + Math.PI / 2;
+ trailElement = self.createAsset('trail', 'Trail element', 0, 0.5);
+ var angle = Math.atan2(velocityY, velocityX);
var speed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
trailElement.rotation = angle;
- trailElement.scale.y = speed / 100;
+ trailElement.scale.x = speed / 100;
}
trailElements.push(trailElement);
if (trailElements.length > trailLength) {
var removedElement = trailElements.shift();
@@ -484,19 +485,21 @@
pickups.splice(i, 1);
}
}
for (var i = effects.length - 1; i >= 0; i--) {
- if (effects[i].update(velocityX, velocityY)) {
+ var effect = effects[i];
+ if (effect.update(velocityX, velocityY)) {
+ effect.destroy();
effects.splice(i, 1);
}
}
for (var i = monsters.length - 1; i >= 0; i--) {
var monster = monsters[i];
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)) {
+ effects.push(new BloodsplatterEffect(self, monster.x, monster.y));
interface.changeLives(-1);
monster.destroy();
monsters.splice(i, 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.