User prompt
alt barda kllanılan gemiden sonra rastgele başka bir gemi gelsin
User prompt
oyun alanında diğer eşleşmelerden sonra beliren aynı renk gemiler de ayn yana olursa da birleşip üst seviye gemi olsun
User prompt
birbirine temas eden aynı renk gemiler birleşip tek bir üst seviye gemi olsun
User prompt
oyun ilk açıldığında oyun alanında gemi olmasın ve alt barda 3 farklı gemi olsun ve en fazla 3 gemi olabilsin oyun alanına koyulan gemiler yer değiştiremesin en üst seviye gemiler birleştiğinde çevresindeki gemiler batsın ve bonus puan versin
User prompt
altta bir bar içinde farklı gemiler olsun. başlangıçta birinci seviye gemi varken yeni gemiler açıldıkça alt barda yeni gemiler de çıksın .oyuncu bu gemileri sürükleme yöntemi ile oyun alanına bıaksın. 3 ve daha fazla sayıda aynı tür gemi yan yana alt alta veya L şeklinde hizalandığında birleşip tek bir gemi olsun ve üst seviye gemi olsun
User prompt
Please fix the bug: 'ReferenceError: mergeShips is not defined' in or related to this line: 'mergeShips(draggingShip, targetShip);' Line Number: 372
User prompt
arka plana bir deniz koy
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'gridX')' in or related to this line: 'var key = ship.gridX + "," + ship.gridY;' Line Number: 195
User prompt
3 aynı tür gemi birbirine temas edince birleşip bir üst seviye olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Pirate Merge Armada
Initial prompt
merge pirate tarzı gemi birleştirme oyunu yapmak istiyorum
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Ship class for mergeable ships var Ship = Container.expand(function () { var self = Container.call(this); // Level of the ship (1-6) self.level = 1; self.gridX = 0; self.gridY = 0; self.isDragging = false; // Attach ship asset var shipSprite = self.attachAsset('ship' + self.level, { anchorX: 0.5, anchorY: 0.5 }); // Update ship sprite to match level self.setLevel = function (level) { self.level = level; self.removeChild(shipSprite); var newSprite = self.attachAsset('ship' + level, { anchorX: 0.5, anchorY: 0.5 }); shipSprite = newSprite; }; // Animate merge self.animateMerge = function () { tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.easeIn }); } }); }; // Animate spawn self.animateSpawn = function () { self.scaleX = 0.2; self.scaleY = 0.2; tween(self, { scaleX: 1, scaleY: 1 }, { duration: 180, easing: tween.easeOut }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0e1621 }); /**** * Game Code ****/ // Pirate ship assets for different levels (1-6) // --- Game Constants --- var GRID_SIZE = 5; var CELL_SIZE = 230; var GRID_MARGIN = 30; var BOARD_WIDTH = GRID_SIZE * CELL_SIZE; var BOARD_HEIGHT = GRID_SIZE * CELL_SIZE; var BOARD_X = Math.floor((2048 - BOARD_WIDTH) / 2); var BOARD_Y = Math.floor((2732 - BOARD_HEIGHT) / 2) + 60; // leave top margin for GUI // --- Game State --- var grid = []; // 2D array [y][x] of Ship or null var ships = []; // All ship objects var draggingShip = null; var dragStartGrid = null; var dragOffsetX = 0; var dragOffsetY = 0; var isMerging = false; var score = 0; var scoreTxt = null; // --- GUI --- scoreTxt = new Text2('0', { size: 120, fill: 0xFFE066 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // --- Board Background --- for (var y = 0; y < GRID_SIZE; y++) { for (var x = 0; x < GRID_SIZE; x++) { var cell = LK.getAsset('cell', { anchorX: 0.5, anchorY: 0.5, x: BOARD_X + x * CELL_SIZE + CELL_SIZE / 2, y: BOARD_Y + y * CELL_SIZE + CELL_SIZE / 2 }); game.addChild(cell); } } // --- Grid Initialization --- for (var y = 0; y < GRID_SIZE; y++) { grid[y] = []; for (var x = 0; x < GRID_SIZE; x++) { grid[y][x] = null; } } // --- Helper Functions --- function getCellPos(x, y) { return { x: BOARD_X + x * CELL_SIZE + CELL_SIZE / 2, y: BOARD_Y + y * CELL_SIZE + CELL_SIZE / 2 }; } function isInsideGrid(x, y) { return x >= 0 && x < GRID_SIZE && y >= 0 && y < GRID_SIZE; } function getGridFromPos(px, py) { var gx = Math.floor((px - BOARD_X) / CELL_SIZE); var gy = Math.floor((py - BOARD_Y) / CELL_SIZE); if (isInsideGrid(gx, gy)) { return { x: gx, y: gy }; } return null; } function spawnRandomShip() { // Find all empty cells var empties = []; for (var y = 0; y < GRID_SIZE; y++) { for (var x = 0; x < GRID_SIZE; x++) { if (!grid[y][x]) empties.push({ x: x, y: y }); } } if (empties.length === 0) return false; var idx = Math.floor(Math.random() * empties.length); var cell = empties[idx]; var level = Math.random() < 0.85 ? 1 : 2; // 85% level 1, 15% level 2 var ship = new Ship(); ship.setLevel(level); ship.gridX = cell.x; ship.gridY = cell.y; var pos = getCellPos(cell.x, cell.y); ship.x = pos.x; ship.y = pos.y; ship.animateSpawn(); grid[cell.y][cell.x] = ship; ships.push(ship); game.addChild(ship); return true; } function canMerge(shipA, shipB) { return shipA && shipB && shipA.level === shipB.level && shipA !== shipB; } function mergeShips(shipA, shipB) { // Merge shipA into shipB, remove shipA var newLevel = shipB.level + 1; if (newLevel > 6) newLevel = 6; shipB.setLevel(newLevel); shipB.animateMerge(); // Remove shipA from grid and scene grid[shipA.gridY][shipA.gridX] = null; ships.splice(ships.indexOf(shipA), 1); shipA.destroy(); // Update score var addScore = Math.pow(2, newLevel + 1) * 10; score += addScore; scoreTxt.setText(score); } function hasMovesAvailable() { // If any empty cell or any mergeable neighbor, return true for (var y = 0; y < GRID_SIZE; y++) { for (var x = 0; x < GRID_SIZE; x++) { var ship = grid[y][x]; if (!ship) return true; // Check neighbors var dirs = [[0, 1], [1, 0], [-1, 0], [0, -1]]; for (var d = 0; d < dirs.length; d++) { var nx = x + dirs[d][0]; var ny = y + dirs[d][1]; if (isInsideGrid(nx, ny) && grid[ny][nx] && grid[ny][nx].level === ship.level) { return true; } } } } return false; } // --- Initial Ships --- for (var i = 0; i < 3; i++) { spawnRandomShip(); } // --- Drag & Drop Logic --- game.down = function (x, y, obj) { if (isMerging) return; // Find ship at this position var gridPos = getGridFromPos(x, y); if (!gridPos) return; var ship = grid[gridPos.y][gridPos.x]; if (!ship) return; draggingShip = ship; dragStartGrid = { x: ship.gridX, y: ship.gridY }; dragOffsetX = x - ship.x; dragOffsetY = y - ship.y; ship.isDragging = true; // Bring to front game.removeChild(ship); game.addChild(ship); // Animate tween(ship, { scaleX: 1.15, scaleY: 1.15 }, { duration: 100, easing: tween.easeOut }); }; game.move = function (x, y, obj) { if (!draggingShip || isMerging) return; // Move ship with finger draggingShip.x = x - dragOffsetX; draggingShip.y = y - dragOffsetY; }; game.up = function (x, y, obj) { if (!draggingShip || isMerging) return; // Snap to nearest cell var gridPos = getGridFromPos(draggingShip.x, draggingShip.y); if (!gridPos) { // Out of bounds, return to original var orig = getCellPos(dragStartGrid.x, dragStartGrid.y); tween(draggingShip, { x: orig.x, y: orig.y, scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.easeIn }); draggingShip.isDragging = false; draggingShip = null; return; } var targetShip = grid[gridPos.y][gridPos.x]; if (targetShip && canMerge(draggingShip, targetShip)) { // Merge! isMerging = true; var pos = getCellPos(gridPos.x, gridPos.y); tween(draggingShip, { x: pos.x, y: pos.y }, { duration: 100, easing: tween.linear, onFinish: function onFinish() { mergeShips(draggingShip, targetShip); // Move merged ship to cell targetShip.gridX = gridPos.x; targetShip.gridY = gridPos.y; grid[dragStartGrid.y][dragStartGrid.x] = null; grid[gridPos.y][gridPos.x] = targetShip; isMerging = false; draggingShip = null; // After merge, spawn new ship if (!spawnRandomShip()) { // No space, check for moves if (!hasMovesAvailable()) { LK.showGameOver(); } } } }); } else if (!targetShip) { // Move to empty cell var pos = getCellPos(gridPos.x, gridPos.y); tween(draggingShip, { x: pos.x, y: pos.y, scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.easeIn, onFinish: function onFinish() { // Update grid grid[dragStartGrid.y][dragStartGrid.x] = null; grid[gridPos.y][gridPos.x] = draggingShip; draggingShip.gridX = gridPos.x; draggingShip.gridY = gridPos.y; draggingShip.isDragging = false; draggingShip = null; // After move, spawn new ship if (!spawnRandomShip()) { if (!hasMovesAvailable()) { LK.showGameOver(); } } } }); } else { // Occupied, can't merge, return to original var orig = getCellPos(dragStartGrid.x, dragStartGrid.y); tween(draggingShip, { x: orig.x, y: orig.y, scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.easeIn }); draggingShip.isDragging = false; draggingShip = null; } }; // --- Game Update (not used for logic, but could be for future animations) --- game.update = function () { // No per-frame logic needed for MVP };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,340 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Ship class for mergeable ships
+var Ship = Container.expand(function () {
+ var self = Container.call(this);
+ // Level of the ship (1-6)
+ self.level = 1;
+ self.gridX = 0;
+ self.gridY = 0;
+ self.isDragging = false;
+ // Attach ship asset
+ var shipSprite = self.attachAsset('ship' + self.level, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Update ship sprite to match level
+ self.setLevel = function (level) {
+ self.level = level;
+ self.removeChild(shipSprite);
+ var newSprite = self.attachAsset('ship' + level, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ shipSprite = newSprite;
+ };
+ // Animate merge
+ self.animateMerge = function () {
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 120,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 120,
+ easing: tween.easeIn
+ });
+ }
+ });
+ };
+ // Animate spawn
+ self.animateSpawn = function () {
+ self.scaleX = 0.2;
+ self.scaleY = 0.2;
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 180,
+ easing: tween.easeOut
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x0e1621
+});
+
+/****
+* Game Code
+****/
+// Pirate ship assets for different levels (1-6)
+// --- Game Constants ---
+var GRID_SIZE = 5;
+var CELL_SIZE = 230;
+var GRID_MARGIN = 30;
+var BOARD_WIDTH = GRID_SIZE * CELL_SIZE;
+var BOARD_HEIGHT = GRID_SIZE * CELL_SIZE;
+var BOARD_X = Math.floor((2048 - BOARD_WIDTH) / 2);
+var BOARD_Y = Math.floor((2732 - BOARD_HEIGHT) / 2) + 60; // leave top margin for GUI
+// --- Game State ---
+var grid = []; // 2D array [y][x] of Ship or null
+var ships = []; // All ship objects
+var draggingShip = null;
+var dragStartGrid = null;
+var dragOffsetX = 0;
+var dragOffsetY = 0;
+var isMerging = false;
+var score = 0;
+var scoreTxt = null;
+// --- GUI ---
+scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFE066
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// --- Board Background ---
+for (var y = 0; y < GRID_SIZE; y++) {
+ for (var x = 0; x < GRID_SIZE; x++) {
+ var cell = LK.getAsset('cell', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: BOARD_X + x * CELL_SIZE + CELL_SIZE / 2,
+ y: BOARD_Y + y * CELL_SIZE + CELL_SIZE / 2
+ });
+ game.addChild(cell);
+ }
+}
+// --- Grid Initialization ---
+for (var y = 0; y < GRID_SIZE; y++) {
+ grid[y] = [];
+ for (var x = 0; x < GRID_SIZE; x++) {
+ grid[y][x] = null;
+ }
+}
+// --- Helper Functions ---
+function getCellPos(x, y) {
+ return {
+ x: BOARD_X + x * CELL_SIZE + CELL_SIZE / 2,
+ y: BOARD_Y + y * CELL_SIZE + CELL_SIZE / 2
+ };
+}
+function isInsideGrid(x, y) {
+ return x >= 0 && x < GRID_SIZE && y >= 0 && y < GRID_SIZE;
+}
+function getGridFromPos(px, py) {
+ var gx = Math.floor((px - BOARD_X) / CELL_SIZE);
+ var gy = Math.floor((py - BOARD_Y) / CELL_SIZE);
+ if (isInsideGrid(gx, gy)) {
+ return {
+ x: gx,
+ y: gy
+ };
+ }
+ return null;
+}
+function spawnRandomShip() {
+ // Find all empty cells
+ var empties = [];
+ for (var y = 0; y < GRID_SIZE; y++) {
+ for (var x = 0; x < GRID_SIZE; x++) {
+ if (!grid[y][x]) empties.push({
+ x: x,
+ y: y
+ });
+ }
+ }
+ if (empties.length === 0) return false;
+ var idx = Math.floor(Math.random() * empties.length);
+ var cell = empties[idx];
+ var level = Math.random() < 0.85 ? 1 : 2; // 85% level 1, 15% level 2
+ var ship = new Ship();
+ ship.setLevel(level);
+ ship.gridX = cell.x;
+ ship.gridY = cell.y;
+ var pos = getCellPos(cell.x, cell.y);
+ ship.x = pos.x;
+ ship.y = pos.y;
+ ship.animateSpawn();
+ grid[cell.y][cell.x] = ship;
+ ships.push(ship);
+ game.addChild(ship);
+ return true;
+}
+function canMerge(shipA, shipB) {
+ return shipA && shipB && shipA.level === shipB.level && shipA !== shipB;
+}
+function mergeShips(shipA, shipB) {
+ // Merge shipA into shipB, remove shipA
+ var newLevel = shipB.level + 1;
+ if (newLevel > 6) newLevel = 6;
+ shipB.setLevel(newLevel);
+ shipB.animateMerge();
+ // Remove shipA from grid and scene
+ grid[shipA.gridY][shipA.gridX] = null;
+ ships.splice(ships.indexOf(shipA), 1);
+ shipA.destroy();
+ // Update score
+ var addScore = Math.pow(2, newLevel + 1) * 10;
+ score += addScore;
+ scoreTxt.setText(score);
+}
+function hasMovesAvailable() {
+ // If any empty cell or any mergeable neighbor, return true
+ for (var y = 0; y < GRID_SIZE; y++) {
+ for (var x = 0; x < GRID_SIZE; x++) {
+ var ship = grid[y][x];
+ if (!ship) return true;
+ // Check neighbors
+ var dirs = [[0, 1], [1, 0], [-1, 0], [0, -1]];
+ for (var d = 0; d < dirs.length; d++) {
+ var nx = x + dirs[d][0];
+ var ny = y + dirs[d][1];
+ if (isInsideGrid(nx, ny) && grid[ny][nx] && grid[ny][nx].level === ship.level) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+// --- Initial Ships ---
+for (var i = 0; i < 3; i++) {
+ spawnRandomShip();
+}
+// --- Drag & Drop Logic ---
+game.down = function (x, y, obj) {
+ if (isMerging) return;
+ // Find ship at this position
+ var gridPos = getGridFromPos(x, y);
+ if (!gridPos) return;
+ var ship = grid[gridPos.y][gridPos.x];
+ if (!ship) return;
+ draggingShip = ship;
+ dragStartGrid = {
+ x: ship.gridX,
+ y: ship.gridY
+ };
+ dragOffsetX = x - ship.x;
+ dragOffsetY = y - ship.y;
+ ship.isDragging = true;
+ // Bring to front
+ game.removeChild(ship);
+ game.addChild(ship);
+ // Animate
+ tween(ship, {
+ scaleX: 1.15,
+ scaleY: 1.15
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+};
+game.move = function (x, y, obj) {
+ if (!draggingShip || isMerging) return;
+ // Move ship with finger
+ draggingShip.x = x - dragOffsetX;
+ draggingShip.y = y - dragOffsetY;
+};
+game.up = function (x, y, obj) {
+ if (!draggingShip || isMerging) return;
+ // Snap to nearest cell
+ var gridPos = getGridFromPos(draggingShip.x, draggingShip.y);
+ if (!gridPos) {
+ // Out of bounds, return to original
+ var orig = getCellPos(dragStartGrid.x, dragStartGrid.y);
+ tween(draggingShip, {
+ x: orig.x,
+ y: orig.y,
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 120,
+ easing: tween.easeIn
+ });
+ draggingShip.isDragging = false;
+ draggingShip = null;
+ return;
+ }
+ var targetShip = grid[gridPos.y][gridPos.x];
+ if (targetShip && canMerge(draggingShip, targetShip)) {
+ // Merge!
+ isMerging = true;
+ var pos = getCellPos(gridPos.x, gridPos.y);
+ tween(draggingShip, {
+ x: pos.x,
+ y: pos.y
+ }, {
+ duration: 100,
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ mergeShips(draggingShip, targetShip);
+ // Move merged ship to cell
+ targetShip.gridX = gridPos.x;
+ targetShip.gridY = gridPos.y;
+ grid[dragStartGrid.y][dragStartGrid.x] = null;
+ grid[gridPos.y][gridPos.x] = targetShip;
+ isMerging = false;
+ draggingShip = null;
+ // After merge, spawn new ship
+ if (!spawnRandomShip()) {
+ // No space, check for moves
+ if (!hasMovesAvailable()) {
+ LK.showGameOver();
+ }
+ }
+ }
+ });
+ } else if (!targetShip) {
+ // Move to empty cell
+ var pos = getCellPos(gridPos.x, gridPos.y);
+ tween(draggingShip, {
+ x: pos.x,
+ y: pos.y,
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 120,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ // Update grid
+ grid[dragStartGrid.y][dragStartGrid.x] = null;
+ grid[gridPos.y][gridPos.x] = draggingShip;
+ draggingShip.gridX = gridPos.x;
+ draggingShip.gridY = gridPos.y;
+ draggingShip.isDragging = false;
+ draggingShip = null;
+ // After move, spawn new ship
+ if (!spawnRandomShip()) {
+ if (!hasMovesAvailable()) {
+ LK.showGameOver();
+ }
+ }
+ }
+ });
+ } else {
+ // Occupied, can't merge, return to original
+ var orig = getCellPos(dragStartGrid.x, dragStartGrid.y);
+ tween(draggingShip, {
+ x: orig.x,
+ y: orig.y,
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 120,
+ easing: tween.easeIn
+ });
+ draggingShip.isDragging = false;
+ draggingShip = null;
+ }
+};
+// --- Game Update (not used for logic, but could be for future animations) ---
+game.update = function () {
+ // No per-frame logic needed for MVP
+};
\ No newline at end of file
deniz arka plan. In-Game asset. 2d. High contrast. No shadows
3d piksar tarzı şeffaf kare. In-Game asset. 2d. High contrast. No shadows
3d pixar tarzı korsan gemisi beyaz renk. In-Game asset. 2d. High contrast. No shadows
beyaz bölgeler sarı olsun
beyaz kısımlar açık yeşil olsun
beyaz kısımlar mavi olsun
mavi kısımlar koyu mor olsun
mor kısımlar siyah olsun