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.
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
===================================================================
--- original.js
+++ change.js
@@ -172,9 +172,8 @@
self.hitbox.height = graphics.width * 0.45;
});
var Player = Container.expand(function (parent, x, y) {
var self = Container.call(this);
- self.gameInstance = parent;
parent.addChild(self);
self.x = x;
self.y = y;
self.update = update;
@@ -186,16 +185,9 @@
hitbox.height = 25;
hitbox.alpha = 0;
self.hitbox = hitbox;
self.loseLife = function () {
- self.parent.lives--;
- var lifeIcon = self.parent.lifeIcons[self.parent.lives];
- if (lifeIcon) {
- lifeIcon.alpha = 0.5;
- }
- if (self.parent.lives <= 0) {
- LK.showGameOver();
- }
+ self.parent.interface.changeLives(-1);
};
function update(targetPosition) {
var dx = targetPosition.x - self.x;
var dy = targetPosition.y - self.y;
@@ -214,8 +206,48 @@
function angleClamp(angle) {
return angle >= 0 ? angle : angle < -Math.PI / 2 ? Math.PI : 0;
}
});
+var Interface = Container.expand(function (parent) {
+ var self = Container.call(this);
+ parent.addChild(self);
+ self.score = 0;
+ self.lives = 3;
+ self.scoreIcon = LK.getAsset('scoreIcon', 'Score icon', 1, 0);
+ self.scoreText = new Text2(self.score, {
+ size: 80,
+ fill: "#000000",
+ align: 'left'
+ });
+ self.lifeIcons = [];
+ for (var i = 0; i < self.lives; i++) {
+ var lifeIcon = LK.getAsset('lifeIcon', 'Life icon', 1, 0);
+ lifeIcon.x = -10 + i * 70;
+ lifeIcon.y = 100;
+ LK.gui.topCenter.addChild(lifeIcon);
+ self.lifeIcons.push(lifeIcon);
+ }
+ self.scoreIcon.x = -10;
+ self.scoreIcon.y = 20;
+ self.scoreText.x = 10;
+ self.scoreText.y = 20;
+ self.scoreText.anchor.set(0, 0);
+ LK.gui.topCenter.addChild(self.scoreIcon);
+ LK.gui.topCenter.addChild(self.scoreText);
+ self.changeLives = function (amount) {
+ self.lives += amount;
+ for (var i = 0; i < self.lifeIcons.length; i++) {
+ self.lifeIcons[i].alpha = i < self.lives ? 1 : 0.5;
+ }
+ if (self.lives <= 0) {
+ LK.showGameOver();
+ }
+ };
+ self.changeScore = function (amount) {
+ self.score += amount;
+ self.scoreText.setText(self.score);
+ };
+});
var Game = Container.expand(function () {
var self = Container.call(this);
var stageWidth = 2048;
var stageHeight = 2732;
@@ -231,8 +263,9 @@
var targetPosition = {
x: 0,
y: 0
};
+ self.interface = new Interface(self);
var player = new Player(self, stageWidth / 2, stageHeight / 5);
var speedText = new Text2('Speed: 0', {
size: 50,
fill: "#000000",
@@ -251,31 +284,8 @@
key: '0:0',
landscapeTiles,
pickups
}));
- var score = 0;
- var lives = 3;
- var scoreIcon = LK.getAsset('scoreIcon', 'Score icon', 1, 0);
- var scoreText = new Text2(score, {
- size: 80,
- fill: "#000000",
- align: 'left'
- });
- this.lifeIcons = [];
- for (var i = 0; i < lives; i++) {
- var lifeIcon = LK.getAsset('lifeIcon', 'Life icon', 1, 0);
- lifeIcon.x = -10 + i * 70;
- lifeIcon.y = 100;
- LK.gui.topCenter.addChild(lifeIcon);
- lifeIcons.push(lifeIcon);
- }
- 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);
@@ -306,9 +316,9 @@
}
for (var i = pickups.length - 1; i >= 0; i--) {
var pickup = pickups[i];
if (pickup.update(player, velocityX, velocityY)) {
- score++;
+ self.interface.changeScore(1);
pickup.destroy();
pickups.splice(i, 1);
} else if (pickup.y < -(tileSize / 2 + tileMargin) || pickup.active && player.hitbox.intersects(pickup.hitbox)) {
pickup.destroy();
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.