User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var playerGraphics = player.attachAsset('player_run', {' Line Number: 97
User prompt
Switch between left and right leg every .5 seconds ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make players legs run
User prompt
Remove background colour sky-blue
User prompt
Loop the backgrounds remove blue screen
User prompt
Make background scroll to left alternating between background and background2
User prompt
Make background scrolling left
User prompt
Make enemy move faster
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'kick')' in or related to this line: 'self.kick = function () {' Line Number: 135
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'kick')' in or related to this line: 'self.kick = function () {' Line Number: 124
User prompt
Make the hero kick enemy
Remix started
Copy Mario vs Monsters
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Define a class for enemies var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> // Define a class for the player character var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player_run', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.jumpHeight = 40; self.isJumping = false; self.velocityY = 0; self.update = function () { if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.7; // Decreased gravity effect by 30% if (self.y >= 2732 / 2) { // Ground level self.y = 2732 / 2; self.isJumping = false; self.velocityY = 0; self.attachAsset('player_run', { anchorX: 0.5, anchorY: 0.5 }); } } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.velocityY = -self.jumpHeight; self.attachAsset('player_jump', { anchorX: 0.5, anchorY: 0.5 }); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Black background }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); background.x = 2048; background.y = 0; var background2 = game.addChild(LK.getAsset('background2', { anchorX: 0, anchorY: 0 })); background2.x = 4096; background2.y = 0; function switchLegs() { if (typeof player !== 'undefined') { var playerGraphics = player.attachAsset('player_run', { anchorX: 0.5, anchorY: 0.5 }); } tween(playerGraphics, { tint: 0xFFFFFF }, { duration: 500, onFinish: function onFinish() { playerGraphics.tint = playerGraphics.tint === 0xFFFFFF ? 0xAAAAAA : 0xFFFFFF; switchLegs(); } }); } switchLegs(); var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 / 2; // Initialize enemies var enemies = []; var enemySpawnInterval = 100; var enemySpawnCounter = 0; // Create a new Text2 object to display the score var scoreText = new Text2('0', { size: 100, fill: 0xFFFFFF }); // Add the score text to the game GUI at the top center of the screen LK.gui.top.addChild(scoreText); scoreText.x = 2048 / 2; scoreText.y = 0; // Handle game updates game.update = function () { player.update(); background.x -= 5; background2.x -= 5; if (background.x <= -2048) { background.x = 4096; } if (background2.x <= -2048) { background2.x = 4096; } // Spawn enemies enemySpawnCounter++; if (enemySpawnCounter >= enemySpawnInterval) { var enemy = new Enemy(); enemy.x = 2048; enemy.y = 2732 / 2; enemies.push(enemy); game.addChild(enemy); // Randomize the spawn interval for the next enemy enemySpawnInterval = Math.floor(Math.random() * 150) + 50; enemySpawnCounter = 0; } // Update enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (player.intersects(enemies[j])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else if (player.x > enemies[j].x && !enemies[j].passed) { enemies[j].passed = true; LK.setScore(LK.getScore() + 1); scoreText.setText(LK.getScore()); } } }; // Handle player jump game.down = function (x, y, obj) { player.jump(); };
===================================================================
--- original.js
+++ change.js
@@ -83,12 +83,14 @@
}));
background2.x = 4096;
background2.y = 0;
function switchLegs() {
- var playerGraphics = player.attachAsset('player_run', {
- anchorX: 0.5,
- anchorY: 0.5
- });
+ if (typeof player !== 'undefined') {
+ var playerGraphics = player.attachAsset('player_run', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ }
tween(playerGraphics, {
tint: 0xFFFFFF
}, {
duration: 500,
🔥 fire. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Mario driving a tank. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Wario flying an aeroplane. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Waluigi flying a helicopter. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows