User prompt
O zaman her 5 puanda bir rouglike seçme ekranı olsun şimdilik bunlar olsun devamını ekleyeceğim
User prompt
Hayır mesela orada tıklamamız gerekecek yani play butonuna arkası simsiyah olabilir
User prompt
Hayır tıklayıp oyuna başlayabileceğimiz bir ana menü
User prompt
Oyuna bir başlangıç ekranı koylalım hani başla tuşudur falan
User prompt
Yılan sağ sola hareket ettirilmiyor
User prompt
Neyse ekrana tıklama olsun baya buglu çalışıyor
User prompt
Bence şöyle olsun kırmızı buton oyunda her zaman ekranın sol köşesinin altında olsun ve tıkladığında yılanın baktığı yöne ateş etsin yani yılan donmasın
User prompt
Kutulu odalarda oyun crash veriyo
User prompt
O zaman şöyle yapalım bi kırmızı tuş ekle ve bu tuşa basıldığında ateş edilsin
User prompt
Şimdi de kutulu elma gelince oyun durdu
User prompt
Kutulu odalar gelince hareket edilmiyor
User prompt
Ama şu an ekrana tıklıyorum ve ateş etmiyor
User prompt
Oyunda iki tuş ekleyelim biri bizim silah ateşleme tuşu olurken digeri kılıç tuşu olsun kılıç da şu işe yarıyor oyunda düşmanlar olacak ve silahla ölmeyecek bizde onları kılıçla devirecez ama hareket için tuşlar ekleme
User prompt
Oyuna bir başlangıç ekranı ekleyelim yazan isimi yerde "snaker" yazsın
User prompt
Elmalar ya da kutular gidebileceğimiz pixel pixel yerlere göre değişsin yani tam da gidebileceğimiz pixellerin üstünde olsun
User prompt
Mermi assetlerinin yönü baktığımız yere göre değişsin
User prompt
Bence daha açık renkli olsun ya da sen arkaya image koy ben yaprım
User prompt
Sen şu oyun alanını birazcık renkli yap canlı olsun
User prompt
Ama kutulu elmalar geldiğinde başka bi elma olmasın yani illaki onu kırıp elmayı yememiz gereksin
User prompt
Yılanın gittiği yöne ateş etsin
User prompt
Artık oyunda bazen %25 ihtimalle kutulu elmalar olacak bu elmalara çarpışınca ölecek yiyebilmek için elimizdeki silahla ona ateş edip sonra yememiz gerekecek
User prompt
Generate the first version of the source code of my game: Snake Classic.
User prompt
Snake Classic
Initial prompt
Bir oyun bu oyun snake e benzer bir oyun olacak ama daha kalitlerisi şimdilik normal snake oyunu yap
/**** * Classes ****/ // BoxFood class (dangerous apple) var BoxFood = Container.expand(function () { var self = Container.call(this); var boxAsset = self.attachAsset('boxFood', { anchorX: 0.5, anchorY: 0.5 }); self.isBox = true; self.destroyedByBullet = false; return self; }); // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletAsset = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); // Default speed values (will be set on fire) self.speedX = 32; self.speedY = 0; self.update = function () { self.lastX = self.x; self.lastY = self.y; self.x += self.speedX; self.y += self.speedY; }; return self; }); // Food class var Food = Container.expand(function () { var self = Container.call(this); var foodAsset = self.attachAsset('food', { anchorX: 0.5, anchorY: 0.5 }); self.isBox = false; return self; }); // Snake segment class var Segment = Container.expand(function () { var self = Container.call(this); var segAsset = self.attachAsset('snakeSegment', { anchorX: 0.5, anchorY: 0.5 }); return self; }); // Snake class var Snake = Container.expand(function () { var self = Container.call(this); self.segments = []; self.direction = 'right'; self.nextDirection = 'right'; self.moveTimer = 0; self.moveInterval = 16; // Lower is faster, 16 = ~4 moves/sec at 60fps self.alive = true; // Initialize snake with 4 segments for (var i = 0; i < 4; i++) { var seg = new Segment(); seg.x = 1024 - i * 64; seg.y = 1366; self.addChild(seg); self.segments.push(seg); } self.update = function () { if (!self.alive) return; // Prevent movement if box food is active and not destroyed by bullet if (typeof boxFoodActive !== "undefined" && typeof boxFoodObj !== "undefined" && boxFoodActive && boxFoodObj && !boxFoodObj.destroyedByBullet) { return; } if (typeof boxFoodActive !== "undefined" && typeof boxFoodObj !== "undefined" && boxFoodActive && boxFoodObj && boxFoodObj.destroyedByBullet) { // Allow movement if box food is destroyed by bullet } self.moveTimer++; if (self.moveTimer < self.moveInterval) return; self.moveTimer = 0; // Update direction self.direction = self.nextDirection; // Calculate new head position var head = self.segments[0]; var newX = head.x; var newY = head.y; if (self.direction === 'right') newX += 64;else if (self.direction === 'left') newX -= 64;else if (self.direction === 'up') newY -= 64;else if (self.direction === 'down') newY += 64; // Move body for (var i = self.segments.length - 1; i > 0; i--) { self.segments[i].x = self.segments[i - 1].x; self.segments[i].y = self.segments[i - 1].y; } head.x = newX; head.y = newY; }; self.grow = function () { var last = self.segments[self.segments.length - 1]; var seg = new Segment(); seg.x = last.x; seg.y = last.y; self.addChild(seg); self.segments.push(seg); }; return self; }); /**** * Initialize Game ****/ // Game variables var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Game variables var snake; var food; var scoreTxt; var gameOver = false; var bullets = []; var boxFoods = []; var boxFoodActive = false; var boxFoodObj = null; // --- Splash screen variables --- var splashContainer = new Container(); var splashBg = LK.getAsset('yourBackgroundImageId', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732 }); splashContainer.addChild(splashBg); var splashTitle = new Text2('snaker', { size: 240, fill: 0xFFFFFF }); splashTitle.anchor.set(0.5, 0.5); splashTitle.x = 2048 / 2; splashTitle.y = 2732 / 2; splashContainer.addChild(splashTitle); game.addChild(splashContainer); var splashActive = true; // Remove splash and start game on first tap game.down = function (x, y, obj) { if (splashActive) { splashActive = false; splashContainer.destroy(); // After splash, allow normal game.down (fire bullet) to work game.down = function (x, y, obj) { lastTouchX = x; lastTouchY = y; // Fire bullet from snake head in the direction the snake is moving if box food is active if (boxFoodActive && boxFoodObj && snake && snake.segments.length > 0) { var head = snake.segments[0]; var bullet = new Bullet(); bullet.x = head.x; bullet.y = head.y; bullet.lastX = bullet.x; // Set bullet speed and direction based on snake direction, and rotate asset accordingly if (snake.direction === 'right') { bullet.speedX = 32; bullet.speedY = 0; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = 0; } else if (snake.direction === 'left') { bullet.speedX = -32; bullet.speedY = 0; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = Math.PI; } else if (snake.direction === 'up') { bullet.speedX = 0; bullet.speedY = -32; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = -Math.PI / 2; } else if (snake.direction === 'down') { bullet.speedX = 0; bullet.speedY = 32; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = Math.PI / 2; } bullets.push(bullet); game.addChild(bullet); } }; return; } // If splash is not active, do nothing here (game.down will be replaced) }; // Add a bright background image (replace 'yourBackgroundImageId' with your own image asset id) var bgImage = LK.getAsset('yourBackgroundImageId', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732 }); game.addChild(bgImage); // Create snake snake = new Snake(); game.addChild(snake); // Create food function spawnFood() { // Remove previous food if (food) food.destroy(); // Remove previous box food if present if (boxFoodObj) { boxFoodObj.destroy(); boxFoodObj = null; boxFoodActive = false; } // 25% chance to spawn box food if (Math.random() < 0.25) { // Build a list of all possible grid positions var possiblePositions = []; for (var gx = 64; gx <= 2048 - 64; gx += 64) { for (var gy = 64; gy <= 2732 - 64; gy += 64) { var occupied = false; for (var i = 0; i < snake.segments.length; i++) { if (Math.abs(snake.segments[i].x - gx) < 1 && Math.abs(snake.segments[i].y - gy) < 1) { occupied = true; break; } } if (!occupied) possiblePositions.push({ x: gx, y: gy }); } } if (possiblePositions.length > 0) { var idx = Math.floor(Math.random() * possiblePositions.length); var newBoxFood = new BoxFood(); newBoxFood.x = possiblePositions[idx].x; newBoxFood.y = possiblePositions[idx].y; game.addChild(newBoxFood); boxFoods.push(newBoxFood); boxFoodObj = newBoxFood; boxFoodActive = true; // Do not spawn normal food when box food is active food = null; } } else { // Only normal food // Build a list of all possible grid positions var possiblePositions = []; for (var gx = 64; gx <= 2048 - 64; gx += 64) { for (var gy = 64; gy <= 2732 - 64; gy += 64) { var occupied = false; for (var i = 0; i < snake.segments.length; i++) { if (Math.abs(snake.segments[i].x - gx) < 1 && Math.abs(snake.segments[i].y - gy) < 1) { occupied = true; break; } } if (!occupied) possiblePositions.push({ x: gx, y: gy }); } } if (possiblePositions.length > 0) { var idx = Math.floor(Math.random() * possiblePositions.length); food = new Food(); food.x = possiblePositions[idx].x; food.y = possiblePositions[idx].y; game.addChild(food); boxFoodActive = false; boxFoodObj = null; } } } spawnFood(); // Score text scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Game update game.update = function () { if (gameOver) return; snake.update(); // Check wall collision var head = snake.segments[0]; if (head.x < 0 || head.x > 2048 || head.y < 0 || head.y > 2732) { gameOver = true; LK.showGameOver(); return; } // Check self collision for (var i = 1; i < snake.segments.length; i++) { if (Math.abs(head.x - snake.segments[i].x) < 1 && Math.abs(head.y - snake.segments[i].y) < 1) { gameOver = true; LK.showGameOver(); return; } } // Handle bullets for (var b = bullets.length - 1; b >= 0; b--) { var bullet = bullets[b]; bullet.update(); // Remove bullet if off screen if (bullet.x > 2048 + 32) { bullet.destroy(); bullets.splice(b, 1); continue; } // Check collision with box food if (boxFoodActive && boxFoodObj && !boxFoodObj._destroyed && !boxFoodObj.destroyedByBullet && bullet.intersects(boxFoodObj)) { boxFoodObj.destroyedByBullet = true; bullet.destroy(); bullets.splice(b, 1); // Change box food color to indicate it's now edible (optional: destroy and respawn as normal food) boxFoodObj.attachAsset('food', { anchorX: 0.5, anchorY: 0.5 }); } } // Check food collision if (food && head.intersects(food)) { snake.grow(); LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); spawnFood(); // Speed up as snake grows if (snake.moveInterval > 4) snake.moveInterval--; } // SWORD ATTACK LOGIC if (swordActive) { swordTimer++; // Sword effect follows head if (swordEffect && snake && snake.segments.length > 0) { var head = snake.segments[0]; swordEffect.x = head.x; swordEffect.y = head.y; } // Check for box food collision with sword if (boxFoodActive && boxFoodObj && !boxFoodObj._destroyed && snake && snake.segments.length > 0) { var head = snake.segments[0]; if (head.intersects(boxFoodObj) && !boxFoodObj.destroyedByBullet) { // Defeat box food with sword snake.grow(); LK.setScore(LK.getScore() + 2); scoreTxt.setText(LK.getScore()); boxFoodObj.destroy(); boxFoodObj = null; boxFoodActive = false; spawnFood(); if (snake.moveInterval > 4) snake.moveInterval--; // End sword effect swordActive = false; swordTimer = 0; if (swordEffect) { swordEffect.destroy(); swordEffect = null; } } } // Sword duration end if (swordTimer > swordDuration) { swordActive = false; swordTimer = 0; if (swordEffect) { swordEffect.destroy(); swordEffect = null; } } } // Check box food collision if (boxFoodActive && boxFoodObj && !boxFoodObj._destroyed) { if (head.intersects(boxFoodObj)) { if (boxFoodObj.destroyedByBullet) { // Now edible snake.grow(); LK.setScore(LK.getScore() + 2); // Maybe more points for box food scoreTxt.setText(LK.getScore()); boxFoodObj.destroy(); boxFoodObj = null; boxFoodActive = false; spawnFood(); if (snake.moveInterval > 4) snake.moveInterval--; } else if (!swordActive) { // Deadly! gameOver = true; LK.showGameOver(); return; } } } }; // Touch controls var lastTouchX = null; var lastTouchY = null; // --- On-screen buttons for fire and sword --- // Red circular fire button var fireBtn = new Container(); var fireBtnBg = LK.getAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, width: 180, height: 180 }); fireBtnBg.tint = 0xff2222; fireBtn.addChild(fireBtnBg); var fireBtnTxt = new Text2('FIRE', { size: 60, fill: 0xffffff }); fireBtnTxt.anchor.set(0.5, 0.5); fireBtnTxt.x = 0; fireBtnTxt.y = 0; fireBtn.addChild(fireBtnTxt); fireBtn.x = 2048 - 200; fireBtn.y = 2732 - 250; fireBtn.interactive = true; fireBtn.buttonMode = true; LK.gui.bottomRight.addChild(fireBtn); var swordBtn = new Container(); var swordBtnBg = LK.getAsset('snakeSegment', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, width: 180, height: 180 }); swordBtn.addChild(swordBtnBg); var swordBtnTxt = new Text2('SWORD', { size: 60, fill: 0xffffff }); swordBtnTxt.anchor.set(0.5, 0.5); swordBtnTxt.x = 0; swordBtnTxt.y = 0; swordBtn.addChild(swordBtnTxt); swordBtn.x = 2048 - 420; swordBtn.y = 2732 - 250; swordBtn.interactive = true; swordBtn.buttonMode = true; LK.gui.bottom.addChild(swordBtn); // Sword attack state var swordActive = false; var swordTimer = 0; var swordDuration = 18; // ~0.3s at 60fps // Sword attack visual (simple overlay on snake head) var swordEffect = null; // Fire button handler fireBtn.down = function (x, y, obj) { // Fire bullet from snake head in the direction the snake is moving if box food is active if (boxFoodActive && boxFoodObj && snake && snake.segments.length > 0) { var head = snake.segments[0]; var bullet = new Bullet(); bullet.x = head.x; bullet.y = head.y; bullet.lastX = bullet.x; // Set bullet speed and direction based on snake direction, and rotate asset accordingly if (snake.direction === 'right') { bullet.speedX = 32; bullet.speedY = 0; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = 0; } else if (snake.direction === 'left') { bullet.speedX = -32; bullet.speedY = 0; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = Math.PI; } else if (snake.direction === 'up') { bullet.speedX = 0; bullet.speedY = -32; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = -Math.PI / 2; } else if (snake.direction === 'down') { bullet.speedX = 0; bullet.speedY = 32; if (bullet.children && bullet.children.length > 0) bullet.children[0].rotation = Math.PI / 2; } bullets.push(bullet); game.addChild(bullet); } }; // Sword button handler swordBtn.down = function (x, y, obj) { if (!swordActive && snake && snake.segments.length > 0) { swordActive = true; swordTimer = 0; // Visual effect: overlay a segment asset on head, colored if (swordEffect) swordEffect.destroy(); var head = snake.segments[0]; swordEffect = LK.getAsset('snakeSegment', { anchorX: 0.5, anchorY: 0.5 }); swordEffect.x = head.x; swordEffect.y = head.y; swordEffect.alpha = 0.7; swordEffect.tint = 0xffe600; game.addChild(swordEffect); } }; // Main game tap: only direction change, no firing game.down = function (x, y, obj) { // Check if tap is on fireBtn or swordBtn (ignore if so) if (obj && (obj === fireBtn || obj === swordBtn)) return; // Otherwise, treat as direction change lastTouchX = x; lastTouchY = y; }; // --- SWORD LOGIC in update (see below) --- game.up = function (x, y, obj) { if (lastTouchX === null || lastTouchY === null) return; var dx = x - lastTouchX; var dy = y - lastTouchY; if (Math.abs(dx) > Math.abs(dy)) { if (dx > 0 && snake.direction !== 'left') snake.nextDirection = 'right';else if (dx < 0 && snake.direction !== 'right') snake.nextDirection = 'left'; } else { if (dy > 0 && snake.direction !== 'up') snake.nextDirection = 'down';else if (dy < 0 && snake.direction !== 'down') snake.nextDirection = 'up'; } lastTouchX = null; lastTouchY = null; };
===================================================================
--- original.js
+++ change.js
@@ -308,9 +308,9 @@
bullets.splice(b, 1);
continue;
}
// Check collision with box food
- if (boxFoodActive && boxFoodObj && !boxFoodObj.destroyedByBullet && bullet.intersects(boxFoodObj)) {
+ if (boxFoodActive && boxFoodObj && !boxFoodObj._destroyed && !boxFoodObj.destroyedByBullet && bullet.intersects(boxFoodObj)) {
boxFoodObj.destroyedByBullet = true;
bullet.destroy();
bullets.splice(b, 1);
// Change box food color to indicate it's now edible (optional: destroy and respawn as normal food)
@@ -320,9 +320,9 @@
});
}
}
// Check food collision
- if (head.intersects(food)) {
+ if (food && head.intersects(food)) {
snake.grow();
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
spawnFood();
@@ -338,9 +338,9 @@
swordEffect.x = head.x;
swordEffect.y = head.y;
}
// Check for box food collision with sword
- if (boxFoodActive && boxFoodObj && snake && snake.segments.length > 0) {
+ if (boxFoodActive && boxFoodObj && !boxFoodObj._destroyed && snake && snake.segments.length > 0) {
var head = snake.segments[0];
if (head.intersects(boxFoodObj) && !boxFoodObj.destroyedByBullet) {
// Defeat box food with sword
snake.grow();
@@ -370,9 +370,9 @@
}
}
}
// Check box food collision
- if (boxFoodActive && boxFoodObj) {
+ if (boxFoodActive && boxFoodObj && !boxFoodObj._destroyed) {
if (head.intersects(boxFoodObj)) {
if (boxFoodObj.destroyedByBullet) {
// Now edible
snake.grow();
Bir top pixel art yeşil renkli. In-Game asset. 2d. High contrast. No shadows
Pixel art bullet. In-Game asset. 2d. High contrast. No shadows
Pixel art apple. In-Game asset. 2d. High contrast. No shadows
Çimen ama bütün elranı kaplıyor . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Kırmızı bir pixel art oyun tuşu. In-Game asset. 2d. High contrast. No shadows
2D pixel art para kasası. In-Game asset. High contrast. No shadows
A red MONSTER . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat