User prompt
enemy death after 250 hits
User prompt
add background
User prompt
peluru bos menyebar 3 saat tembakkan
User prompt
peluru musuh menyebar dua setiap tembak
User prompt
jangkauan peluru musub tambah jauh
User prompt
peluru musuh bergerak cepat
User prompt
tap layar berulang di mana saja agar karakter yang dimainkan bisa lompat
User prompt
pergerakkan boss buat cekup pelan
User prompt
pergerakkan boss sampai ke layar bawah
User prompt
pergerakkan boss lebih jauh ke atas dan kebawah
User prompt
buat pakai level. tambah naik level tambah susah dikalahkan
User prompt
hilangkan asset platform
User prompt
player bisa lompat tak terbatas
User prompt
player bisa 7 x jump. player auto shooter. musuh bisa menembak ke arah musuh
User prompt
buat game side scrolling action platform. random generate platform. jumping and shooting boss enemy
Code edit (1 edits merged)
Please save this source code
User prompt
Jet Fighter vs Godzilla
Initial prompt
buat game pesawat canggih bertempur dengan godzilla. godzilla menyerang dengan semburan api
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 20;
self.maxHealth = 20;
self.shootTimer = 0;
self.shootInterval = 90; // 1.5 seconds at 60fps
self.moveTimer = 0;
self.moveDirection = 1;
self.baseY = self.y;
self.update = function () {
// Boss movement pattern
self.moveTimer++;
self.y = self.baseY + Math.sin(self.moveTimer * 0.05) * 50;
// Shooting pattern
self.shootTimer++;
if (self.shootTimer >= self.shootInterval) {
self.shoot();
self.shootTimer = 0;
}
// Flash when hit
if (self.hitFlash > 0) {
self.hitFlash--;
bossGraphics.tint = self.hitFlash % 10 < 5 ? 0xff0000 : 0xffffff;
} else {
bossGraphics.tint = 0xffffff;
}
};
self.hitFlash = 0;
self.shoot = function () {
LK.getSound('bossShoot').play();
// Create boss bullet aimed at player
var bullet = new BossBullet();
bullet.x = self.x - 150;
bullet.y = self.y;
// Calculate direction to player
var deltaX = player.x - bullet.x;
var deltaY = player.y - bullet.y;
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
var speed = 6;
bullet.speedX = deltaX / distance * speed;
bullet.speedY = deltaY / distance * speed;
bossBullets.push(bullet);
game.addChild(bullet);
// Flash effect
tween(bossGraphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
onFinish: function onFinish() {
tween(bossGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
};
self.takeDamage = function () {
self.health--;
self.hitFlash = 30;
LK.getSound('hit').play();
if (self.health <= 0) {
self.destroy();
LK.showYouWin();
}
};
return self;
});
var BossBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bossBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.lifetime = 0;
self.maxLifetime = 300;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
self.lifetime++;
if (self.lifetime >= self.maxLifetime || self.x < -50) {
self.shouldDestroy = true;
}
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12;
self.lifetime = 0;
self.maxLifetime = 300; // 5 seconds at 60fps
self.update = function () {
self.x += self.speed;
self.lifetime++;
if (self.lifetime >= self.maxLifetime || self.x > 2200) {
self.shouldDestroy = true;
}
};
return self;
});
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
self.scrollSpeed = 2;
self.update = function () {
self.x -= self.scrollSpeed;
if (self.x < -100) {
self.shouldDestroy = true;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.gravity = 0.8;
self.jumpPower = -15;
self.isGrounded = false;
self.isDead = false;
self.moveSpeed = 6;
self.shootCooldown = 0;
self.lastGrounded = false;
self.jumpsRemaining = 7;
self.maxJumps = 7;
self.update = function () {
// Apply gravity
if (!self.isGrounded) {
self.velocityY += self.gravity;
}
// Apply vertical movement
self.y += self.velocityY;
// Ground collision detection
self.isGrounded = false;
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (self.intersects(platform) && self.velocityY >= 0) {
// Check if player is falling onto platform from above
if (self.y - 40 < platform.y - 20) {
self.y = platform.y - 40;
self.velocityY = 0;
self.isGrounded = true;
break;
}
}
}
// Ground floor collision
if (self.y > 2600) {
self.y = 2600;
self.velocityY = 0;
self.isGrounded = true;
}
// Landing sound effect and reset jumps
if (!self.lastGrounded && self.isGrounded && self.velocityY >= 0) {
LK.getSound('jump').play();
self.jumpsRemaining = self.maxJumps; // Reset jumps when landing
}
self.lastGrounded = self.isGrounded;
// Boundary checking
if (self.x < 30) self.x = 30;
if (self.x > 800) self.x = 800; // Keep player on left side of screen
if (self.y < 30) self.y = 30;
// Reduce shoot cooldown
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
// Auto-shooting
if (self.shootCooldown <= 0) {
self.shoot();
}
};
self.jump = function () {
if (self.jumpsRemaining > 0) {
self.velocityY = self.jumpPower;
self.jumpsRemaining--;
self.isGrounded = false;
LK.getSound('jump').play();
}
};
self.shoot = function () {
if (self.shootCooldown <= 0) {
var bullet = new Bullet();
bullet.x = self.x + 30;
bullet.y = self.y;
bullets.push(bullet);
game.addChild(bullet);
self.shootCooldown = 15; // Quarter second cooldown
LK.getSound('shoot').play();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var player;
var boss;
var platforms = [];
var bullets = [];
var bossBullets = [];
var score = 0;
var platformTimer = 0;
var scrollSpeed = 2;
var gameStarted = false;
// UI elements
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var healthTxt = new Text2('Boss Health: 20', {
size: 60,
fill: 0xFF0000
});
healthTxt.anchor.set(0, 0);
healthTxt.x = 120;
healthTxt.y = 20;
LK.gui.topLeft.addChild(healthTxt);
var jumpsTxt = new Text2('Jumps: 7', {
size: 60,
fill: 0x00FF00
});
jumpsTxt.anchor.set(1, 0);
jumpsTxt.x = 2048 - 20;
jumpsTxt.y = 20;
LK.gui.topRight.addChild(jumpsTxt);
// Initialize game objects
function initializeGame() {
// Create player
player = game.addChild(new Player());
player.x = 200;
player.y = 2500;
// Create boss
boss = game.addChild(new Boss());
boss.x = 1700;
boss.y = 1000;
boss.baseY = boss.y;
// Create initial platforms
for (var i = 0; i < 5; i++) {
createRandomPlatform(i * 400 + 500);
}
// Start background music
LK.playMusic('gameMusic');
gameStarted = true;
}
// Create random platform at specified x position
function createRandomPlatform(x) {
var platform = new Platform();
platform.x = x;
platform.y = 1500 + Math.random() * 800; // Random height between 1500-2300
platform.width = 150 + Math.random() * 100; // Random width 150-250
platforms.push(platform);
game.addChild(platform);
}
// Touch controls for jumping and shooting
var jumpPressed = false;
var shootPressed = false;
game.down = function (x, y, obj) {
if (!gameStarted || player.isDead) return;
if (y > 2200) {
// Bottom half of screen for jumping
if (!jumpPressed) {
player.jump();
jumpPressed = true;
}
} else {
// Top half of screen for shooting
if (!shootPressed) {
player.shoot();
shootPressed = true;
}
}
};
game.up = function (x, y, obj) {
jumpPressed = false;
shootPressed = false;
};
// Main game update
game.update = function () {
if (!gameStarted || player.isDead) return;
// Generate new platforms
platformTimer++;
if (platformTimer >= 120) {
// Every 2 seconds
createRandomPlatform(2200);
platformTimer = 0;
}
// Update platforms
for (var i = platforms.length - 1; i >= 0; i--) {
var platform = platforms[i];
if (platform.shouldDestroy) {
platform.destroy();
platforms.splice(i, 1);
}
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.shouldDestroy) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet vs boss collision
if (bullet.intersects(boss)) {
boss.takeDamage();
bullet.destroy();
bullets.splice(i, 1);
score += 10;
LK.setScore(score);
}
}
// Update boss bullets
for (var i = bossBullets.length - 1; i >= 0; i--) {
var bossBullet = bossBullets[i];
if (bossBullet.shouldDestroy) {
bossBullet.destroy();
bossBullets.splice(i, 1);
continue;
}
// Check boss bullet vs player collision
if (bossBullet.intersects(player) && !player.isDead) {
player.isDead = true;
// Player death effect
LK.effects.flashScreen(0xff0000, 1000);
tween(player, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
LK.showGameOver();
}
});
}
}
// Update UI
scoreTxt.setText('Score: ' + score);
if (boss && boss.health !== undefined) {
healthTxt.setText('Boss Health: ' + boss.health);
}
jumpsTxt.setText('Jumps: ' + player.jumpsRemaining);
// Check if player falls off screen
if (player.y > 2800) {
player.isDead = true;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
};
// Initialize the game
initializeGame(); ===================================================================
--- original.js
+++ change.js
@@ -39,13 +39,19 @@
};
self.hitFlash = 0;
self.shoot = function () {
LK.getSound('bossShoot').play();
- // Create boss bullet
+ // Create boss bullet aimed at player
var bullet = new BossBullet();
bullet.x = self.x - 150;
bullet.y = self.y;
- bullet.speedY = Math.random() * 4 - 2; // Random vertical spread
+ // Calculate direction to player
+ var deltaX = player.x - bullet.x;
+ var deltaY = player.y - bullet.y;
+ var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+ var speed = 6;
+ bullet.speedX = deltaX / distance * speed;
+ bullet.speedY = deltaY / distance * speed;
bossBullets.push(bullet);
game.addChild(bullet);
// Flash effect
tween(bossGraphics, {
@@ -79,9 +85,9 @@
var bulletGraphics = self.attachAsset('bossBullet', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speedX = -8;
+ self.speedX = 0;
self.speedY = 0;
self.lifetime = 0;
self.maxLifetime = 300;
self.update = function () {
@@ -140,8 +146,10 @@
self.isDead = false;
self.moveSpeed = 6;
self.shootCooldown = 0;
self.lastGrounded = false;
+ self.jumpsRemaining = 7;
+ self.maxJumps = 7;
self.update = function () {
// Apply gravity
if (!self.isGrounded) {
self.velocityY += self.gravity;
@@ -167,11 +175,12 @@
self.y = 2600;
self.velocityY = 0;
self.isGrounded = true;
}
- // Landing sound effect
+ // Landing sound effect and reset jumps
if (!self.lastGrounded && self.isGrounded && self.velocityY >= 0) {
LK.getSound('jump').play();
+ self.jumpsRemaining = self.maxJumps; // Reset jumps when landing
}
self.lastGrounded = self.isGrounded;
// Boundary checking
if (self.x < 30) self.x = 30;
@@ -180,12 +189,17 @@
// Reduce shoot cooldown
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
+ // Auto-shooting
+ if (self.shootCooldown <= 0) {
+ self.shoot();
+ }
};
self.jump = function () {
- if (self.isGrounded) {
+ if (self.jumpsRemaining > 0) {
self.velocityY = self.jumpPower;
+ self.jumpsRemaining--;
self.isGrounded = false;
LK.getSound('jump').play();
}
};
@@ -236,8 +250,16 @@
healthTxt.anchor.set(0, 0);
healthTxt.x = 120;
healthTxt.y = 20;
LK.gui.topLeft.addChild(healthTxt);
+var jumpsTxt = new Text2('Jumps: 7', {
+ size: 60,
+ fill: 0x00FF00
+});
+jumpsTxt.anchor.set(1, 0);
+jumpsTxt.x = 2048 - 20;
+jumpsTxt.y = 20;
+LK.gui.topRight.addChild(jumpsTxt);
// Initialize game objects
function initializeGame() {
// Create player
player = game.addChild(new Player());
@@ -353,8 +375,9 @@
scoreTxt.setText('Score: ' + score);
if (boss && boss.health !== undefined) {
healthTxt.setText('Boss Health: ' + boss.health);
}
+ jumpsTxt.setText('Jumps: ' + player.jumpsRemaining);
// Check if player falls off screen
if (player.y > 2800) {
player.isDead = true;
LK.effects.flashScreen(0xff0000, 1000);
monglkey king raja kera di atas awan kinton menyerang dengan tongkat sakti. side scroller image. In-Game asset. 2d. High contrast. No shadows
erlang shen. the sun wukong enemy. side scroller image. atack with fire In-Game asset. 2d. High contrast. No shadows
dari jauh terlihat istana langit di atas awan luas versi fantasy china. In-Game asset. 2d. High contrast. No shadows