Code edit (1 edits merged)
Please save this source code
User prompt
scroll the background and loop the background
User prompt
scroll the background and loop the background
User prompt
resize the image without lossing the quality
User prompt
change the asteroid points in to 50
User prompt
stop only the background movement
User prompt
scale the background with the screen
User prompt
fit the background entirely with the screen
User prompt
move every thing except player and background continously downwards to the screen endlesslt
User prompt
reset the size of the background
User prompt
extend the size of the background fully stretch with the screen
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(background, {' Line Number: 233 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Update the endless background smoothly and continuously with the previous
User prompt
update the endless background smoothly
User prompt
update this with a endless background
User prompt
move every thing except player continously downwards to the screen endlesslt
User prompt
Make the game move upwards at a certain time
User prompt
make this game to move upwards to the screen at certain time
User prompt
disable make this game to move downwards to the screen at certain time
User prompt
duplicate the same background on its end
User prompt
extend the background based on the game movement
User prompt
stretch the background based on the game movement
User prompt
when player destroy when it got hit by asteroid play the blast effect on player
Code edit (1 edits merged)
Please save this source code
User prompt
move the player up based on game movement
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
/**** 
* Classes
****/ 
// Asteroid class
var Asteroid = Container.expand(function () {
	var self = Container.call(this);
	// Attach asteroid asset
	var asteroidGraphics = self.attachAsset('asteroid', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set asteroid speed
	self.speed = 3;
	// Update function called every game tick
	self.update = function () {
		// Move asteroid based on speed
		self.y += self.speed;
		// Destroy asteroid when it gets out of player screen
		if (self.y > 2732) {
			self.destroy();
		}
		// Check for collision with player
		if (self.intersects(player)) {
			// Add a blasting effect
			var blast = self.attachAsset('blast', {
				anchorX: 0.5,
				anchorY: 0.5
			});
			blast.x = player.x;
			blast.y = player.y;
			game.addChild(blast);
			// Destroy the blast effect after a short delay
			LK.setTimeout(function () {
				blast.destroy();
			}, 500);
			// Trigger game over when asteroid hits player
			LK.showGameOver();
		}
	};
});
// Bullet class
var Bullet = Container.expand(function () {
	var self = Container.call(this);
	// Attach bullet asset
	var bulletGraphics = self.attachAsset('bullet', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set bullet speed
	self.speed = -14;
	// Update function called every game tick
	self.update = function () {
		self.y += self.speed;
		// Check for collision with enemy and asteroid
		var targets = game.children.filter(function (child) {
			return child instanceof Enemy || child instanceof Asteroid;
		});
		for (var i = 0; i < targets.length; i++) {
			var target = targets[i];
			if (self.intersects(target)) {
				// Destroy target and bullet on collision
				target.destroy();
				self.destroy();
				// Increase score by 50 points when target dies
				LK.setScore(LK.getScore() + 50);
				// Update the scoreboard
				scoreTxt.setText(LK.getScore());
				// Add a blasting effect
				var blast = self.attachAsset('blast', {
					anchorX: 0.5,
					anchorY: 0.5
				});
				blast.x = self.x;
				blast.y = self.y;
				game.addChild(blast);
				// Destroy the blast effect after a short delay
				LK.setTimeout(function () {
					blast.destroy();
				}, 500);
				break;
			}
		}
		// Destroy bullet when it gets out of player screen
		if (self.y < 0 || self.y > 2732) {
			self.destroy();
		}
	};
});
// Enemy class
var Enemy = Container.expand(function () {
	var self = Container.call(this);
	// Attach enemy asset
	var enemyGraphics = self.attachAsset('enemy', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set enemy speed
	self.speed = 5;
	// Update function called every game tick
	self.update = function () {
		// Move enemy based on speed
		self.y += self.speed;
		// Destroy enemy when it gets out of player screen
		if (self.y > 2732) {
			self.destroy();
		}
		// Enemy fires a bullet every 60 ticks
		if (LK.ticks % 60 == 0) {
			var enemyBullet = game.addChild(new EnemyBullet());
			// Set bullet initial position to enemy's position
			enemyBullet.x = self.x;
			enemyBullet.y = self.y;
			// Set bullet speed to move downwards
			enemyBullet.speed = 6;
		}
	};
});
// EnemyBullet class
var EnemyBullet = Container.expand(function () {
	var self = Container.call(this);
	// Attach bullet asset
	var bulletGraphics = self.attachAsset('bullet', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set bullet speed
	self.speed = 5;
	// Update function called every game tick
	self.update = function () {
		self.y += self.speed;
		// Check for collision with player
		if (self.intersects(player)) {
			// Add a blasting effect
			var blast = self.attachAsset('blast', {
				anchorX: 0.5,
				anchorY: 0.5
			});
			blast.x = player.x;
			blast.y = player.y;
			game.addChild(blast);
			// Destroy the blast effect after a short delay
			LK.setTimeout(function () {
				blast.destroy();
			}, 500);
			// Trigger game over when bullet hits player
			LK.showGameOver();
		}
	};
});
// Player class
var Player = Container.expand(function () {
	var self = Container.call(this);
	// Attach player asset
	var playerGraphics = self.attachAsset('player', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set player speed
	self.speed = 5;
	// Update function called every game tick
	self.update = function () {
		// Player movement is handled in game.move event
	};
});
/**** 
* Initialize Game
****/ 
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
var game = new LK.Game();
/**** 
* Game Code
****/ 
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
var background = game.attachAsset('background', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 1024,
	y: 1366,
	scaleX: game.width / LK.getAsset('background', {}).width,
	scaleY: game.height / LK.getAsset('background', {}).height
});
// Create a scoreboard and display it on the screen
var scoreTxt = new Text2('0', {
	size: 150,
	fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
game.update = function () {
	// Spawn an enemy and an asteroid every 60 ticks
	if (LK.ticks % 60 == 0) {
		var enemy = game.addChild(new Enemy());
		// Set enemy initial position
		enemy.x = Math.random() * 2048;
		enemy.y = 0;
		var asteroid = game.addChild(new Asteroid());
		// Set asteroid initial position
		asteroid.x = Math.random() * 2048;
		asteroid.y = 0;
	}
	// Move everything except player continuously downwards
	game.children.forEach(function (child) {
		if (!(child instanceof Player)) {
			child.y += 5;
			if (child === background && child.y >= 2732) {
				child.y = 1; // Reset background position to loop
			}
		}
	});
};
var player = game.addChild(new Player());
// Set player initial position
player.x = 1024;
player.y = 2732 - player.height / 2 - 300;
// Add mouse move event to the game
game.move = function (x, y, obj) {
	// Move player only on x axis
	player.x = x;
};
game.down = function (x, y, obj) {
	// Create a bullet instance
	var bullet = game.addChild(new Bullet());
	// Set bullet initial position to player's position
	bullet.x = player.x;
	bullet.y = player.y;
};
// Update the scoreboard every game tick
scoreTxt.setText(LK.getScore()); ===================================================================
--- original.js
+++ change.js
@@ -213,9 +213,9 @@
 	game.children.forEach(function (child) {
 		if (!(child instanceof Player)) {
 			child.y += 5;
 			if (child === background && child.y >= 2732) {
-				child.y = 0; // Reset background position to loop
+				child.y = 1; // Reset background position to loop
 			}
 		}
 	});
 };
:quality(85)/https://cdn.frvr.ai/67bd57e4efe262753dfd6dfb.png%3F3) 
 Space craft in facing forward. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67bd65e6b3c92d3f541dbe1d.png%3F3) 
 spacecraft in 4k
:quality(85)/https://cdn.frvr.ai/67bd6df50b7dc080adb82b08.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/67bd6ef5b3c92d3f541dbebe.png%3F3) 
 fire blast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67bd755cb3c92d3f541dbf00.png%3F3) 
 asteroid. Single Game Texture. In-Game asset. 2d. No shadows
:quality(85)/https://cdn.frvr.ai/67bd7b3cb3c92d3f541dbf68.png%3F3) 
 dark nebula galaxy 4k. Single Game Texture. In-Game asset. 2d. Blank background. No shadows