User prompt
bağlılar olmasınlar
User prompt
ykarı ve aşağı butonu birbirlerinin aynısı oluyor bi yukarı bi ikiside aşağı
User prompt
yukarı aşaşğı gibi davranıyor
User prompt
yukarı gitmesini hani eksiden yukarısına tıkldııyorduk ya ordaki gibi olsum
User prompt
yukarı butonu bozuk yine aşağı götüryor ve bu sefer o bir buttonlarıda bozma
User prompt
yukarı aşağı götürüyor
User prompt
bu seferde yukarı bozuldu aşağı çalışıyor ama 2 sinide bozma
User prompt
şimdide aşağı butonu bozuldu
User prompt
yukarı gitme butonu aşağı götürüyor
User prompt
snkaeTrail olmaycak
User prompt
yılanın bedeni olmayacak sadce kafası olacak
User prompt
yılan uzamayacak sadce başı olacak
User prompt
yılan gittiği yerde kendisi bırakıyor ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yine ynalış
User prompt
aynı düzelt buton yanlış götürüyor
User prompt
yukarı butonu ters kontol ediyor
User prompt
yukarı butonu aşağıya götürüyor
User prompt
yıollanın haraket etmesi. butonlar yap yukarı aşağı sağa sola
User prompt
oyun dost yılllanlar ekle 10 sanitye içinde gelsinler ve yem bıraksınlar ama level 2 yem normal değil ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yılanın vücudu olmasın
User prompt
yılan kontrolleri geç alıgılıyor
User prompt
yılanın kafa ile vücdü birleştiren vücut parçasını sil
User prompt
odadaki duvarlar belli değil oyuncyular anlmaz
Code edit (1 edits merged)
Please save this source code
User prompt
Classic Snake
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Food = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('food', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Simple pulsing animation
var scale = 1 + Math.sin(LK.ticks * 0.1) * 0.1;
self.scaleX = scale;
self.scaleY = scale;
};
return self;
});
var SnakeSegment = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('snakeBody', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
// Game configuration
var GRID_SIZE = 40;
var BOARD_WIDTH = 20;
var BOARD_HEIGHT = 30;
var MOVE_DELAY = 8; // Frames between moves
// Game state variables
var snake = [];
var snakeDirection = {
x: 1,
y: 0
};
var nextDirection = {
x: 1,
y: 0
};
var food = null;
var moveCounter = 0;
var isGameRunning = true;
// Calculate board position to center it
var boardOffsetX = (2048 - BOARD_WIDTH * GRID_SIZE) / 2;
var boardOffsetY = (2732 - BOARD_HEIGHT * GRID_SIZE) / 2;
// Create score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Initialize snake with 3 segments
function initializeSnake() {
snake = [];
// Create head
var head = game.addChild(new SnakeSegment());
head.attachAsset('snakeHead', {
anchorX: 0.5,
anchorY: 0.5
});
head.x = boardOffsetX + 5 * GRID_SIZE;
head.y = boardOffsetY + 15 * GRID_SIZE;
snake.push({
x: 5,
y: 15,
obj: head
});
// Create initial body segments
for (var i = 1; i < 3; i++) {
var segment = game.addChild(new SnakeSegment());
segment.x = boardOffsetX + (5 - i) * GRID_SIZE;
segment.y = boardOffsetY + 15 * GRID_SIZE;
snake.push({
x: 5 - i,
y: 15,
obj: segment
});
}
}
// Convert grid coordinates to screen coordinates
function gridToScreen(gridX, gridY) {
return {
x: boardOffsetX + gridX * GRID_SIZE,
y: boardOffsetY + gridY * GRID_SIZE
};
}
// Generate random food position
function spawnFood() {
var validPositions = [];
// Find all valid positions (not occupied by snake)
for (var x = 0; x < BOARD_WIDTH; x++) {
for (var y = 0; y < BOARD_HEIGHT; y++) {
var occupied = false;
for (var i = 0; i < snake.length; i++) {
if (snake[i].x === x && snake[i].y === y) {
occupied = true;
break;
}
}
if (!occupied) {
validPositions.push({
x: x,
y: y
});
}
}
}
if (validPositions.length > 0) {
var randomIndex = Math.floor(Math.random() * validPositions.length);
var pos = validPositions[randomIndex];
if (food) {
food.destroy();
}
food = game.addChild(new Food());
var screenPos = gridToScreen(pos.x, pos.y);
food.x = screenPos.x;
food.y = screenPos.y;
food.gridX = pos.x;
food.gridY = pos.y;
}
}
// Check if position is valid (within bounds and not colliding with snake)
function isValidPosition(x, y) {
// Check bounds
if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) {
return false;
}
// Check collision with snake body (excluding head)
for (var i = 1; i < snake.length; i++) {
if (snake[i].x === x && snake[i].y === y) {
return false;
}
}
return true;
}
// Move snake
function moveSnake() {
if (!isGameRunning) return;
// Update direction
snakeDirection.x = nextDirection.x;
snakeDirection.y = nextDirection.y;
// Calculate new head position
var head = snake[0];
var newHeadX = head.x + snakeDirection.x;
var newHeadY = head.y + snakeDirection.y;
// Check if new position is valid
if (!isValidPosition(newHeadX, newHeadY)) {
// Game over
isGameRunning = false;
LK.getSound('gameOver').play();
LK.showGameOver();
return;
}
// Check if food is eaten
var ateFood = false;
if (food && newHeadX === food.gridX && newHeadY === food.gridY) {
ateFood = true;
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('eat').play();
// Flash food before removing
tween(food, {
alpha: 0
}, {
duration: 200
});
spawnFood();
}
// Move snake segments
if (!ateFood) {
// Remove tail if not growing
var tail = snake.pop();
tail.obj.destroy();
}
// Add new head
var newHead = game.addChild(new SnakeSegment());
newHead.attachAsset('snakeHead', {
anchorX: 0.5,
anchorY: 0.5
});
var screenPos = gridToScreen(newHeadX, newHeadY);
newHead.x = screenPos.x;
newHead.y = screenPos.y;
// Convert old head to body
if (snake.length > 0) {
var oldHead = snake[0].obj;
oldHead.removeChildren();
oldHead.attachAsset('snakeBody', {
anchorX: 0.5,
anchorY: 0.5
});
}
snake.unshift({
x: newHeadX,
y: newHeadY,
obj: newHead
});
}
// Handle direction changes
function changeDirection(newDir) {
// Prevent immediate reversal
if (newDir.x === -snakeDirection.x && newDir.y === -snakeDirection.y) {
return;
}
nextDirection.x = newDir.x;
nextDirection.y = newDir.y;
}
// Touch controls
game.down = function (x, y, obj) {
if (!isGameRunning) return;
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var dx = x - centerX;
var dy = y - centerY;
// Determine direction based on which is greater: horizontal or vertical distance
if (Math.abs(dx) > Math.abs(dy)) {
// Horizontal movement
if (dx > 0) {
changeDirection({
x: 1,
y: 0
}); // Right
} else {
changeDirection({
x: -1,
y: 0
}); // Left
}
} else {
// Vertical movement
if (dy > 0) {
changeDirection({
x: 0,
y: 1
}); // Down
} else {
changeDirection({
x: 0,
y: -1
}); // Up
}
}
};
// Create visible walls around the game board
function createWalls() {
// Top and bottom walls
for (var x = -1; x <= BOARD_WIDTH; x++) {
// Top wall
var topWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
topWall.x = boardOffsetX + x * GRID_SIZE;
topWall.y = boardOffsetY - GRID_SIZE;
// Bottom wall
var bottomWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
bottomWall.x = boardOffsetX + x * GRID_SIZE;
bottomWall.y = boardOffsetY + BOARD_HEIGHT * GRID_SIZE;
}
// Left and right walls
for (var y = 0; y < BOARD_HEIGHT; y++) {
// Left wall
var leftWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
leftWall.x = boardOffsetX - GRID_SIZE;
leftWall.y = boardOffsetY + y * GRID_SIZE;
// Right wall
var rightWall = game.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
}));
rightWall.x = boardOffsetX + BOARD_WIDTH * GRID_SIZE;
rightWall.y = boardOffsetY + y * GRID_SIZE;
}
}
// Initialize game
createWalls();
initializeSnake();
spawnFood();
// Main game loop
game.update = function () {
if (!isGameRunning) return;
moveCounter++;
if (moveCounter >= MOVE_DELAY) {
moveCounter = 0;
moveSnake();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -258,9 +258,47 @@
}); // Up
}
}
};
+// Create visible walls around the game board
+function createWalls() {
+ // Top and bottom walls
+ for (var x = -1; x <= BOARD_WIDTH; x++) {
+ // Top wall
+ var topWall = game.addChild(LK.getAsset('wall', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ topWall.x = boardOffsetX + x * GRID_SIZE;
+ topWall.y = boardOffsetY - GRID_SIZE;
+ // Bottom wall
+ var bottomWall = game.addChild(LK.getAsset('wall', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ bottomWall.x = boardOffsetX + x * GRID_SIZE;
+ bottomWall.y = boardOffsetY + BOARD_HEIGHT * GRID_SIZE;
+ }
+ // Left and right walls
+ for (var y = 0; y < BOARD_HEIGHT; y++) {
+ // Left wall
+ var leftWall = game.addChild(LK.getAsset('wall', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ leftWall.x = boardOffsetX - GRID_SIZE;
+ leftWall.y = boardOffsetY + y * GRID_SIZE;
+ // Right wall
+ var rightWall = game.addChild(LK.getAsset('wall', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ rightWall.x = boardOffsetX + BOARD_WIDTH * GRID_SIZE;
+ rightWall.y = boardOffsetY + y * GRID_SIZE;
+ }
+}
// Initialize game
+createWalls();
initializeSnake();
spawnFood();
// Main game loop
game.update = function () {
robotik yap
wall block. In-Game asset. 2d. High contrast. No shadows
energy ball. In-Game asset. 2d. High contrast. No shadows
frendly robotic snake. In-Game asset. 2d. High contrast. No shadows
rainbow energy. In-Game asset. 2d. High contrast. No shadows
enemy robotic snake. In-Game asset. 2d. High contrast. No shadows
Robotic GigaChad snake. In-Game asset. 2d. High contrast. No shadows
yellow and orange cube 2d. In-Game asset. 2d. High contrast. No shadows
button red 2d. In-Game asset. 2d. High contrast. No shadows