User prompt
Please fix the bug: 'Timeout.tick error: self is undefined' in or related to this line: 'var rainbowGiftGraphics = self.attachAsset('rainbowGift', {' Line Number: 36
User prompt
Please fix the bug: 'Timeout.tick error: self is undefined' in or related to this line: 'var rainbowGiftGraphics = self.attachAsset('rainbowGift', {' Line Number: 36
User prompt
Please fix the bug: 'Timeout.tick error: self is undefined' in or related to this line: 'var rainbowGiftGraphics = self.attachAsset('rainbowGift', {' Line Number: 36
User prompt
Please fix the bug: 'Timeout.tick error: self is undefined' in or related to this line: 'var rainbowGiftGraphics = self.attachAsset('rainbowGift', {' Line Number: 36
User prompt
Please fix the bug: 'Timeout.tick error: self is undefined' in or related to this line: 'var rainbowGiftGraphics = self.attachAsset('rainbowGift', {' Line Number: 36
User prompt
Please fix the bug: 'Timeout.tick error: self is undefined' in or related to this line: 'self.attachAsset('rainbowGift', {' Line Number: 36
User prompt
make up to levle 3
User prompt
Please fix the bug: 'Timeout.tick error: self is undefined' in or related to this line: 'self.attachAsset('rainbowGift', {' Line Number: 36
User prompt
make raimbow gifts for power up
User prompt
Migrate to the latest version of LK
Remix started
Copy Santa Panic
/**** * Classes ****/ var Gift = Container.expand(function (dropSpeed) { var self = Container.call(this); self.dropSpeed = dropSpeed; var giftGraphics = self.attachAsset('gift', { anchorX: 0.5, anchorY: 0.5 }); self.drop = function () { self.y += self.dropSpeed; var wiggle = (Math.random() - 0.5) * 10; self.x += wiggle; self.x = Math.max(self.width / 2, Math.min(2048 - self.width / 2, self.x)); }; }); var RainbowGift = Gift.expand(function (dropSpeed) { var self = Gift.call(this, dropSpeed); var rainbowGiftGraphics = self.attachAsset('rainbowGift', { anchorX: 0.5, anchorY: 0.5 }); self.collect = function () { // Power up effect here }; return self; }); var GrayHeart = Container.expand(function () { var self = Container.call(this); var grayHeartGraphics = self.attachAsset('grayHeart', {}); }); var Ground = Container.expand(function () { var self = Container.call(this); var groundGraphics = self.attachAsset('ground', { anchorY: 1 }); groundGraphics.width = 2048; self.addChild(groundGraphics); }); var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.attachAsset('heart', {}); }); var Santa = Container.expand(function () { var self = Container.call(this); var santaGraphics = self.attachAsset('santa', { anchorX: 0.5, anchorY: 0.5 }); self.lastX = self.x; self._move_migrated = function (newX) { var halfWidth = this.width / 2; var oldX = this.x; var moveAmount = Math.max(halfWidth, Math.min(2048 - halfWidth, newX)) - this.x; this.x += moveAmount * 0.2; if (oldX > this.x) { this.scale.x = 1; } else if (oldX < this.x) { this.scale.x = -1; } self.lastX = this.x; }; self.collect = function () {}; }); var Snowflake = Container.expand(function (santa) { var self = Container.call(this); self.santa = santa; var snowflakeGraphics = self.attachAsset('snowflake', { anchorX: 0.5, anchorY: 0.5 }); snowflakeGraphics.scale.set(0.5); self.drop = function () { self.y += 5; self.x -= 5; if (self.y > 2732 - self.santa.height || self.x < -self.width) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var score = 0; var level = 1; var highestScore = 0; var scoreTxt = new Text2(score.toString(), { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(.5, 0); LK.gui.top.addChild(scoreTxt); var lives = 3; var hearts = []; for (var i = 0; i < lives; i++) { var heart = new Heart(); heart.x = i * (heart.width + 10); heart.y = 10; hearts.push(heart); LK.gui.topLeft.addChild(heart); } var santa = game.addChild(new Santa()); var snowflakes = []; for (var i = 0; i < 10; i++) { var initialSnowflake = new Snowflake(santa); initialSnowflake.x = Math.random() * 2048; initialSnowflake.y = Math.random() * 2732; snowflakes.push(initialSnowflake); game.addChild(initialSnowflake); } var snowfallInterval = LK.setInterval(function () { for (var i = 0; i < 3; i++) { var snowflake = new Snowflake(santa); snowflake.x = 2048 + snowflake.width / 2; snowflake.y = Math.random() * 2732; snowflakes.push(snowflake); game.addChild(snowflake); } }, 1000); var gifts = []; santa.x = 2048 / 2; santa.y = 2732 - santa.height; var ground = new Ground(); var background = game.attachAsset('background', {}); background.width = 2048; background.height = 2732 - ground.height; game.addChildAt(background, 0); game.addChildAt(ground, 1); var giftDropSpeed = 5; var maxGiftDropSpeed = 15; var giftSpeedIncreaseInterval = 10000; var lastSpeedIncreaseTime = 0; var giftCreationInterval = LK.setInterval(function () { var currentTime = Date.now(); giftDropSpeed = 5 + level; // Increase drop speed based on level var gift; if (Math.random() < 0.1) { // 10% chance to create a rainbow gift gift = new RainbowGift(giftDropSpeed); } else { gift = new Gift(giftDropSpeed); } gift.x = Math.random() * 2048; gift.y = 0; gifts.push(gift); game.addChild(gift); }, 2000); LK.on('tick', function () { santa._move_migrated(); for (var j = 0; j < snowflakes.length; j++) { snowflakes[j].drop(); if (snowflakes[j].y > 2732) { snowflakes.splice(j, 1); j--; } } for (var i = 0; i < gifts.length; i++) { gifts[i].drop(); if (santa.intersects(gifts[i])) { santa.collect(gifts[i]); score++; if (score > highestScore) { highestScore = score; } scoreTxt.setText(score.toString()); if (score % 10 === 0) { level++; console.log("Level Up! Current Level: " + level); } gifts[i].destroy(); gifts.splice(i, 1); i--; if (hearts.length > 0) { var lostHeart = hearts[hearts.length - 1]; } } else if (gifts[i].y > 2732 - ground.height - gifts[i].height / 2) { gifts[i].destroy(); gifts.splice(i, 1); i--; if (--lives <= 0) { if (hearts.length > 0) { var lostHeart = hearts.pop(); lostHeart.destroy(); var grayHeart = new GrayHeart(); grayHeart.x = lostHeart.x; grayHeart.y = lostHeart.y; LK.gui.topLeft.addChild(grayHeart); } scoreTxt.setText('Highest Score: ' + highestScore.toString()); LK.showGameOver(); } else if (hearts.length > 0) { var lostHeart = hearts.pop(); lostHeart.destroy(); var grayHeart = new GrayHeart(); grayHeart.x = lostHeart.x; grayHeart.y = lostHeart.y; LK.gui.topLeft.addChild(grayHeart); } } } }); game.on('down', function (x, y, obj) { var pos = game.toLocal(obj.global); santa._move_migrated(pos.x); }); game.on('move', function (x, y, obj) { var pos = game.toLocal(obj.global); santa._move_migrated(pos.x); });
===================================================================
--- original.js
+++ change.js
@@ -16,9 +16,9 @@
};
});
var RainbowGift = Gift.expand(function (dropSpeed) {
var self = Gift.call(this, dropSpeed);
- self.attachAsset('rainbowGift', {
+ var rainbowGiftGraphics = self.attachAsset('rainbowGift', {
anchorX: 0.5,
anchorY: 0.5
});
self.collect = function () {
Pixelated Santa Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixeled Christmas present Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixalated heart empty Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixalated heart grey Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelated snow flake Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
snowy ground image pixalated Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
snowy ground image pixalated 2D Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art a small image 2048 to serve as ground that has snow for a simple 2D game no trees not nothing only snow and ground to cover the ground width of the screen Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gif pixel art for game background, snow on the ground, houses in the far background and moonligh, trees on the left and right, cozy Christmas atmosphere Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
rat dance. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows