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
User prompt
fix shoot respo
User prompt
make the distance greater between the control pad and the shooting pad
User prompt
move control touchpad to lefft
User prompt
move shoot touch pad to right side bank
User prompt
delete player interval for shoot
User prompt
move shoot button to right side
User prompt
add touch pad for player shoot
User prompt
player bullet interval 1 second
User prompt
playe bullet interval 2 second
User prompt
enemy bullet inter chanhe to 2 second
User prompt
enemy bullet interval 0,5 second
User prompt
delete charge attack
User prompt
rockmonster dificult to defeat
User prompt
make touch pad for control player
User prompt
fix control
Code edit (1 edits merged)
Please save this source code
User prompt
Magic Adventurer vs Rock Monster
Initial prompt
magic adventurer vs rock monster. hold to control player
/**** * 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 self.x += self.moveDirection * self.moveSpeed; if (self.x <= 200 || self.x >= 1848) { self.moveDirection *= -1; } // Attack timer self.attackTimer++; if (self.attackTimer >= self.attackCooldown) { self.attack(); self.attackTimer = 0; } }; return self; }); var Touchpad = Container.expand(function () { var self = Container.call(this); var baseGraphics = self.attachAsset('touchpadBase', { anchorX: 0.5, anchorY: 0.5 }); var knobGraphics = self.attachAsset('touchpadKnob', { anchorX: 0.5, anchorY: 0.5 }); var shootButtonGraphics = self.attachAsset('shootButton', { anchorX: 0.5, anchorY: 0.5 }); shootButtonGraphics.x = 200; shootButtonGraphics.y = 0; shootButtonGraphics.alpha = 0.7; self.knob = knobGraphics; self.shootButton = shootButtonGraphics; self.maxDistance = 35; self.isActive = false; self.inputX = 0; self.inputY = 0; baseGraphics.alpha = 0.6; knobGraphics.alpha = 0.8; self.updateKnob = function (x, y) { var dx = x - self.x; var dy = y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance <= self.maxDistance) { self.knob.x = dx; self.knob.y = dy; } else { var angle = Math.atan2(dy, dx); self.knob.x = Math.cos(angle) * self.maxDistance; self.knob.y = Math.sin(angle) * self.maxDistance; } self.inputX = self.knob.x / self.maxDistance; self.inputY = self.knob.y / self.maxDistance; }; self.resetKnob = function () { self.knob.x = 0; self.knob.y = 0; self.inputX = 0; self.inputY = 0; self.isActive = false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2C3E50 }); /**** * Game Code ****/ 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 touchpad = game.addChild(new Touchpad()); touchpad.x = 200; touchpad.y = 2500; var touchpadActive = false; // 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) { if (touchpadActive) { touchpad.updateKnob(x, y); } } game.move = handleMove; game.down = function (x, y, obj) { // Check if touching shoot button area var shootButtonX = touchpad.x + 200; var shootButtonY = touchpad.y; var shootDx = x - shootButtonX; var shootDy = y - shootButtonY; var shootDistance = Math.sqrt(shootDx * shootDx + shootDy * shootDy); if (shootDistance <= 50) { adventurer.castSpell(); return; } // Check if touching touchpad area var dx = x - touchpad.x; var dy = y - touchpad.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance <= 80) { touchpadActive = true; touchpad.isActive = true; touchpad.updateKnob(x, y); } }; game.up = function (x, y, obj) { if (touchpadActive) { touchpad.resetKnob(); touchpadActive = false; } }; game.update = function () { // Update adventurer movement with touchpad if (touchpad.isActive) { var moveSpeed = 6; var newX = adventurer.x + touchpad.inputX * moveSpeed; var newY = adventurer.y + touchpad.inputY * moveSpeed; adventurer.x = Math.max(40, Math.min(2008, newX)); adventurer.y = Math.max(1500, Math.min(2680, newY)); } // Update magic bolts for (var i = magicBolts.length - 1; i >= 0; i--) { var bolt = magicBolts[i]; if (bolt.y < -50) { bolt.destroy(); magicBolts.splice(i, 1); continue; } if (bolt.intersects(rockMonster)) { 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]; if (attack.y > 2800) { attack.destroy(); monsterAttacks.splice(i, 1); continue; } if (attack.intersects(adventurer)) { adventurer.takeDamage(attack.damage); LK.getSound('playerHit').play(); attack.destroy(); monsterAttacks.splice(i, 1); } } // Update health displays adventurerHealthBar.setText('Health: ' + adventurer.health); monsterHealthBar.setText('Monster: ' + rockMonster.health); };
===================================================================
--- original.js
+++ change.js
@@ -171,9 +171,9 @@
var magicBolts = [];
var monsterAttacks = [];
var dragNode = null;
var touchpad = game.addChild(new Touchpad());
-touchpad.x = 1848;
+touchpad.x = 200;
touchpad.y = 2500;
var touchpadActive = false;
// Health bars
var adventurerHealthBar = new Text2('Health: 100', {
litle girl ride flyng broom stick. In-Game asset. 2d. High contrast. No shadows
evil black gray cloud monster. In-Game asset. 2d. High contrast. No shadows
black dark lighting orb ball In-Game asset. 2d. High contrast. No shadows
langit biru cerah, daerah hutan luas, di kejauhan ada pedesaaan sederhana. suasana pagi hari langit biru. In-Game asset. 2d. High contrast. No shadows