User prompt
Her 100 skorda level artsın
User prompt
Havadan meteor yerine martılar geçsin ve bize çarparsa canımız gitsin
User prompt
Denizde dalga olsun ama dalgalar üstten gelsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Sağlık paketinden sadece 20 can versin
User prompt
Sağlık paketleri olsun onlara vurduğumuzda can kazanalım ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
seaMonsterı öldürdüğümüzde patalama sesi gelsin
User prompt
Köpek balıklarını öldürdüğümüzde patlama sesi gelsin
User prompt
Dalgalar daha gerçekçi olsun ve üstten gelsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Denizin içerisine dalga ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Havadan hızlı bir şekilde meteorlar da gelsin ve Şhip bir teknenin içinde olsun
User prompt
Oyun her 200 skorda level atlasın ve 100 level olsun
User prompt
seaMonsterler dahızlı gelsin ve gelirken bize ateş etsin hızlı bir şekilde ve seaMonster bizi geçerse canımız hgitsin
User prompt
seaMonsterlar havadan gelsin
Code edit (1 edits merged)
Please save this source code
User prompt
Sea Monster Battle
Initial prompt
Bir teknemiz olsun o teknenin içinden denizdeki yaratıklarla savaşalı
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var MonsterBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('projectile', { anchorX: 0.5, anchorY: 0.5 }); bulletGraphics.tint = 0xFF0000; // Red color for monster bullets self.speed = 10; self.update = function () { self.y += self.speed; }; return self; }); var Projectile = Container.expand(function () { var self = Container.call(this); var projectileGraphics = self.attachAsset('projectile', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -12; self.update = function () { self.y += self.speed; }; return self; }); var SeaMonster = Container.expand(function () { var self = Container.call(this); var monsterGraphics = self.attachAsset('seaMonster', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8 + Math.random() * 6; self.health = 1; self.lastShotTime = 0; self.shotCooldown = 600 + Math.random() * 400; // Random shooting interval self.update = function () { self.y += self.speed; // Monster shooting logic if (Date.now() - self.lastShotTime > self.shotCooldown) { self.lastShotTime = Date.now(); var bullet = new MonsterBullet(); bullet.x = self.x; bullet.y = self.y + 50; bullet.lastY = bullet.y; monsterBullets.push(bullet); game.addChild(bullet); } }; self.takeDamage = function () { self.health--; if (self.health <= 0) { LK.effects.flashObject(self, 0xFF0000, 200); return true; // Monster destroyed } return false; }; return self; }); var Ship = Container.expand(function () { var self = Container.call(this); var shipGraphics = self.attachAsset('ship', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.lastShotTime = 0; self.shotCooldown = 300; // milliseconds self.moveLeft = function () { self.x -= self.speed; if (self.x < shipGraphics.width / 2) { self.x = shipGraphics.width / 2; } }; self.moveRight = function () { self.x += self.speed; if (self.x > 2048 - shipGraphics.width / 2) { self.x = 2048 - shipGraphics.width / 2; } }; self.canShoot = function () { return Date.now() - self.lastShotTime > self.shotCooldown; }; self.shoot = function () { if (self.canShoot()) { self.lastShotTime = Date.now(); return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x006994 }); /**** * Game Code ****/ var ship; var projectiles = []; var seaMonsters = []; var monsterBullets = []; var dragNode = null; var monsterSpawnTimer = 0; var monsterSpawnInterval = 120; // frames var difficultyTimer = 0; // Initialize ship ship = game.addChild(new Ship()); ship.x = 2048 / 2; ship.y = 2732 - 150; // Score display var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Health display var healthTxt = new Text2('Health: 100', { size: 60, fill: 0xFFFFFF }); healthTxt.anchor.set(0, 0); healthTxt.x = 120; healthTxt.y = 20; LK.gui.topLeft.addChild(healthTxt); var playerHealth = 100; function updateScore() { scoreTxt.setText('Score: ' + LK.getScore()); } function updateHealth() { healthTxt.setText('Health: ' + playerHealth); } function spawnMonster() { var monster = new SeaMonster(); monster.x = Math.random() * (2048 - 100) + 50; monster.y = -50; monster.lastY = monster.y; seaMonsters.push(monster); game.addChild(monster); } function handleMove(x, y, obj) { if (dragNode === ship) { ship.x = x; if (ship.x < 60) ship.x = 60; if (ship.x > 2048 - 60) ship.x = 2048 - 60; } } game.move = handleMove; game.down = function (x, y, obj) { dragNode = ship; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; game.update = function () { // Increase difficulty over time difficultyTimer++; if (difficultyTimer % 1800 === 0) { // Every 30 seconds monsterSpawnInterval = Math.max(30, monsterSpawnInterval - 10); } // Spawn monsters monsterSpawnTimer++; if (monsterSpawnTimer >= monsterSpawnInterval) { spawnMonster(); monsterSpawnTimer = 0; } // Auto-shoot from ship if (ship.shoot()) { var projectile = new Projectile(); projectile.x = ship.x; projectile.y = ship.y - 40; projectile.lastY = projectile.y; projectiles.push(projectile); game.addChild(projectile); LK.getSound('shoot').play(); } // Update and check projectiles for (var i = projectiles.length - 1; i >= 0; i--) { var projectile = projectiles[i]; // Check if projectile went off screen if (projectile.lastY >= -20 && projectile.y < -20) { projectile.destroy(); projectiles.splice(i, 1); continue; } // Check projectile-monster collisions var hit = false; for (var j = seaMonsters.length - 1; j >= 0; j--) { var monster = seaMonsters[j]; if (projectile.intersects(monster)) { if (monster.takeDamage()) { LK.setScore(LK.getScore() + 10); updateScore(); LK.getSound('hit').play(); monster.destroy(); seaMonsters.splice(j, 1); } projectile.destroy(); projectiles.splice(i, 1); hit = true; break; } } if (!hit) { projectile.lastY = projectile.y; } } // Update and check monster bullets for (var b = monsterBullets.length - 1; b >= 0; b--) { var bullet = monsterBullets[b]; // Check if bullet hit ship if (bullet.intersects(ship)) { playerHealth -= 15; updateHealth(); LK.effects.flashScreen(0xFF0000, 300); bullet.destroy(); monsterBullets.splice(b, 1); if (playerHealth <= 0) { LK.showGameOver(); return; } continue; } // Check if bullet went off screen (bottom) if (bullet.lastY <= 2732 + 20 && bullet.y > 2732 + 20) { bullet.destroy(); monsterBullets.splice(b, 1); continue; } bullet.lastY = bullet.y; } // Update and check sea monsters for (var k = seaMonsters.length - 1; k >= 0; k--) { var monster = seaMonsters[k]; // Check if monster reached ship if (monster.intersects(ship)) { playerHealth -= 20; updateHealth(); LK.effects.flashScreen(0xFF0000, 500); monster.destroy(); seaMonsters.splice(k, 1); if (playerHealth <= 0) { LK.showGameOver(); return; } continue; } // Check if monster went off screen (bottom) - player loses health if (monster.lastY <= 2732 + 50 && monster.y > 2732 + 50) { playerHealth -= 10; // Lose health when monster passes updateHealth(); LK.effects.flashScreen(0xFFFF00, 200); // Yellow flash for passed monster monster.destroy(); seaMonsters.splice(k, 1); if (playerHealth <= 0) { LK.showGameOver(); return; } continue; } monster.lastY = monster.y; } // Win condition (optional high score target) if (LK.getScore() >= 1000) { LK.showYouWin(); } }; // Start background music LK.playMusic('ocean'); // Initialize displays updateScore(); updateHealth();
===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,21 @@
/****
* Classes
****/
+var MonsterBullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('projectile', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ bulletGraphics.tint = 0xFF0000; // Red color for monster bullets
+ self.speed = 10;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
var Projectile = Container.expand(function () {
var self = Container.call(this);
var projectileGraphics = self.attachAsset('projectile', {
anchorX: 0.5,
@@ -23,12 +36,24 @@
var monsterGraphics = self.attachAsset('seaMonster', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 2 + Math.random() * 3;
+ self.speed = 8 + Math.random() * 6;
self.health = 1;
+ self.lastShotTime = 0;
+ self.shotCooldown = 600 + Math.random() * 400; // Random shooting interval
self.update = function () {
self.y += self.speed;
+ // Monster shooting logic
+ if (Date.now() - self.lastShotTime > self.shotCooldown) {
+ self.lastShotTime = Date.now();
+ var bullet = new MonsterBullet();
+ bullet.x = self.x;
+ bullet.y = self.y + 50;
+ bullet.lastY = bullet.y;
+ monsterBullets.push(bullet);
+ game.addChild(bullet);
+ }
};
self.takeDamage = function () {
self.health--;
if (self.health <= 0) {
@@ -85,8 +110,9 @@
****/
var ship;
var projectiles = [];
var seaMonsters = [];
+var monsterBullets = [];
var dragNode = null;
var monsterSpawnTimer = 0;
var monsterSpawnInterval = 120; // frames
var difficultyTimer = 0;
@@ -193,8 +219,32 @@
if (!hit) {
projectile.lastY = projectile.y;
}
}
+ // Update and check monster bullets
+ for (var b = monsterBullets.length - 1; b >= 0; b--) {
+ var bullet = monsterBullets[b];
+ // Check if bullet hit ship
+ if (bullet.intersects(ship)) {
+ playerHealth -= 15;
+ updateHealth();
+ LK.effects.flashScreen(0xFF0000, 300);
+ bullet.destroy();
+ monsterBullets.splice(b, 1);
+ if (playerHealth <= 0) {
+ LK.showGameOver();
+ return;
+ }
+ continue;
+ }
+ // Check if bullet went off screen (bottom)
+ if (bullet.lastY <= 2732 + 20 && bullet.y > 2732 + 20) {
+ bullet.destroy();
+ monsterBullets.splice(b, 1);
+ continue;
+ }
+ bullet.lastY = bullet.y;
+ }
// Update and check sea monsters
for (var k = seaMonsters.length - 1; k >= 0; k--) {
var monster = seaMonsters[k];
// Check if monster reached ship
@@ -209,12 +259,19 @@
return;
}
continue;
}
- // Check if monster went off screen (bottom)
+ // Check if monster went off screen (bottom) - player loses health
if (monster.lastY <= 2732 + 50 && monster.y > 2732 + 50) {
+ playerHealth -= 10; // Lose health when monster passes
+ updateHealth();
+ LK.effects.flashScreen(0xFFFF00, 200); // Yellow flash for passed monster
monster.destroy();
seaMonsters.splice(k, 1);
+ if (playerHealth <= 0) {
+ LK.showGameOver();
+ return;
+ }
continue;
}
monster.lastY = monster.y;
}
İnsan. In-Game asset. 2d. High contrast. No shadows
Büyük tekne. In-Game asset. 2d. High contrast. No shadows
Köpek balığı. In-Game asset. 2d. High contrast. No shadows
Deniz dalgası. In-Game asset. 2d. High contrast. No shadows
Sağlık paketi. In-Game asset. 2d. High contrast. No shadows
Martı. In-Game asset. 2d. High contrast. No shadows