User prompt
Give a 10 bonus point when player dodges (closes to enemys) and a text pop up near the score table "Bonus Point +10"
User prompt
Start easy and ramp up enemy speed, spawn rate, or introduce new enemy types over time. This keeps players engaged and challenged without overwhelming them early. - **Variety in Enemies:** Add enemies with different movement patterns, speeds, or behaviors to keep gameplay fresh.
User prompt
Use flashes, trails, scaling, or particle effects when dodging, collecting, or getting hit. This makes every action feel impactful.
User prompt
Add a second dodge effect asset and they sound with In order
User prompt
Make a dodging sound effect
User prompt
Make game music work
User prompt
One enemy can spawn one text ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When the enemys go so close from the player make a fading text that says Good! Wow! Excellent ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bro thats so aggressive make it less
User prompt
Bro it should become more faster after 10 sec
User prompt
Made a pop effect when we get the power op ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Best score is not working
User prompt
Make the best score part work it is not working
User prompt
The text should be a bit Down below
User prompt
When the game ends a text came up and say New Record:(players score) and make a best score Part ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
The shuriken 2 and 3 spawn more every ten sec to
User prompt
Make the shuriken spawner less
User prompt
enemy2 and 3 should have the tail to but less (their tail will stop spawning after 1 sec
User prompt
The stars should be faster and faster after every 10 Seconds
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // --- Enemy Class --- var Enemy = Container.expand(function () { var self = Container.call(this); // Attach enemy asset (image) var enemyAsset = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.radius = enemyAsset.width / 2; self.speed = 3; self.angle = 0; self.update = function () { // Store lastX, lastY for good practice (if needed for triggers) if (typeof self.lastX === "undefined") self.lastX = self.x; if (typeof self.lastY === "undefined") self.lastY = self.y; // Move in direction of angle self.x += Math.cos(self.angle) * self.speed * globalSpeedMultiplier; self.y += Math.sin(self.angle) * self.speed * globalSpeedMultiplier; // Update lastX, lastY self.lastX = self.x; self.lastY = self.y; }; return self; }); // --- Enemy2 Class (Red, smaller, faster) --- var Enemy2 = Container.expand(function () { var self = Container.call(this); // Attach enemy2 asset (image) var enemyAsset = self.attachAsset('enemy2', { anchorX: 0.5, anchorY: 0.5 }); self.radius = enemyAsset.width / 2; self.speed = 5; // Faster than regular enemy self.angle = 0; self.update = function () { // Store lastX, lastY for good practice if (typeof self.lastX === "undefined") self.lastX = self.x; if (typeof self.lastY === "undefined") self.lastY = self.y; // Move in direction of angle self.x += Math.cos(self.angle) * self.speed * globalSpeedMultiplier; self.y += Math.sin(self.angle) * self.speed * globalSpeedMultiplier; // Update lastX, lastY self.lastX = self.x; self.lastY = self.y; }; return self; }); // --- Enemy3 Class (Purple, wide, special movement) --- var Enemy3 = Container.expand(function () { var self = Container.call(this); // Attach enemy3 asset (image) var enemyAsset = self.attachAsset('enemy3', { anchorX: 0.5, anchorY: 0.5 }); self.radius = enemyAsset.width / 2; self.speed = 2; // Slower but wider self.angle = 0; self.wobbleOffset = 0; // For special movement pattern self.update = function () { // Store lastX, lastY for good practice if (typeof self.lastX === "undefined") self.lastX = self.x; if (typeof self.lastY === "undefined") self.lastY = self.y; // Special wobble movement self.wobbleOffset += 0.1; var wobbleX = Math.cos(self.wobbleOffset) * 50; // Side-to-side wobble var wobbleY = Math.sin(self.wobbleOffset * 0.5) * 30; // Up-down wobble // Move in direction of angle with wobble self.x += Math.cos(self.angle) * self.speed * globalSpeedMultiplier + wobbleX * 0.02; self.y += Math.sin(self.angle) * self.speed * globalSpeedMultiplier + wobbleY * 0.02; // Update lastX, lastY self.lastX = self.x; self.lastY = self.y; }; return self; }); // --- Player Class --- var Player = Container.expand(function () { var self = Container.call(this); // Attach player asset var playerAsset = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); // Set radius for collision self.radius = playerAsset.width / 2; // Flash effect on hit self.flash = function () { LK.effects.flashObject(self, 0xff0000, 600); }; return self; }); // --- Powerup Class --- var Powerup = Container.expand(function () { var self = Container.call(this); // Attach powerup asset var powerupAsset = self.attachAsset('powerup', { anchorX: 0.5, anchorY: 0.5 }); // Set radius for collision self.radius = powerupAsset.width / 2; return self; }); // --- Trail Class --- var Trail = Container.expand(function (assetId) { var self = Container.call(this); // Attach the same asset as the enemy var trailAsset = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Start with some transparency self.alpha = 0.6; // Fade out over time using tween tween(self, { alpha: 0 }, { duration: 700, onFinish: function onFinish() { if (self.parent) { self.destroy(); } } }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181c24 }); /**** * Game Code ****/ // Purple, wide, special // Red, smaller, faster // --- Asset Initialization --- // --- Game Variables --- var player; var enemies = []; var powerups = []; var trails = []; var dragNode = null; var lastPlayerPos = { x: 0, y: 0 }; var lastHit = false; var score = 0; var scoreTxt; var survivalTime = 0; var timeTxt; var spawnTimer = 0; var spawnInterval = 90; // frames var powerupTimer = 0; var powerupInterval = 300; // frames (was 600, now twice as frequent) var difficultyTimer = 0; var minSpawnInterval = 30; var gameStarted = false; // Control when gameplay begins globalSpeedMultiplier = 1.0; // Reset speed multiplier var globalSpeedMultiplier = 1.0; // Multiplier for all enemy speeds // --- UI --- scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); timeTxt = new Text2('Time: 0.0', { size: 70, fill: 0xB0EAFF }); timeTxt.anchor.set(0.5, 0); LK.gui.top.addChild(timeTxt); timeTxt.y = 110; // Warning text about shuriken increase var warningTxt = new Text2('Shurikens Will Increase Every 10 Seconds Be Careful!', { size: 60, fill: 0xFFFF00 }); warningTxt.anchor.set(0.5, 0); LK.gui.top.addChild(warningTxt); warningTxt.y = 200; // Fade out warning text after 3 seconds tween(warningTxt, { alpha: 0 }, { duration: 3000, onFinish: function onFinish() { warningTxt.visible = false; gameStarted = true; // Start the game when text fades out } }); // --- Player --- player = new Player(); player.x = 2048 / 2; player.y = 2732 / 2; game.addChild(player); // --- Helper Functions --- function resetGameVars() { enemies = []; powerups = []; trails = []; score = 0; survivalTime = 0; spawnTimer = 0; spawnInterval = 90; powerupTimer = 0; difficultyTimer = 0; lastHit = false; gameStarted = false; // Reset game start state scoreTxt.setText('Score: 0'); timeTxt.setText('Time: 0.0'); player.x = 2048 / 2; player.y = 2732 / 2; // Show warning text again on reset warningTxt.visible = true; warningTxt.alpha = 1; // Fade out warning text after 3 seconds tween(warningTxt, { alpha: 0 }, { duration: 3000, onFinish: function onFinish() { warningTxt.visible = false; gameStarted = true; // Start the game when text fades out } }); } // --- Spawning --- function spawnEnemy() { // Spawn at random edge, move toward player var enemy; // After 10 seconds, start mixing in Enemy2, after 20 seconds add Enemy3 if (survivalTime >= 20) { var r = Math.random(); if (r < 0.4) { enemy = new Enemy(); } else if (r < 0.7) { enemy = new Enemy2(); } else { enemy = new Enemy3(); } } else if (survivalTime >= 10) { var r = Math.random(); if (r < 0.6) { enemy = new Enemy(); } else { enemy = new Enemy2(); } } else { enemy = new Enemy(); } var edge = Math.floor(Math.random() * 4); var x, y; if (edge === 0) { // Top x = 200 + Math.random() * (2048 - 400); y = -80; } else if (edge === 1) { // Bottom x = 200 + Math.random() * (2048 - 400); y = 2732 + 80; } else if (edge === 2) { // Left x = -80; y = 200 + Math.random() * (2732 - 400); } else { // Right x = 2048 + 80; y = 200 + Math.random() * (2732 - 400); } enemy.x = x; enemy.y = y; // Track spawn time for trail duration control enemy.spawnTime = LK.ticks; // Aim at player var dx = player.x - x; var dy = player.y - y; enemy.angle = Math.atan2(dy, dx); if (typeof baseEnemySpeed === "undefined") { baseEnemySpeed = 3; } // Only set speed for Enemy (default), others use their own if (enemy instanceof Enemy) { enemy.speed = baseEnemySpeed + Math.random() * 2 + survivalTime / 20; } enemies.push(enemy); game.addChild(enemy); } function spawnPowerup() { var powerup = new Powerup(); powerup.x = 200 + Math.random() * (2048 - 400); powerup.y = 200 + Math.random() * (2732 - 400); powerups.push(powerup); game.addChild(powerup); } // --- Collision --- function circleIntersect(a, b) { var dx = a.x - b.x; var dy = a.y - b.y; var dist = Math.sqrt(dx * dx + dy * dy); return dist < (a.radius + b.radius) * 0.85; } // --- Drag Controls --- function handleMove(x, y, obj) { if (dragNode) { // Only move player if dragging (i.e., finger/mouse is moving after down) // Calculate movement delta from lastPlayerPos if (lastPlayerPos.active) { var dx = x - lastPlayerPos.x; var dy = y - lastPlayerPos.y; // Only move if there is a delta (prevents teleport on first touch) if (dx !== 0 || dy !== 0) { var newX = dragNode.x + dx; var newY = dragNode.y + dy; // Clamp to game area (avoid top left 100x100) var px = Math.max(100 + player.radius, Math.min(2048 - player.radius, newX)); var py = Math.max(100 + player.radius, Math.min(2732 - player.radius, newY)); dragNode.x = px; dragNode.y = py; } } // Update lastPlayerPos for next move lastPlayerPos.x = x; lastPlayerPos.y = y; lastPlayerPos.active = true; } } game.move = handleMove; game.down = function (x, y, obj) { dragNode = player; // Record initial drag position, but do not move player yet lastPlayerPos.x = x; lastPlayerPos.y = y; lastPlayerPos.active = false; // Prevents teleport on first move }; game.up = function (x, y, obj) { dragNode = null; lastPlayerPos.active = false; }; // --- Main Update Loop --- game.update = function () { // Don't start gameplay until warning text has faded out if (!gameStarted) { return; } // Survival time survivalTime += 1 / 60; timeTxt.setText('Time: ' + survivalTime.toFixed(1)); // Difficulty scaling difficultyTimer++; if (difficultyTimer % 600 === 0) { // Every 10 seconds, increase difficulty // Decrease spawn interval (more frequent spawns) if (spawnInterval > minSpawnInterval) { spawnInterval -= 8; if (spawnInterval < minSpawnInterval) spawnInterval = minSpawnInterval; } // Increase number of enemies spawned per interval if (typeof enemiesPerSpawn === "undefined") { enemiesPerSpawn = 1; } enemiesPerSpawn++; // Increase base enemy speed if (typeof baseEnemySpeed === "undefined") { baseEnemySpeed = 3; } baseEnemySpeed += 0.5; // Increase global speed multiplier for all enemies globalSpeedMultiplier += 0.2; } // Enemy spawn spawnTimer++; if (spawnTimer >= spawnInterval) { // Spawn multiple enemies per interval as difficulty increases if (typeof enemiesPerSpawn === "undefined") { enemiesPerSpawn = 1; } for (var s = 0; s < enemiesPerSpawn; s++) { spawnEnemy(); } spawnTimer = 0; } // Powerup spawn powerupTimer++; if (powerupTimer >= powerupInterval) { // Spawn 2 powerups per interval for more frequent yellow balls for (var i = 0; i < 2; i++) { spawnPowerup(); } powerupTimer = 0; } // Update enemies for (var i = enemies.length - 1; i >= 0; i--) { var e = enemies[i]; e.update(); // Create trail only when enemy is moving faster than base speed AND within spawn time limits var shouldCreateTrail = false; var timeSinceSpawn = (LK.ticks - (e.spawnTime || 0)) / 60; // Convert to seconds // Enemy has 2.25 seconds, Enemy2 and Enemy3 have 1 second var trailTimeLimit = e instanceof Enemy ? 2.25 : 1.0; if (timeSinceSpawn <= trailTimeLimit) { if (e instanceof Enemy && e.speed > baseEnemySpeed + 1) { shouldCreateTrail = true; } else if (e instanceof Enemy2 && e.speed > 5) { shouldCreateTrail = true; } else if (e instanceof Enemy3 && e.speed > 2) { shouldCreateTrail = true; } } if (shouldCreateTrail && LK.ticks % 8 === 0) { var assetId = 'enemy'; // Default if (e instanceof Enemy2) assetId = 'enemy2'; if (e instanceof Enemy3) assetId = 'enemy3'; var trail = new Trail(assetId); trail.x = e.x; trail.y = e.y; trail.rotation = e.rotation || 0; trails.push(trail); game.addChild(trail); } // Remove if off screen if (e.x < -200 || e.x > 2248 || e.y < -200 || e.y > 2932) { e.destroy(); enemies.splice(i, 1); continue; } // Collision with player if (circleIntersect(e, player)) { if (!lastHit) { player.flash(); LK.effects.flashScreen(0xff0000, 600); LK.showGameOver(); lastHit = true; return; } } } // Clean up destroyed trails for (var t = trails.length - 1; t >= 0; t--) { var trail = trails[t]; if (!trail.parent || trail.alpha <= 0) { if (trail.parent) trail.destroy(); trails.splice(t, 1); } } // Remove dead enemies if game over if (lastHit) { for (var j = 0; j < enemies.length; j++) { enemies[j].destroy(); } enemies = []; for (var k = 0; k < powerups.length; k++) { powerups[k].destroy(); } powerups = []; for (var l = 0; l < trails.length; l++) { trails[l].destroy(); } trails = []; return; } // Update powerups for (var p = powerups.length - 1; p >= 0; p--) { var pu = powerups[p]; // Collision with player if (circleIntersect(pu, player)) { score += 10; scoreTxt.setText('Score: ' + score); pu.destroy(); powerups.splice(p, 1); continue; } } // Score increases with time if (Math.floor(survivalTime * 10) % 10 === 0) { var newScore = Math.floor(survivalTime); if (newScore > score) { score = newScore; scoreTxt.setText('Score: ' + score); } } }; // --- Game Over Reset --- LK.on('gameover', function () { resetGameVars(); }); // --- You Win (not used in endless, but for completeness) --- LK.on('youwin', function () { resetGameVars(); });
===================================================================
--- original.js
+++ change.js
@@ -407,12 +407,14 @@
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var e = enemies[i];
e.update();
- // Create trail only when enemy is moving faster than base speed AND within 2.25 seconds of spawn
+ // Create trail only when enemy is moving faster than base speed AND within spawn time limits
var shouldCreateTrail = false;
var timeSinceSpawn = (LK.ticks - (e.spawnTime || 0)) / 60; // Convert to seconds
- if (timeSinceSpawn <= 2.25) {
+ // Enemy has 2.25 seconds, Enemy2 and Enemy3 have 1 second
+ var trailTimeLimit = e instanceof Enemy ? 2.25 : 1.0;
+ if (timeSinceSpawn <= trailTimeLimit) {
if (e instanceof Enemy && e.speed > baseEnemySpeed + 1) {
shouldCreateTrail = true;
} else if (e instanceof Enemy2 && e.speed > 5) {
shouldCreateTrail = true;