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 DirectionalButton = Container.expand(function (direction, assetId) {
var self = Container.call(this);
var graphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = direction;
// Add visual feedback when pressed
self.down = function (x, y, obj) {
if (!isGameRunning) return;
// Visual feedback - make button slightly smaller
tween(self, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
// Change snake direction immediately
changeDirection(self.direction);
};
self.up = function (x, y, obj) {
// Return button to normal size
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
};
return self;
});
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 FriendlySnake = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('friendlySnake', {
anchorX: 0.5,
anchorY: 0.5
});
self.moveSpeed = 2;
self.direction = Math.random() * Math.PI * 2;
self.dropTimer = 0;
self.maxDrops = 3;
self.dropsLeft = 3;
self.update = function () {
// Move in current direction
self.x += Math.cos(self.direction) * self.moveSpeed;
self.y += Math.sin(self.direction) * self.moveSpeed;
// Bounce off walls
if (self.x < boardOffsetX || self.x > boardOffsetX + BOARD_WIDTH * GRID_SIZE) {
self.direction = Math.PI - self.direction;
}
if (self.y < boardOffsetY || self.y > boardOffsetY + BOARD_HEIGHT * GRID_SIZE) {
self.direction = -self.direction;
}
// Keep within bounds
self.x = Math.max(boardOffsetX, Math.min(boardOffsetX + BOARD_WIDTH * GRID_SIZE, self.x));
self.y = Math.max(boardOffsetY, Math.min(boardOffsetY + BOARD_HEIGHT * GRID_SIZE, self.y));
// Drop food periodically
self.dropTimer++;
if (self.dropTimer >= 120 && self.dropsLeft > 0) {
// Every 2 seconds
self.dropFood();
self.dropTimer = 0;
self.dropsLeft--;
}
// Remove after all drops are done
if (self.dropsLeft <= 0) {
tween(self, {
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
self.destroy();
var index = friendlySnakes.indexOf(self);
if (index > -1) {
friendlySnakes.splice(index, 1);
}
}
});
}
};
self.dropFood = function () {
var dropType = Math.random() < 0.3 ? 'level2' : 'normal';
var newFood;
if (dropType === 'level2') {
newFood = game.addChild(new Level2Food());
} else {
newFood = game.addChild(new Food());
}
newFood.x = self.x;
newFood.y = self.y;
// Convert screen position to grid position
var gridX = Math.round((self.x - boardOffsetX) / GRID_SIZE);
var gridY = Math.round((self.y - boardOffsetY) / GRID_SIZE);
newFood.gridX = gridX;
newFood.gridY = gridY;
// Add to food array
foodItems.push(newFood);
};
return self;
});
var Level2Food = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('level2Food', {
anchorX: 0.5,
anchorY: 0.5
});
self.foodType = 'level2';
self.update = function () {
// Special pulsing animation for level 2 food
var scale = 1 + Math.sin(LK.ticks * 0.15) * 0.3;
self.scaleX = scale;
self.scaleY = scale;
// Color cycling effect
var colorPhase = LK.ticks * 0.1 % (Math.PI * 2);
var red = Math.floor(128 + 127 * Math.sin(colorPhase));
var green = Math.floor(128 + 127 * Math.sin(colorPhase + Math.PI * 2 / 3));
var blue = Math.floor(128 + 127 * Math.sin(colorPhase + Math.PI * 4 / 3));
graphics.tint = red << 16 | green << 8 | blue;
};
return self;
});
var Snake = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('snakeHead', {
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;
var friendlySnakes = [];
var friendlySnakeTimer = 0;
var foodItems = [];
// 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 only head
function initializeSnake() {
snake = [];
// Create head using new Snake class
var head = game.addChild(new Snake());
head.x = boardOffsetX + 5 * GRID_SIZE;
head.y = boardOffsetY + 15 * GRID_SIZE;
snake.push({
x: 5,
y: 15,
obj: head
});
}
// 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;
foodItems.push(food);
}
}
// 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;
}
// No body collision check needed for head-only snake
return true;
}
// Move snake
function moveSnake() {
if (!isGameRunning) return;
// Direction is already updated immediately in changeDirection function
// 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 any food is eaten
var ateFood = false;
for (var i = foodItems.length - 1; i >= 0; i--) {
var currentFood = foodItems[i];
if (currentFood && newHeadX === currentFood.gridX && newHeadY === currentFood.gridY) {
ateFood = true;
var points = currentFood.foodType === 'level2' ? 25 : 10;
LK.setScore(LK.getScore() + points);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('eat').play();
// Flash food before removing
tween(currentFood, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
currentFood.destroy();
}
});
foodItems.splice(i, 1);
if (currentFood === food) {
food = null;
spawnFood();
}
break;
}
}
// Simply move the existing head to new position (no growth)
var headObj = snake[0].obj;
var screenPos = gridToScreen(newHeadX, newHeadY);
headObj.x = screenPos.x;
headObj.y = screenPos.y;
snake[0].x = newHeadX;
snake[0].y = newHeadY;
}
// Handle direction changes
function changeDirection(newDir) {
// Prevent immediate reversal
if (newDir.x === -snakeDirection.x && newDir.y === -snakeDirection.y) {
return;
}
// Apply direction change immediately for responsive controls
snakeDirection.x = newDir.x;
snakeDirection.y = newDir.y;
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;
}
}
// Create directional control buttons
var upButton = game.addChild(new DirectionalButton({
x: 0,
y: 1
}, 'upButton'));
var downButton = game.addChild(new DirectionalButton({
x: 0,
y: -1
}, 'downButton'));
var leftButton = game.addChild(new DirectionalButton({
x: -1,
y: 0
}, 'leftButton'));
var rightButton = game.addChild(new DirectionalButton({
x: 1,
y: 0
}, 'rightButton'));
// Position buttons in bottom right corner
var buttonSpacing = 140;
var buttonBaseX = 2048 - 200;
var buttonBaseY = 2732 - 300;
// Up button
upButton.x = buttonBaseX;
upButton.y = buttonBaseY - buttonSpacing;
// Down button
downButton.x = buttonBaseX;
downButton.y = buttonBaseY + buttonSpacing;
// Left button
leftButton.x = buttonBaseX - buttonSpacing;
leftButton.y = buttonBaseY;
// Right button
rightButton.x = buttonBaseX + buttonSpacing;
rightButton.y = buttonBaseY;
// Add text labels to buttons
var upText = new Text2('↑', {
size: 60,
fill: 0xFFFFFF
});
upText.anchor.set(0.5, 0.5);
upText.x = upButton.x;
upText.y = upButton.y;
game.addChild(upText);
var downText = new Text2('↓', {
size: 60,
fill: 0xFFFFFF
});
downText.anchor.set(0.5, 0.5);
downText.x = downButton.x;
downText.y = downButton.y;
game.addChild(downText);
var leftText = new Text2('←', {
size: 60,
fill: 0xFFFFFF
});
leftText.anchor.set(0.5, 0.5);
leftText.x = leftButton.x;
leftText.y = leftButton.y;
game.addChild(leftText);
var rightText = new Text2('→', {
size: 60,
fill: 0xFFFFFF
});
rightText.anchor.set(0.5, 0.5);
rightText.x = rightButton.x;
rightText.y = rightButton.y;
game.addChild(rightText);
// Initialize game
createWalls();
initializeSnake();
spawnFood();
// Main game loop
game.update = function () {
if (!isGameRunning) return;
moveCounter++;
if (moveCounter >= MOVE_DELAY) {
moveCounter = 0;
moveSnake();
}
// Spawn friendly snakes every 10 seconds (600 frames at 60fps)
friendlySnakeTimer++;
if (friendlySnakeTimer >= 600) {
friendlySnakeTimer = 0;
var friendlySnake = game.addChild(new FriendlySnake());
// Spawn at random edge position
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
friendlySnake.x = boardOffsetX + Math.random() * BOARD_WIDTH * GRID_SIZE;
friendlySnake.y = boardOffsetY;
break;
case 1:
// Right
friendlySnake.x = boardOffsetX + BOARD_WIDTH * GRID_SIZE;
friendlySnake.y = boardOffsetY + Math.random() * BOARD_HEIGHT * GRID_SIZE;
break;
case 2:
// Bottom
friendlySnake.x = boardOffsetX + Math.random() * BOARD_WIDTH * GRID_SIZE;
friendlySnake.y = boardOffsetY + BOARD_HEIGHT * GRID_SIZE;
break;
case 3:
// Left
friendlySnake.x = boardOffsetX;
friendlySnake.y = boardOffsetY + Math.random() * BOARD_HEIGHT * GRID_SIZE;
break;
}
friendlySnakes.push(friendlySnake);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -344,14 +344,14 @@
// Vertical movement
if (dy > 0) {
changeDirection({
x: 0,
- y: -1
+ y: 1
}); // Down
} else {
changeDirection({
x: 0,
- y: 1
+ y: -1
}); // Up
}
}
};
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