User prompt
When setting score text also update LK.setScore
User prompt
set FingerIndicator alpha to .8
User prompt
set TouchIndicator alpha to .4
Code edit (1 edits merged)
Please save this source code
User prompt
Decrease the snake food intersection distance by 30%
User prompt
Decrease the snake food intersection distance by 30€
Code edit (4 edits merged)
Please save this source code
User prompt
use circle to circle distance calculation for food collection
User prompt
On the score text, add a black dropshadow
User prompt
In game, set the background color to white. Keep the background element
User prompt
set the background color of the game to white without removing the background element
User prompt
set the background color of the game to white
User prompt
set background element alpha to .5
User prompt
set background element alpha to .5 and change background color to white
User prompt
Change background creation, so it's created before snakeContainer is initialized
User prompt
make sure background is created before snake container
User prompt
Add background element to the game, place it at the center of the screen
User prompt
Set snake body part tint to 6fa8a8
Code edit (1 edits merged)
Please save this source code
User prompt
set tailSegmentDelay to 20
Code edit (1 edits merged)
Please save this source code
var SnakeBodySegment = Container.expand(function () { var self = Container.call(this); var bodySegmentGraphics = self.createAsset('snakeBodySegment', 'Snake Body Segment Graphics', .5, .5); bodySegmentGraphics.rotation = Math.PI / 2; bodySegmentGraphics.tint = 0x6fa8a8; }); var FingerIndicator = Container.expand(function () { var self = Container.call(this); var fingerIndicatorGraphics = self.createAsset('fingerIndicator', 'Finger Indicator Graphics', 0.5, 0.5); fingerIndicatorGraphics.alpha = .5; }); var TouchIndicator = Container.expand(function () { var self = Container.call(this); var touchIndicatorGraphics = self.createAsset('touchIndicator', 'Touch Indicator Graphics', 0.5, 0.5); touchIndicatorGraphics.alpha = .3; }); var Snake = Container.expand(function () { var self = Container.call(this); var snakeGraphics = self.createAsset('snake', 'Snake Graphics', .5, .5); snakeGraphics.rotation = -Math.PI / 2; self.direction = { x: 0, y: 0 }; self.speed = 7.5; self.angle = 0; self.headPositions = []; self.bodySegments = []; self.addBodySegment = function () { var segment = new SnakeBodySegment(); var lastSegmentPosition = this.bodySegments.length > 0 ? this.bodySegments[this.bodySegments.length - 1] : this; segment.x = lastSegmentPosition.x; segment.y = lastSegmentPosition.y; segment.rotation = lastSegmentPosition.rotation; this.bodySegments.push(segment); return segment; }; self.move = function () { var targetRotation = Math.atan2(self.direction.y, self.direction.x); var rotationDifference = targetRotation - self.rotation; while (rotationDifference < -Math.PI) rotationDifference += 2 * Math.PI; while (rotationDifference > Math.PI) rotationDifference -= 2 * Math.PI; var turnRate = Math.PI / 96 * 1.625; self.rotation += Math.sign(rotationDifference) * Math.min(Math.abs(rotationDifference), turnRate); self.x = self.x + Math.cos(self.rotation) * self.speed; self.y = self.y + Math.sin(self.rotation) * self.speed; if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) { LK.showGameOver(); } var thresholdDistance = 50; for (var i = 1; i < self.bodySegments.length; i++) { var dx = self.x - self.bodySegments[i].x; var dy = self.y - self.bodySegments[i].y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < thresholdDistance) { LK.showGameOver(); } } self.headPositions.push({ x: self.x, y: self.y, rotation: self.rotation }); var tailSegmentDelay = 20; while (self.headPositions.length > self.bodySegments.length * tailSegmentDelay + 1) { self.headPositions.shift(); } for (var i = 0; i < self.bodySegments.length; i++) { var segmentIndex = (i + 1) * tailSegmentDelay; if (self.headPositions.length > segmentIndex) { var pos = self.headPositions[self.headPositions.length - 1 - segmentIndex]; self.bodySegments[i].x = pos.x; self.bodySegments[i].y = pos.y; self.bodySegments[i].rotation = pos.rotation; } } }; }); var Food = Container.expand(function () { var self = Container.call(this); var foodGraphics = self.createAsset('food', 'Food Graphics', .5, .5); self.spawn = function () { this.x = Math.random() * (2048 - 60) + 30; this.y = Math.random() * (2732 - 60) + 30; }; }); var Game = Container.expand(function () { stage.on('up', function (obj) { if (touchIndicator) { touchIndicator.destroy(); touchIndicator = null; } isMouseDown = false; if (fingerIndicator) { fingerIndicator.destroy(); fingerIndicator = null; } snake.direction.x = Math.cos(snake.rotation) * snake.speed; snake.direction.y = Math.sin(snake.rotation) * snake.speed; }); var self = Container.call(this); var score = 0; var background = self.createAsset('background', 'Background Graphics', .5, .5); background.x = 2048 / 2; background.y = 2732 / 2; background.alpha = .5; LK.stageContainer.setBackgroundColor(0xFFFFFF); var snakeContainer = self.addChild(new Container()); var snake = snakeContainer.addChild(new Snake()); var scoreTxt = new Text2('0', { size: 150, fill: '#ffffff', font: 'Impact', dropShadow: true, dropShadowColor: '#000000', dropShadowBlur: 4, dropShadowAngle: Math.PI / 6, dropShadowDistance: 6 }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var foods = []; snake.x = 2048 / 2; snake.y = 2732 / 2; var food = new Food(); food.spawn(); foods.push(food); self.addChild(food); var dragNode = null; var initialTouchPosition = { x: 0, y: 0 }; var touchIndicator = null; var fingerIndicator = null; var isMouseDown = false; var maxDistance = 200; stage.on('down', function (obj) { var event = obj.event; initialTouchPosition = event.getLocalPosition(self); if (touchIndicator) { touchIndicator.destroy(); } if (fingerIndicator) { fingerIndicator.destroy(); } touchIndicator = self.addChild(new TouchIndicator()); touchIndicator.x = initialTouchPosition.x; touchIndicator.y = initialTouchPosition.y; fingerIndicator = self.addChild(new FingerIndicator()); fingerIndicator.x = initialTouchPosition.x; fingerIndicator.y = initialTouchPosition.y; isMouseDown = true; }); function handleMove(obj) { var event = obj.event; var currentTouchPosition = event.getLocalPosition(self); var dx = currentTouchPosition.x - initialTouchPosition.x; var dy = currentTouchPosition.y - initialTouchPosition.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > maxDistance) { var angle = Math.atan2(dy, dx); dx = maxDistance * Math.cos(angle); dy = maxDistance * Math.sin(angle); } if (fingerIndicator) { fingerIndicator.x = initialTouchPosition.x + dx; fingerIndicator.y = initialTouchPosition.y + dy; } if (isMouseDown) { snake.direction.x = dx; snake.direction.y = dy; } } stage.on('move', handleMove); LK.on('tick', function () { snake.move(); for (var i = 0; i < foods.length; i++) { var snakeHeadRadius = snake.width / 2; var foodRadius = foods[i].width / 2; var dx = snake.x - foods[i].x; var dy = snake.y - foods[i].y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < snakeHeadRadius + foodRadius - 30) { foods[i].destroy(); foods.splice(i, 1); score++; scoreTxt.setText(score); var newSegment = snake.addBodySegment(); snakeContainer.addChildAt(newSegment, 0); var newFood = new Food(); newFood.spawn(); foods.push(newFood); self.addChild(newFood); } } }); });
===================================================================
--- original.js
+++ change.js
@@ -102,9 +102,9 @@
var score = 0;
var background = self.createAsset('background', 'Background Graphics', .5, .5);
background.x = 2048 / 2;
background.y = 2732 / 2;
- background.alpha = .2;
+ background.alpha = .5;
LK.stageContainer.setBackgroundColor(0xFFFFFF);
var snakeContainer = self.addChild(new Container());
var snake = snakeContainer.addChild(new Snake());
var scoreTxt = new Text2('0', {
@@ -180,9 +180,9 @@
var foodRadius = foods[i].width / 2;
var dx = snake.x - foods[i].x;
var dy = snake.y - foods[i].y;
var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < snakeHeadRadius + foodRadius) {
+ if (distance < snakeHeadRadius + foodRadius - 30) {
foods[i].destroy();
foods.splice(i, 1);
score++;
scoreTxt.setText(score);
Single, Anaconda snake head segment. Seen from above. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single snake head segment. Seen from above. Cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Golden Apple Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bright Amazing games background for modern snake game. It should be epic!
White circular touch indicator. White button like look. Game asset. No background. 2d. No shadow.