User prompt
make 12x repeated jump
User prompt
make platform short distance from ground
User prompt
short push attack range
User prompt
player can safe landed after long jump
User prompt
player can repeated jump 8x
User prompt
player can repeated short jump 5x
User prompt
reduce jump to 4x repeated
User prompt
7x jump
Code edit (1 edits merged)
Please save this source code
User prompt
Side Dash: Platform Warrior
Initial prompt
1. JavaScript 2D side scroling ground and Platformer Game push attack game. 2. player swipe dash attac game. 3 enemy move left and right. 4. random platform. 5. game end when all enemies died. 6. game over when player died. 7. touchscreen controler button for move left and right. touch controler button A for attack. touch controler S for jump. 8.limited platform just 7 paltform. enemy on the platform. 9.enemy not same platform with player
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var ControlButton = Container.expand(function () { var self = Container.call(this); var btnGraphics = self.attachAsset('controlBtn', { anchorX: 0.5, anchorY: 0.5, alpha: 0.5 }); var label = new Text2('', { size: 70, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); self.addChild(label); self.setLabel = function (text) { label.setText(text); }; self.down = function () { btnGraphics.alpha = 0.8; if (self.onPress) { self.onPress(); } }; self.up = function () { btnGraphics.alpha = 0.5; if (self.onRelease) { self.onRelease(); } }; return self; }); var DashEffect = Container.expand(function () { var self = Container.call(this); var effect = self.attachAsset('dashEffect', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); self.init = function (x, y, direction) { self.x = x; self.y = y; self.direction = direction; self.alpha = 1; effect.scaleX = direction; // Fade out effect tween(self, { alpha: 0 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.width = enemyGraphics.width; self.height = enemyGraphics.height; self.speed = 2; self.direction = 1; self.platformWidth = 0; self.platformX = 0; self.init = function (platform) { self.platformWidth = platform.width; self.platformX = platform.x; self.y = platform.y - platform.height / 2 - self.height / 2; self.x = platform.x; }; self.update = function () { // Move back and forth on platform self.x += self.speed * self.direction; // Change direction at edges if (self.x > self.platformX + self.platformWidth / 2 - self.width / 2) { self.direction = -1; enemyGraphics.scaleX = -1; } else if (self.x < self.platformX - self.platformWidth / 2 + self.width / 2) { self.direction = 1; enemyGraphics.scaleX = 1; } }; return self; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.width = heroGraphics.width; self.height = heroGraphics.height; self.vx = 0; self.vy = 0; self.direction = 1; self.isJumping = false; self.jumpCount = 0; self.maxJumps = 8; self.isDashing = false; self.dashCooldown = 0; self.onGround = false; self.currentPlatform = null; self.move = function (direction) { if (self.isDashing) { return; } self.direction = direction; self.vx = 6 * direction; heroGraphics.scaleX = direction; }; self.stopMoving = function () { if (self.isDashing) { return; } self.vx = 0; }; self.jump = function () { if (self.jumpCount >= self.maxJumps || self.isDashing) { return; } self.vy = -20; self.jumpCount++; self.isJumping = true; self.onGround = false; LK.getSound('jump').play(); }; self.dash = function () { if (self.isDashing || self.dashCooldown > 0) { return; } self.isDashing = true; self.dashCooldown = 30; // Half second cooldown // Dash in the direction the hero is facing self.vx = 25 * self.direction; // Create dash effect var effect = new DashEffect(); effect.init(self.x - 50 * self.direction, self.y, self.direction); game.addChild(effect); LK.getSound('dash').play(); // End dash after a short time LK.setTimeout(function () { self.isDashing = false; self.vx = 0; }, 200); }; self.update = function () { // Apply gravity if (!self.onGround) { self.vy += 1; // Gravity } // Apply movement self.x += self.vx; self.y += self.vy; // Handle dash cooldown if (self.dashCooldown > 0) { self.dashCooldown--; } // Screen boundaries if (self.x < self.width / 2) { self.x = self.width / 2; } else if (self.x > 2048 - self.width / 2) { self.x = 2048 - self.width / 2; } // Check if hero has fallen off screen if (self.y > 2732) { LK.getSound('playerHurt').play(); LK.showGameOver(); } }; return self; }); var Platform = Container.expand(function () { var self = Container.call(this); var platformGraphics = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); self.width = platformGraphics.width; self.height = platformGraphics.height; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222233 }); /**** * Game Code ****/ // Game variables var hero; var platforms = []; var enemies = []; var enemyCount = 7; var leftBtn, rightBtn, jumpBtn, dashBtn; var scoreText; // Controls state var leftPressed = false; var rightPressed = false; // Initialize game elements function initGame() { // Create hero hero = new Hero(); game.addChild(hero); // Create platforms createPlatforms(); // Place hero on the first platform hero.x = platforms[0].x; hero.y = platforms[0].y - platforms[0].height / 2 - hero.height / 2; hero.currentPlatform = platforms[0]; hero.onGround = true; // Create enemies createEnemies(); // Create controls createControls(); // Create score display scoreText = new Text2("Enemies: " + enemyCount, { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Start game music LK.playMusic('gameMusic', { fade: { start: 0, end: 0.4, duration: 1000 } }); } function createPlatforms() { // Create main platform at bottom var mainPlatform = new Platform(); mainPlatform.x = 2048 / 2; mainPlatform.y = 2732 - 200; mainPlatform.width = 1000; // Make bottom platform wider game.addChild(mainPlatform); platforms.push(mainPlatform); // Create 6 more platforms at random positions for (var i = 0; i < 6; i++) { var platform = new Platform(); // Distribute platforms across the screen var sectionWidth = 2048 / 3; var sectionHeight = (2732 - 400) / 3; var col = i % 3; var row = Math.floor(i / 3); platform.x = col * sectionWidth + sectionWidth / 2 + Math.random() * 200 - 100; platform.y = 400 + row * sectionHeight + Math.random() * 200 - 100; game.addChild(platform); platforms.push(platform); } } function createEnemies() { // Create enemies on platforms (skip the first platform where hero starts) for (var i = 1; i < platforms.length; i++) { var enemy = new Enemy(); enemy.init(platforms[i]); game.addChild(enemy); enemies.push(enemy); } // Add more enemies to random platforms to reach enemyCount while (enemies.length < enemyCount) { var platformIndex = Math.floor(Math.random() * (platforms.length - 1)) + 1; var enemy = new Enemy(); enemy.init(platforms[platformIndex]); // Offset enemy position to avoid overlap enemy.x += Math.random() * 100 - 50; game.addChild(enemy); enemies.push(enemy); } } function createControls() { // Create movement buttons leftBtn = new ControlButton(); leftBtn.x = 150; leftBtn.y = 2732 - 150; leftBtn.setLabel("←"); leftBtn.onPress = function () { leftPressed = true; hero.move(-1); }; leftBtn.onRelease = function () { leftPressed = false; if (!rightPressed) { hero.stopMoving(); } else { hero.move(1); } }; game.addChild(leftBtn); rightBtn = new ControlButton(); rightBtn.x = 350; rightBtn.y = 2732 - 150; rightBtn.setLabel("→"); rightBtn.onPress = function () { rightPressed = true; hero.move(1); }; rightBtn.onRelease = function () { rightPressed = false; if (!leftPressed) { hero.stopMoving(); } else { hero.move(-1); } }; game.addChild(rightBtn); // Create action buttons jumpBtn = new ControlButton(); jumpBtn.x = 2048 - 350; jumpBtn.y = 2732 - 150; jumpBtn.setLabel("S"); jumpBtn.onPress = function () { hero.jump(); }; game.addChild(jumpBtn); dashBtn = new ControlButton(); dashBtn.x = 2048 - 150; dashBtn.y = 2732 - 150; dashBtn.setLabel("A"); dashBtn.onPress = function () { hero.dash(); }; game.addChild(dashBtn); } function checkCollisions() { // Check platform collisions var onAnyPlatform = false; for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; // Only check for landing if moving downward if (hero.vy > 0 && !hero.onGround) { // Check if hero's feet are at platform level var heroBottom = hero.y + hero.height / 2; var platformTop = platform.y - platform.height / 2; // Check if hero is within platform width var heroCenterX = hero.x; var platformLeft = platform.x - platform.width / 2; var platformRight = platform.x + platform.width / 2; // If hero is just above platform and within platform width if (heroBottom >= platformTop && heroBottom <= platformTop + 20 && heroCenterX >= platformLeft && heroCenterX <= platformRight) { // Land on platform hero.y = platformTop - hero.height / 2; hero.vy = 0; hero.onGround = true; hero.isJumping = false; hero.jumpCount = 0; hero.currentPlatform = platform; onAnyPlatform = true; break; } } } // If not on any platform and was on ground before, start falling if (!onAnyPlatform && hero.onGround) { hero.onGround = false; } // Check enemy collisions for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (hero.intersects(enemy)) { // If hero is dashing, defeat enemy if (hero.isDashing) { // Remove enemy LK.getSound('enemyDefeat').play(); enemy.destroy(); enemies.splice(j, 1); // Update score enemyCount--; scoreText.setText("Enemies: " + enemyCount); // Check win condition if (enemyCount <= 0) { LK.showYouWin(); } // Create dash effect var effect = new DashEffect(); effect.init(enemy.x, enemy.y, hero.direction); game.addChild(effect); } else { // If not dashing, player loses LK.getSound('playerHurt').play(); LK.showGameOver(); } } } } // Game update function game.update = function () { // Update hero hero.update(); // Update enemies for (var i = 0; i < enemies.length; i++) { enemies[i].update(); } // Check collisions checkCollisions(); }; // Touch events for entire game area game.down = function (x, y, obj) { // Add any global touch interactions here }; game.up = function (x, y, obj) { // Add any global touch release interactions here }; game.move = function (x, y, obj) { // Add any global touch move interactions here }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -105,9 +105,9 @@
self.vy = 0;
self.direction = 1;
self.isJumping = false;
self.jumpCount = 0;
- self.maxJumps = 5;
+ self.maxJumps = 8;
self.isDashing = false;
self.dashCooldown = 0;
self.onGround = false;
self.currentPlatform = null;
2d animation garuda man play shoot 2 gun 2 direction left and right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
garuda fire ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
2d animation reog ponorogo monster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows