User prompt
sayıları 10 saniyede bir tane artsın
User prompt
note lar 2 saniyede bir tane düşşün
User prompt
silah duvarın önünde sabit dursun
User prompt
mortar altı ile duvarın üstü ykın olsun
User prompt
duvar çözünürlüğünü kaybetmesin
User prompt
duvgar biraz uzun olsun
User prompt
duvarın canı sınırsız olsun
User prompt
can sınırsız olsun
User prompt
duvar mortarın üstünde olsun.mortar duvarın önünde olsun
User prompt
duvar çözünürlüğü yüksek olsun
User prompt
çözünürlük yüksek olsun
User prompt
wall genişliği soldan sağa olsun
User prompt
duvar biraz uzun olsun
User prompt
mortar biraz yukarıda olsun
User prompt
wall ekranın 10/2 sini kaplasın
User prompt
ekranda tıkladığım yere bomba atsın
Code edit (1 edits merged)
Please save this source code
User prompt
Nota Savunması: Havan Kulesi
Initial prompt
bir tower defan oyunu olsun.ekranın aşağısında duvarın üzerinde havan olsun.Ve karşıdan gelen müzik notalarına bomba atsın.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Bomb class: Fired by the mortar, moves upward, explodes on contact with a note var Bomb = Container.expand(function () { var self = Container.call(this); var bombAsset = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 28; // Always positive, direction handled by dirX/dirY self.radius = bombAsset.width * 0.5; self.dirX = 0; self.dirY = -1; self.update = function () { if (typeof self.lastX === "undefined") self.lastX = self.x; if (typeof self.lastY === "undefined") self.lastY = self.y; self.x += self.dirX * self.speed; self.y += self.dirY * self.speed; self.lastX = self.x; self.lastY = self.y; }; return self; }); // Mortar class: Player's cannon, can be dragged horizontally and fires bombs var Mortar = Container.expand(function () { var self = Container.call(this); var mortarAsset = self.attachAsset('mortar', { anchorX: 0.5, anchorY: 1 }); self.width = mortarAsset.width; self.height = mortarAsset.height; // For a little animation on fire self.fireAnim = function () { tween(self, { scaleX: 1.2, scaleY: 0.85 }, { duration: 80, easing: tween.cubicOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.cubicIn }); } }); }; return self; }); // Note class: Descends from the top, must be destroyed before reaching the wall var Note = Container.expand(function () { var self = Container.call(this); var noteAsset = self.attachAsset('note', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8 + Math.random() * 4; // Slight speed variation self.radius = noteAsset.width * 0.5; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181c2c }); /**** * Game Code ****/ // --- Game constants --- var GAME_W = 2048; var GAME_H = 2732; var WALL_HEIGHT = 260; var MORTAR_Y = GAME_H - WALL_HEIGHT - 180; var NOTE_SPAWN_INTERVAL = 60; // frames var NOTE_MIN_X = 180; var NOTE_MAX_X = GAME_W - 180; // --- Game state --- var bombs = []; var notes = []; var canShoot = true; var dragNode = null; var lastGameOver = false; var noteSpawnTick = 0; // --- Wall (defense line) --- var wallWidth = GAME_W; var wall = LK.getAsset('wall', { anchorX: 0, anchorY: 0, width: wallWidth, height: WALL_HEIGHT, x: 0, y: GAME_H - WALL_HEIGHT }); game.addChild(wall); // --- Mortar (player cannon) --- var mortar = new Mortar(); game.addChild(mortar); mortar.x = GAME_W / 2; mortar.y = MORTAR_Y; // --- Score display --- var scoreTxt = new Text2('0', { size: 120, fill: 0xFFF700 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // --- Helper: Clamp mortar movement within screen --- function clampMortarX(x) { var halfW = mortar.width * 0.5; if (x < halfW + 40) return halfW + 40; if (x > GAME_W - halfW - 40) return GAME_W - halfW - 40; return x; } // --- Dragging mortar --- game.down = function (x, y, obj) { // Only allow drag if touch is near the mortar var dx = x - mortar.x; var dy = y - mortar.y; if (Math.abs(dx) < mortar.width * 0.7 && Math.abs(dy) < mortar.height * 1.2) { dragNode = mortar; } }; game.up = function (x, y, obj) { dragNode = null; }; game.move = function (x, y, obj) { if (dragNode === mortar) { mortar.x = clampMortarX(x); } }; // --- Tap to fire bomb --- game.tap = function (x, y, obj) { // Only allow firing if tap is above the mortar and not on the wall if (canShoot && y < mortar.y - 60) { lastTapTarget = { x: x, y: y }; fireBomb(); } }; // For mobile, treat 'down' as tap if not dragging game.down = function (origDown) { return function (x, y, obj) { origDown && origDown(x, y, obj); if (!dragNode && canShoot && y < mortar.y - 60) { lastTapTarget = { x: x, y: y }; fireBomb(); } }; }(game.down); // --- Fire bomb logic --- // Store the last tap target for bomb direction var lastTapTarget = { x: mortar.x, y: mortar.y - 800 }; function fireBomb() { canShoot = false; var bomb = new Bomb(); bomb.x = mortar.x; bomb.y = mortar.y - mortar.height * 0.7; // Calculate direction vector from bomb to lastTapTarget var dx = lastTapTarget.x - bomb.x; var dy = lastTapTarget.y - bomb.y; var len = Math.sqrt(dx * dx + dy * dy); if (len === 0) { dx = 0; dy = -1; len = 1; } bomb.dirX = dx / len; bomb.dirY = dy / len; bombs.push(bomb); game.addChild(bomb); mortar.fireAnim(); // Allow next shot after short delay LK.setTimeout(function () { canShoot = true; }, 220); } // --- Spawn a note at random X --- function spawnNote() { var note = new Note(); note.x = NOTE_MIN_X + Math.random() * (NOTE_MAX_X - NOTE_MIN_X); note.y = -note.height * 0.5; notes.push(note); game.addChild(note); } // --- Main update loop --- game.update = function () { // --- Bombs update --- for (var i = bombs.length - 1; i >= 0; i--) { var bomb = bombs[i]; bomb.update(); // Remove if off screen if (bomb.y < -bomb.height) { bomb.destroy(); bombs.splice(i, 1); continue; } // Check collision with notes for (var j = notes.length - 1; j >= 0; j--) { var note = notes[j]; var dx = bomb.x - note.x; var dy = bomb.y - note.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < bomb.radius + note.radius - 10) { // Hit! note.destroy(); notes.splice(j, 1); bomb.destroy(); bombs.splice(i, 1); // Score up LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Small explosion effect LK.effects.flashObject(mortar, 0xfff700, 200); break; } } } // --- Notes update --- for (var k = notes.length - 1; k >= 0; k--) { var note = notes[k]; note.update(); // If note hits the wall, game over if (note.y + note.radius > wall.y) { if (!lastGameOver) { LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); lastGameOver = true; } return; } // Remove if off screen (shouldn't happen) if (note.y > GAME_H + note.height) { note.destroy(); notes.splice(k, 1); } } // --- Spawn notes at interval --- noteSpawnTick++; if (noteSpawnTick >= NOTE_SPAWN_INTERVAL) { spawnNote(); noteSpawnTick = 0; } }; // --- Reset state on new game --- LK.on('gameStart', function () { // Remove all bombs and notes for (var i = 0; i < bombs.length; i++) bombs[i].destroy(); for (var j = 0; j < notes.length; j++) notes[j].destroy(); bombs = []; notes = []; canShoot = true; lastGameOver = false; noteSpawnTick = 0; LK.setScore(0); scoreTxt.setText('0'); mortar.x = GAME_W / 2; }); // --- Asset initialization (shapes) --- // Mortar: a simple ellipse/circle // Bomb: small dark circle // Note: yellow ellipse (music note) // Wall: wide rectangle /* End of gamecode.js */
===================================================================
--- original.js
+++ change.js
@@ -82,15 +82,15 @@
/****
* Game Code
****/
// --- Game constants ---
-var GAME_W = 4096;
-var GAME_H = 5464;
-var WALL_HEIGHT = 520;
-var MORTAR_Y = GAME_H - WALL_HEIGHT - 360;
+var GAME_W = 2048;
+var GAME_H = 2732;
+var WALL_HEIGHT = 260;
+var MORTAR_Y = GAME_H - WALL_HEIGHT - 180;
var NOTE_SPAWN_INTERVAL = 60; // frames
-var NOTE_MIN_X = 360;
-var NOTE_MAX_X = GAME_W - 360;
+var NOTE_MIN_X = 180;
+var NOTE_MAX_X = GAME_W - 180;
// --- Game state ---
var bombs = [];
var notes = [];
var canShoot = true;
@@ -114,9 +114,9 @@
mortar.x = GAME_W / 2;
mortar.y = MORTAR_Y;
// --- Score display ---
var scoreTxt = new Text2('0', {
- size: 240,
+ size: 120,
fill: 0xFFF700
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
bu duvar geniş olsun
müzik notası olsun gözü ve keskin dişleri olsun. In-Game asset. 2d. High contrast. No shadows
gitar teli. In-Game asset. 2d. High contrast. No shadows
oyun background olacak.tam ekran olsun.bir konser sahnesine bakan koltuk bakış açısında olsun. In-Game asset. 2d. High contrast. No shadows
yüksek çözünürlüklü topdown bakış açısı makineli tüfek olsun. In-Game asset. 2d. High contrast. No shadows