User prompt
make controler more large
User prompt
enemy dead after 3 time hit
User prompt
make new game rule logic. after win goes to another play
User prompt
more speed a bullet
User prompt
decrease multiple bullet
User prompt
mores speed bullet
User prompt
ada background
User prompt
infinite repeated jump
User prompt
infinite repeated jump
User prompt
add background asset
User prompt
endless wave
User prompt
short range jump
User prompt
slove move player
User prompt
more speed bullet release
User prompt
more slow fall player
User prompt
slowm fall movement
User prompt
slow movement player
User prompt
make random platform
User prompt
enemy get dead hit after shoot
User prompt
can shoot left and right auto
User prompt
can landed platform after repeated jump
User prompt
fix platform can landed
User prompt
make player capable infinite repeated jump
User prompt
make push attack distance more short
User prompt
make enemy platform is long size horizontaly
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.init = function (x, y, direction) { self.x = x; self.y = y; self.direction = direction; }; self.update = function () { self.x += self.speed * self.direction; // Check collision with enemies for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; if (self.intersects(enemy)) { // Play enemy defeat sound LK.getSound('enemyDefeat').play(); // Remove enemy enemy.destroy(); enemies.splice(i, 1); // Update score enemyCount--; scoreText.setText("Enemies: " + enemyCount); // Check win condition if (enemyCount <= 0) { LK.showYouWin(); } // Destroy bullet self.destroy(); return; } } // Destroy bullet if it goes off screen if (self.x < 0 || self.x > 2048) { self.destroy(); } }; return self; }); 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 = 12; 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 = 3 * direction; // Reduced speed for slower movement heroGraphics.scaleX = direction; }; self.stopMoving = function () { if (self.isDashing) { return; } self.vx = 0; }; self.jump = function () { if (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 = 8 * 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 () { // Auto-shoot bullets left and right if (LK.ticks % 30 === 0) { // Shoot every half second // Shoot every second var bulletLeft = new Bullet(); bulletLeft.init(self.x, self.y, -1); // Shoot left game.addChild(bulletLeft); var bulletRight = new Bullet(); bulletRight.init(self.x, self.y, 1); // Shoot right game.addChild(bulletRight); } // Apply gravity if (!self.onGround) { self.vy += 0.25; // Further reduced gravity for even slower fall } // 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; // Set the game background to an image of Ada Lovelace var adaBackground = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(adaBackground); // 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 - 100; mainPlatform.width = 1500; // Make bottom platform longer horizontally game.addChild(mainPlatform); platforms.push(mainPlatform); // Create 6 more platforms at random positions for (var i = 0; i < 6; i++) { var platform = new Platform(); // Randomize platform positions platform.x = Math.random() * (2048 - platform.width) + platform.width / 2; platform.y = Math.random() * (2732 - 800) + 400; 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 + 5 && 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; // Reset jump count on landing hero.currentPlatform = platform; onAnyPlatform = true; // Safe landing effect after a long jump if (hero.vy > 15) { LK.effects.flashObject(hero, 0x00ff00, 500); // Flash green for safe landing } 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
@@ -157,9 +157,9 @@
if (self.isDashing) {
return;
}
self.direction = direction;
- self.vx = 1.5 * direction; // Further reduced speed for even slower movement
+ self.vx = 3 * direction; // Reduced speed for slower movement
heroGraphics.scaleX = direction;
};
self.stopMoving = function () {
if (self.isDashing) {
@@ -170,15 +170,13 @@
self.jump = function () {
if (self.isDashing) {
return;
}
- if (self.jumpCount < self.maxJumps || self.onGround) {
- self.vy = -10; // Reduced jump velocity for a short range jump
- self.jumpCount++;
- self.isJumping = true;
- self.onGround = false;
- LK.getSound('jump').play();
- }
+ 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;
@@ -229,9 +227,8 @@
}
// Check if hero has fallen off screen
if (self.y > 2732) {
LK.getSound('playerHurt').play();
- self.jumpCount = 0; // Reset jump count when falling off screen
LK.showGameOver();
}
};
return self;
@@ -266,18 +263,18 @@
var scoreText;
// Controls state
var leftPressed = false;
var rightPressed = false;
+// Set the game background to an image of Ada Lovelace
+var adaBackground = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+});
+game.addChild(adaBackground);
// Initialize game elements
function initGame() {
- // Attach background image
- var background = LK.getAsset('background', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2,
- y: 2732 / 2
- });
- game.addChild(background);
// Create hero
hero = new Hero();
game.addChild(hero);
// Create platforms
@@ -446,16 +443,12 @@
enemies.splice(j, 1);
// Update score
enemyCount--;
scoreText.setText("Enemies: " + enemyCount);
- // Respawn enemy on a random platform
- var platformIndex = Math.floor(Math.random() * (platforms.length - 1)) + 1;
- var newEnemy = new Enemy();
- newEnemy.init(platforms[platformIndex]);
- newEnemy.x += Math.random() * 100 - 50; // Offset enemy position to avoid overlap
- game.addChild(newEnemy);
- enemies.push(newEnemy);
- 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);
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