User prompt
buat jangkauan peluru player 2x jauh
User prompt
reduce number of jar
User prompt
reduce number of jar. make jar broke after 3 time hit
User prompt
fix nusic background
User prompt
buat logika saat pindah level ninja dan platform bersama munculnya
User prompt
ninja bisa mati saat 5 kali diserang.
User prompt
buat satu di antar jar yang ada bisa melontar api ke bawah sebagai serangan
User prompt
add sound asset for jar
User prompt
buat jar bisa loncat loncat dan bergerak ke kanan dan ke kiri ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
karakter ninja bisa bolak balik imagenya
User prompt
pertajam gambar background
User prompt
add background asset
User prompt
buat ninja bisa di gerakn dengan di swipe kanan atau kiri
User prompt
buat seluruh platform otomatis bergerak random ke kanan atau ke kiri bolak balik ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
buat aturan bila seluruh guci hancur baru pindah level ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
buat naik level setelah guci pecah ditembak
User prompt
buat animasi guci pecah ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
buat guci guci antik di atas permukaan platform dan guci pecah saat diserang ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Ninja Sky Strike
Initial prompt
buat game random static platform. ninja vs evil terbang
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = (Math.random() - 0.5) * 3; self.speedY = (Math.random() - 0.5) * 3; self.health = 1; self.update = function () { self.x += self.speedX; self.y += self.speedY; // Bounce off screen edges if (self.x < 30 || self.x > 2018) { self.speedX *= -1; } if (self.y < 30 || self.y > 2702) { self.speedY *= -1; } }; return self; }); var Jar = Container.expand(function () { var self = Container.call(this); var jarGraphics = self.attachAsset('jar', { anchorX: 0.5, anchorY: 1.0 }); self.broken = false; self.breakJar = function () { if (!self.broken) { self.broken = true; LK.getSound('jarBreak').play(); LK.setScore(LK.getScore() + 5); scoreTxt.setText(LK.getScore()); // Track jars broken for level progression jarsBrokenThisLevel++; // Check if all jars are broken (count remaining unbroken jars) var remainingJars = 0; for (var k = 0; k < jars.length; k++) { if (!jars[k].broken) { remainingJars++; } } // Level up only when all jars are broken (only 1 remaining = this jar that just broke) if (remainingJars <= 1) { // Level up! currentLevel++; jarsBrokenThisLevel = 0; levelTxt.setText('Level ' + currentLevel); // Flash screen gold for level up LK.effects.flashScreen(0xFFD700, 800); // Generate new platforms and jars for next level LK.setTimeout(function () { // Clear existing platforms and jars for (var i = platforms.length - 1; i >= 0; i--) { platforms[i].destroy(); } for (var j = jars.length - 1; j >= 0; j--) { if (!jars[j].broken) { jars[j].destroy(); } } platforms = []; jars = []; generatePlatforms(); }, 500); } // Create multiple jar fragments for breaking effect var fragments = []; for (var i = 0; i < 4; i++) { var fragment = LK.getAsset('jar', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3, tint: 0x8b4513 }); fragment.x = self.x + (Math.random() - 0.5) * 20; fragment.y = self.y + (Math.random() - 0.5) * 20; fragments.push(fragment); game.addChild(fragment); // Animate each fragment var fragmentSpeedX = (Math.random() - 0.5) * 200; var fragmentSpeedY = -Math.random() * 150 - 50; var fragmentRotation = (Math.random() - 0.5) * 6; tween(fragment, { x: fragment.x + fragmentSpeedX, y: fragment.y + fragmentSpeedY + 100, rotation: fragmentRotation, alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 600, easing: tween.easeOut, onFinish: function onFinish() { fragment.destroy(); } }); } // Main jar breaking animation - shake and fade tween(jarGraphics, { rotation: 0.3 }, { duration: 50, easing: tween.easeInOut, onFinish: function onFinish() { tween(jarGraphics, { rotation: -0.3, scaleX: 1.2, scaleY: 0.8 }, { duration: 50, easing: tween.easeInOut, onFinish: function onFinish() { tween(jarGraphics, { scaleX: 0.1, scaleY: 0.1, alpha: 0, rotation: 0 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); } }); } }); } }; return self; }); var Ninja = Container.expand(function () { var self = Container.call(this); var ninjaGraphics = self.attachAsset('ninja', { anchorX: 0.5, anchorY: 0.5 }); self.velocityY = 0; self.onGround = false; self.gravity = 0.8; self.jumpPower = -18; self.health = 3; self.attackCooldown = 0; self.update = function () { // Apply gravity if (!self.onGround) { self.velocityY += self.gravity; } self.y += self.velocityY; // Reset ground state self.onGround = false; // Check platform collisions for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; if (self.intersects(platform) && self.velocityY > 0) { var platformTop = platform.y - platform.height / 2; var ninjaBottom = self.y + self.height / 2; if (ninjaBottom > platformTop - 20) { self.y = platformTop - self.height / 2; self.velocityY = 0; self.onGround = true; // Move ninja with platform self.x += platform.moveSpeed * platform.moveDirection; break; } } } // Fall off screen check if (self.y > 2800) { LK.showGameOver(); } // Reduce attack cooldown if (self.attackCooldown > 0) { self.attackCooldown--; } }; self.jump = function () { if (self.onGround) { self.velocityY = self.jumpPower; self.onGround = false; LK.getSound('jump').play(); } }; self.attack = function (targetX, targetY) { if (self.attackCooldown <= 0) { var projectile = new Projectile(); projectile.x = self.x; projectile.y = self.y; var dx = targetX - self.x; var dy = targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); projectile.speedX = dx / distance * 12; projectile.speedY = dy / distance * 12; projectiles.push(projectile); game.addChild(projectile); self.attackCooldown = 20; LK.getSound('attack').play(); } }; self.moveLeft = function () { self.x -= ninjaSpeed; if (self.x < 50) self.x = 50; }; self.moveRight = function () { self.x += ninjaSpeed; if (self.x > 1998) self.x = 1998; }; return self; }); var Platform = Container.expand(function () { var self = Container.call(this); var platformGraphics = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); self.moveSpeed = Math.random() * 2 + 1; // Random speed between 1-3 self.moveDirection = Math.random() < 0.5 ? -1 : 1; // Random initial direction self.leftBound = 100; self.rightBound = 1948; self.update = function () { // Move platform horizontally self.x += self.moveSpeed * self.moveDirection; // Bounce off boundaries if (self.x <= self.leftBound || self.x >= self.rightBound) { self.moveDirection *= -1; } }; return self; }); var Projectile = Container.expand(function () { var self = Container.call(this); var projectileGraphics = self.attachAsset('projectile', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 0; self.speedY = 0; self.lifetime = 0; self.update = function () { self.x += self.speedX; self.y += self.speedY; self.lifetime++; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Create background var background = LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChild(background); var ninja = new Ninja(); var platforms = []; var enemies = []; var projectiles = []; var jars = []; var enemySpawnTimer = 0; var difficultyTimer = 0; var currentLevel = 1; var jarsPerLevel = 5; var jarsBrokenThisLevel = 0; var touchStartX = 0; var touchStartY = 0; var isSwipeMove = false; var ninjaSpeed = 8; // Create score display var scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create level display var levelTxt = new Text2('Level 1', { size: 60, fill: 0xFFD700 }); levelTxt.anchor.set(0, 0); levelTxt.x = 120; levelTxt.y = 20; LK.gui.topLeft.addChild(levelTxt); // Generate random platforms function generatePlatforms() { platforms = []; // Ground platform var groundPlatform = new Platform(); groundPlatform.x = 1024; groundPlatform.y = 2600; groundPlatform.width = 400; platforms.push(groundPlatform); game.addChild(groundPlatform); // Random platforms - increase count with level var platformCount = Math.min(8 + currentLevel, 15); for (var i = 0; i < platformCount; i++) { var platform = new Platform(); platform.x = Math.random() * 1600 + 200; platform.y = 2400 - i * 250 - Math.random() * 100; // Make platforms smaller at higher levels for more challenge platform.width = Math.max(150 + Math.random() * 100 - currentLevel * 5, 80); platforms.push(platform); game.addChild(platform); // Ensure enough jars are available for level completion var jarChance = Math.min(0.8, 0.6 + currentLevel * 0.05); if (Math.random() < jarChance) { var jar = new Jar(); jar.x = platform.x; jar.y = platform.y - platform.height / 2; jar.platform = platform; // Assign platform reference to jar jars.push(jar); game.addChild(jar); } } } function spawnEnemy() { var enemy = new Enemy(); // Spawn from random edge var side = Math.floor(Math.random() * 4); switch (side) { case 0: // Top enemy.x = Math.random() * 2048; enemy.y = -30; break; case 1: // Right enemy.x = 2078; enemy.y = Math.random() * 2732; break; case 2: // Bottom enemy.x = Math.random() * 2048; enemy.y = 2762; break; case 3: // Left enemy.x = -30; enemy.y = Math.random() * 2732; break; } enemies.push(enemy); game.addChild(enemy); } // Initialize game elements generatePlatforms(); ninja.x = 1024; ninja.y = 2500; game.addChild(ninja); // Touch controls game.down = function (x, y, obj) { touchStartX = x; touchStartY = y; isSwipeMove = false; }; game.up = function (x, y, obj) { if (!isSwipeMove) { // If touching near ninja, jump var dx = x - ninja.x; var dy = y - ninja.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 150) { ninja.jump(); } else { // Attack in direction of touch ninja.attack(x, y); } } }; game.move = function (x, y, obj) { var swipeDistanceX = x - touchStartX; var swipeDistanceY = Math.abs(y - touchStartY); // Detect horizontal swipe (minimum 50px horizontal, less than 100px vertical) if (Math.abs(swipeDistanceX) > 50 && swipeDistanceY < 100) { isSwipeMove = true; if (swipeDistanceX > 0) { // Swipe right ninja.moveRight(); } else { // Swipe left ninja.moveLeft(); } } }; game.update = function () { // Spawn enemies enemySpawnTimer++; difficultyTimer++; var spawnRate = Math.max(180 - Math.floor(difficultyTimer / 300), 60); if (enemySpawnTimer >= spawnRate) { spawnEnemy(); enemySpawnTimer = 0; } // Check projectile vs enemy collisions for (var p = projectiles.length - 1; p >= 0; p--) { var projectile = projectiles[p]; // Remove old projectiles if (projectile.lifetime > 180 || projectile.x < -50 || projectile.x > 2098 || projectile.y < -50 || projectile.y > 2782) { projectile.destroy(); projectiles.splice(p, 1); continue; } // Check enemy hits for (var e = enemies.length - 1; e >= 0; e--) { var enemy = enemies[e]; if (projectile.intersects(enemy)) { // Hit enemy LK.setScore(LK.getScore() + 10); scoreTxt.setText(LK.getScore()); LK.getSound('enemyHit').play(); LK.effects.flashObject(enemy, 0xffffff, 200); enemy.destroy(); enemies.splice(e, 1); projectile.destroy(); projectiles.splice(p, 1); break; } // Check jar hits for (var j = jars.length - 1; j >= 0; j--) { var jar = jars[j]; if (!jar.broken && projectile.intersects(jar)) { jar.breakJar(); jars.splice(j, 1); projectile.destroy(); projectiles.splice(p, 1); break; } } } } // Update jar positions to follow their platforms for (var j = 0; j < jars.length; j++) { var jar = jars[j]; if (!jar.broken && jar.platform) { jar.x = jar.platform.x; } } // Check ninja vs enemy collisions for (var e = enemies.length - 1; e >= 0; e--) { var enemy = enemies[e]; if (ninja.intersects(enemy)) { ninja.health--; LK.effects.flashObject(ninja, 0xff0000, 500); enemy.destroy(); enemies.splice(e, 1); if (ninja.health <= 0) { LK.showGameOver(); } } } // Keep ninja on screen horizontally if (ninja.x < 40) ninja.x = 40; if (ninja.x > 2008) ninja.x = 2008; };
===================================================================
--- original.js
+++ change.js
@@ -266,8 +266,16 @@
/****
* Game Code
****/
+// Create background
+var background = LK.getAsset('background', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+});
+game.addChild(background);
var ninja = new Ninja();
var platforms = [];
var enemies = [];
var projectiles = [];
2d anime chibi style ninja hitam jepang. In-Game asset. 2d. High contrast. No shadows
2d anime image pemandangan gunung fuji jepang zaman kuno di kejauhan. wilayah hutan dan bukit bebatuan dari dekat. langit biru cerah. In-Game asset. 2d. High contrast. No shadows
2d anime chibi evil hitam jepang. In-Game asset. 2d. High contrast. No shadows
2d anime image tanah dan bebatuan. In-Game asset. 2d. High contrast. No shadows