User prompt
delete rockmonster animation hit
User prompt
reduce game resolution
User prompt
reduce player bullet speed
User prompt
player 1 second interval shoot
User prompt
enemy 1 second intervall shoot
User prompt
delete shoot touchpad
User prompt
player 1 second interval shoot
User prompt
player auto shooting 2 second interval bullet
User prompt
delete all touchpad
User prompt
player auto matic shooter 2 second interval
User prompt
percepat lagi gerakkan peluru musuh
User prompt
percepat gerakkan peluru musuh
User prompt
kurangi jumlah peluruh musuh
User prompt
perbaiki game sebab sering patah patah
User prompt
buatkan kembali touchpad untuk kontrol player kanan kiri . player hanya bisa bergerak kanan kiri
User prompt
percepat lagi peluru pemain
User prompt
musuh bisa menyerang dengan peluru ke arah pergerakkan pemain
User prompt
percepat lagi peluru pemain
User prompt
percepat peluru pemain
User prompt
perbaiko game agar tidak patah patahh atau membeku sesaat
User prompt
hilangkan touchpad kontrol dan rubah ke mode kontrol gulir
User prompt
pindahkan tombol touch pad shoot ke kanan bawah layar
User prompt
fix suara music
User prompt
add background asset
User prompt
shoot interval 2 second
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Adventurer = Container.expand(function () { var self = Container.call(this); var adventurerGraphics = self.attachAsset('adventurer', { anchorX: 0.5, anchorY: 0.5 }); self.maxHealth = 100; self.health = self.maxHealth; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.health = 0; LK.showGameOver(); } LK.effects.flashObject(self, 0xFF0000, 500); }; self.castSpell = function () { var bolt = game.addChild(new MagicBolt()); bolt.x = self.x; bolt.y = self.y - 30; bolt.damage = 15; magicBolts.push(bolt); LK.getSound('magicCast').play(); LK.effects.flashObject(self, 0xFFD700, 300); }; return self; }); var MagicBolt = Container.expand(function () { var self = Container.call(this); var boltGraphics = self.attachAsset('magicBolt', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.damage = 10; self.update = function () { self.y -= self.speed; }; return self; }); var MonsterAttack = Container.expand(function () { var self = Container.call(this); var attackGraphics = self.attachAsset('monsterAttack', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.damage = 35; self.update = function () { self.y += self.speed; self.rotation += 0.2; }; return self; }); var RockMonster = Container.expand(function () { var self = Container.call(this); var monsterGraphics = self.attachAsset('rockMonster', { anchorX: 0.5, anchorY: 0.5 }); self.maxHealth = 500; self.health = self.maxHealth; self.attackTimer = 0; self.attackCooldown = 120; self.moveDirection = 1; self.moveSpeed = 2; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.health = 0; LK.showYouWin(); } LK.effects.flashObject(self, 0xFF0000, 400); LK.getSound('monsterHit').play(); }; self.attack = function () { var attack = game.addChild(new MonsterAttack()); attack.x = self.x; attack.y = self.y + 120; monsterAttacks.push(attack); }; self.update = function () { // Move side to side with boundary safety self.x += self.moveDirection * self.moveSpeed; if (self.x <= 200) { self.x = 200; self.moveDirection = 1; } else if (self.x >= 1848) { self.x = 1848; self.moveDirection = -1; } // Attack timer with safety check self.attackTimer++; if (self.attackTimer >= self.attackCooldown && self.attackTimer < self.attackCooldown + 10) { self.attack(); self.attackTimer = 0; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2C3E50 }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0 })); var adventurer = game.addChild(new Adventurer()); adventurer.x = 1024; adventurer.y = 2200; var rockMonster = game.addChild(new RockMonster()); rockMonster.x = 1024; rockMonster.y = 400; var magicBolts = []; var monsterAttacks = []; var dragNode = null; var shootCooldown = 0; var lastMoveX = 0; var lastMoveY = 0; var shootButton = game.addChild(LK.getAsset('shootButton', { anchorX: 0.5, anchorY: 0.5, x: 1750, y: 2500, alpha: 0.7 })); // Health bars var adventurerHealthBar = new Text2('Health: 100', { size: 60, fill: 0x00FF00 }); adventurerHealthBar.anchor.set(0, 0); LK.gui.bottomLeft.addChild(adventurerHealthBar); var monsterHealthBar = new Text2('Monster: 500', { size: 60, fill: 0xFF0000 }); monsterHealthBar.anchor.set(0.5, 0); LK.gui.top.addChild(monsterHealthBar); function handleMove(x, y, obj) { // Calculate movement delta for scroll control var deltaX = x - lastMoveX; var deltaY = y - lastMoveY; // Move adventurer based on touch/mouse movement if (dragNode) { var moveSpeed = 1.5; var newX = adventurer.x + deltaX * moveSpeed; var newY = adventurer.y + deltaY * moveSpeed; adventurer.x = Math.max(40, Math.min(2008, newX)); adventurer.y = Math.max(1500, Math.min(2680, newY)); } lastMoveX = x; lastMoveY = y; } // Start background music LK.playMusic('1epicpertarunganpagi'); game.move = handleMove; game.down = function (x, y, obj) { // Check if touching shoot button var shootDx = x - shootButton.x; var shootDy = y - shootButton.y; var shootDistance = Math.sqrt(shootDx * shootDx + shootDy * shootDy); if (shootDistance <= 150) { if (shootCooldown <= 0) { adventurer.castSpell(); shootCooldown = 120; // 2 seconds at 60 FPS } return; } // Start drag control for movement dragNode = adventurer; lastMoveX = x; lastMoveY = y; }; game.up = function (x, y, obj) { // Stop drag control dragNode = null; }; game.update = function () { // Update magic bolts for (var i = magicBolts.length - 1; i >= 0; i--) { var bolt = magicBolts[i]; // Initialize collision tracking if (bolt.hasHitMonster === undefined) { bolt.hasHitMonster = false; } if (bolt.y < -50) { bolt.destroy(); magicBolts.splice(i, 1); continue; } if (!bolt.hasHitMonster && bolt.intersects(rockMonster)) { bolt.hasHitMonster = true; rockMonster.takeDamage(bolt.damage); bolt.destroy(); magicBolts.splice(i, 1); } } // Update monster attacks for (var j = monsterAttacks.length - 1; j >= 0; j--) { var attack = monsterAttacks[j]; // Initialize collision tracking if (attack.hasHitAdventurer === undefined) { attack.hasHitAdventurer = false; } if (attack.y > 2800) { attack.destroy(); monsterAttacks.splice(j, 1); continue; } if (!attack.hasHitAdventurer && attack.intersects(adventurer)) { attack.hasHitAdventurer = true; adventurer.takeDamage(attack.damage); LK.getSound('playerHit').play(); attack.destroy(); monsterAttacks.splice(j, 1); } } // Update shoot cooldown if (shootCooldown > 0) { shootCooldown--; } // Update health displays adventurerHealthBar.setText('Health: ' + adventurer.health); monsterHealthBar.setText('Monster: ' + rockMonster.health); };
===================================================================
--- original.js
+++ change.js
@@ -87,16 +87,20 @@
attack.y = self.y + 120;
monsterAttacks.push(attack);
};
self.update = function () {
- // Move side to side
+ // Move side to side with boundary safety
self.x += self.moveDirection * self.moveSpeed;
- if (self.x <= 200 || self.x >= 1848) {
- self.moveDirection *= -1;
+ if (self.x <= 200) {
+ self.x = 200;
+ self.moveDirection = 1;
+ } else if (self.x >= 1848) {
+ self.x = 1848;
+ self.moveDirection = -1;
}
- // Attack timer
+ // Attack timer with safety check
self.attackTimer++;
- if (self.attackTimer >= self.attackCooldown) {
+ if (self.attackTimer >= self.attackCooldown && self.attackTimer < self.attackCooldown + 10) {
self.attack();
self.attackTimer = 0;
}
};
@@ -193,32 +197,42 @@
game.update = function () {
// Update magic bolts
for (var i = magicBolts.length - 1; i >= 0; i--) {
var bolt = magicBolts[i];
+ // Initialize collision tracking
+ if (bolt.hasHitMonster === undefined) {
+ bolt.hasHitMonster = false;
+ }
if (bolt.y < -50) {
bolt.destroy();
magicBolts.splice(i, 1);
continue;
}
- if (bolt.intersects(rockMonster)) {
+ if (!bolt.hasHitMonster && bolt.intersects(rockMonster)) {
+ bolt.hasHitMonster = true;
rockMonster.takeDamage(bolt.damage);
bolt.destroy();
magicBolts.splice(i, 1);
}
}
// Update monster attacks
- for (var i = monsterAttacks.length - 1; i >= 0; i--) {
- var attack = monsterAttacks[i];
+ for (var j = monsterAttacks.length - 1; j >= 0; j--) {
+ var attack = monsterAttacks[j];
+ // Initialize collision tracking
+ if (attack.hasHitAdventurer === undefined) {
+ attack.hasHitAdventurer = false;
+ }
if (attack.y > 2800) {
attack.destroy();
- monsterAttacks.splice(i, 1);
+ monsterAttacks.splice(j, 1);
continue;
}
- if (attack.intersects(adventurer)) {
+ if (!attack.hasHitAdventurer && attack.intersects(adventurer)) {
+ attack.hasHitAdventurer = true;
adventurer.takeDamage(attack.damage);
LK.getSound('playerHit').play();
attack.destroy();
- monsterAttacks.splice(i, 1);
+ monsterAttacks.splice(j, 1);
}
}
// Update shoot cooldown
if (shootCooldown > 0) {
16 bit image litle girl ride flyng broom stick. In-Game asset. 2d.
16 bit image evil black gray cloud monster. In-Game asset. 2d.
16 bit image black dark lighting orb ball In-Game asset. 2d.
16 bit image langit biru cerah, daerah hutan luas, di kejauhan ada pedesaaan sederhana. suasana pagi hari langit biru. In-Game asset. 2d.