User prompt
Добавлять 5 очков за попадание в противника
User prompt
Добавить немного сложности, в зависимости от набранных очков
Code edit (4 edits merged)
Please save this source code
User prompt
Добавить красный флеш скрин на экран game over
Code edit (5 edits merged)
Please save this source code
User prompt
Добавить флеш скрин в game over
User prompt
Плавно передать idea в центр экрана, путем движения по y координате
User prompt
Добавить условие, после пересечения противником границы, картинка idea перемещается в центр экрана в течении 1 секунды
Code edit (1 edits merged)
Please save this source code
User prompt
Удалить прозрачность у idea и логику удаления прозрачности у idea
User prompt
Сделать цвет чуть светлее
User prompt
Добавить дополнительный background светло серым
Code edit (1 edits merged)
Please save this source code
User prompt
Выводить game over через 3 секунды после пересечения противника границы
User prompt
Добавить game over в условие, если противник пересек границу и не было попадания, выводить game over, не удаляя условия по прозрачности
User prompt
Исправить ошибку, когда после пересечения противником границы, при этом не было попадания, не появлялся через 2 секунды game over
Code edit (1 edits merged)
Please save this source code
User prompt
Добавить доп условие (не удалая условия по удалению прозрачности), если противник пересек границу 2140, то через 2 секунды выводить game over
User prompt
Добавить доп условие, если противник пересек границу 2140, то через 2 секунды выводить game over
User prompt
Добавить условие, если противник пересек границу 2135, то с задержкой 2 секунды выводить game over
User prompt
Если противник пересек границу, то выводить game over через 1.5 секунды
User prompt
Выводить game over через 1.5 секунд, после того как противник пересек правую границу
User prompt
Картинка vzriv удаляется через 0.5 секунд, после удаления прозрачности у vzriv
Code edit (1 edits merged)
Please save this source code
User prompt
Исправить ошибку, когда у vzriv не удаляется прозрачность
/****
* Classes
****/
// Dog class for the dog that appears when a duck crosses the bottom border
var Dog = Container.expand(function () {
var self = Container.call(this);
var dogGraphics = self.attachAsset('dog', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Enemy class for targets
var Enemy = Container.expand(function () {
var self = Container.call(this);
self.id = Math.floor(Math.random() * 10000); // Assign a random id to each enemy
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = LK.getScore() < 6 ? 4 : Math.random() * (6 - 4) + 4;
self.hit = false;
self._move_migrated = function () {
if (self.hit) {
// Pre-calculate angle to optimize runtime calculations
var hitMovementSpeed = 15;
var hitAngleRadians = Math.PI * 70 / 180; // Pre-convert angle to radians
self.x += hitMovementSpeed * Math.cos(hitAngleRadians);
self.y += hitMovementSpeed * Math.sin(hitAngleRadians);
// Optimize scaling and rotation to reduce calculations
var scaleDecrement = 15 / 60;
self.scale.x -= scaleDecrement / enemyGraphics.width;
self.scale.y -= scaleDecrement / enemyGraphics.height;
self.rotation += Math.PI / 180 * 45 / 60; // Simplify rotation calculation
} else {
self.x += self.speed;
if (self.id % 3 == 0) {
self.y += 1.8 * Math.sin(LK.ticks / 60); // Move up and down smoothly by 30
}
}
};
});
// Assets are automatically created based on usage in the code.
// Bullet class for bullets fired by the player
var PlayerBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('playerBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -22;
self._move_migrated = function () {
// Optimized bullet movement and scaling to reduce calculations per frame
var deltaX = self.speed * Math.cos(this.direction);
var deltaY = self.speed * Math.sin(this.direction);
self.x += deltaX;
self.y += deltaY;
// Simplified scaling to reduce per frame calculations
var scaleDecrement = 10 / 60;
self.scale.x -= scaleDecrement / bulletGraphics.width;
self.scale.y -= scaleDecrement / bulletGraphics.height;
};
self.distanceTo = function (other) {
var dx = other.x - this.x;
var dy = other.y - this.y;
return Math.sqrt(dx * dx + dy * dy);
};
});
// XVOST class for the XVOST object that moves in a random direction at the bottom of the screen
var XVOST = Container.expand(function () {
var self = Container.call(this);
var xvostGraphics = self.attachAsset('xvost', {
anchorX: 0.5,
anchorY: 1.0
});
self.speed = 2.5;
self.direction = Math.PI; // Set direction to left
self.update = function () {
self.x += self.speed * Math.cos(self.direction);
self.y = self.y;
// Add code to smoothly tilt XVOST to the left and right every second
if (LK.ticks % 60 < 30) {
if (self.rotation > -10 * (Math.PI / 180)) {
self.rotation -= 10 * (Math.PI / 180) / (0.5 * 60); // 0.5 seconds at 60FPS
}
} else {
if (self.rotation < 10 * (Math.PI / 180)) {
self.rotation += 10 * (Math.PI / 180) / (0.5 * 60); // 0.5 seconds at 60FPS
}
}
// Mirror the XVOST object when it intersects with the game borders
if (self.x < 100) {
self.x = 100;
self.direction = Math.PI - self.direction; // Change direction
xvostGraphics.scale.x *= -1; // Mirror the XVOST object
} else if (self.x > 1900) {
self.x = 1900;
self.direction = Math.PI - self.direction; // Change direction
xvostGraphics.scale.x *= -1; // Mirror the XVOST object
}
if (self.y < 2000) {
self.y = 2000;
self.direction = -self.direction; // Change direction
xvostGraphics.scale.y *= -1; // Mirror the XVOST object
} else if (self.y > 2250) {
self.y = 2250;
self.direction = -self.direction; // Change direction
xvostGraphics.scale.y *= -1; // Mirror the XVOST object
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFFFFF // Init game with white background
});
/****
* Game Code
****/
// Add 'idea' image to the center of the screen
var idea = game.addChild(new Container());
var ideaGraphics = idea.attachAsset('idea', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.50 // Set opacity to 50%
});
idea.x = 1024; // Center horizontally
idea.y = 1366; // Center vertically
// Add 'vzriv' image to the left center of the screen with 50% opacity
var vzriv = game.addChild(new Container());
var vzrivGraphics = vzriv.attachAsset('vzriv', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.5 // Set opacity to 50%
});
vzriv.x = 1024 / 2; // Center horizontally on the left side
vzriv.y = 1230; // Center vertically
var score = LK.getScore(); // Retrieve the current score
var scoreTxt = new Text2('0', {
size: 70,
fill: "#000000",
fontWeight: "bold" // Make the text bolder
});
scoreTxt.anchor.set(1, 0); // Anchor to the top right
LK.gui.topRight.addChild(scoreTxt);
// Create a background
var background = game.addChild(new Container());
var backgroundGraphics = background.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
background.x = 1024; // Center horizontally
background.y = 1366; // Center vertically
var playerBullets = [];
var enemies = [];
// Dynamically adjust enemy spawn interval based on score to optimize game difficulty
var baseSpawnInterval = 240;
var spawnEnemyInterval = baseSpawnInterval - Math.floor(LK.getScore() / 10) * 5;
spawnEnemyInterval = Math.max(spawnEnemyInterval, 100); // Ensure minimum spawn interval
var enemySpawnTimer = 0;
// Function to spawn enemies
function spawnEnemy() {
var enemySize = LK.getScore() < 9 ? 200 : Math.random() * (200 - 130) + 130;
var enemy = new Enemy();
enemy.scale.x = enemySize / 200;
enemy.scale.y = enemySize / 200;
enemy.x = -130; // Start at the left
enemy.y = Math.random() * (1366 - 170) + 170; // Random position from 100 to 1366
enemies.push(enemy);
game.addChild(enemy);
}
// Function to fire a bullet
function fireBullet() {
var bullet = new PlayerBullet();
bullet.x = 1024; // Center horizontally
bullet.y = 2500; // Bottom of the screen
playerBullets.push(bullet);
game.addChild(bullet);
return bullet;
}
// Touch event to fire bullets
var lastBulletTime = 0;
game.on('down', function (x, y, obj) {
if (LK.ticks - lastBulletTime >= 65 || playerBullets.length === 0) {
// 30 ticks = 0.5 second at 60FPS
var bullet = fireBullet();
var touchPos = game.toLocal(obj.global);
var angle = Math.atan2(2632 - touchPos.y, 1024 - touchPos.x);
bullet.direction = angle; // Set direction to shoot towards the touch point
lastBulletTime = LK.ticks;
}
});
// Add weapon image to the bottom center of the screen
var weapon = game.addChild(new Container());
var weaponGraphics = weapon.attachAsset('weapon', {
anchorX: 0.5,
anchorY: 0.5,
rotation: -50 * (Math.PI / 180) // Rotate 30 degrees counter-clockwise
});
weapon.x = 1024; // Center horizontally
weapon.y = 2880; // Bottom of the screen
// Add 'Napr' image to the center of the screen and handle tap logic
var naprTapCount = 0;
var naprLastTapTime = 0;
var napr = game.addChild(new Container());
var naprGraphics = napr.attachAsset('Napr', {
anchorX: 0.5,
anchorY: 0.5
});
napr.x = 1700; // Center horizontally
napr.y = 2150; // Center vertically
napr.rotation = 7 * (Math.PI / 180); // Rotate the image by 10 degrees
napr.down = function (x, y, obj) {
var currentTime = LK.ticks;
if (currentTime - naprLastTapTime <= 120) {
// 2 seconds at 60FPS
naprTapCount++;
if (naprTapCount >= 5) {
// Show central image for 3 seconds
var centralImage = game.addChild(new Container());
var centralImageGraphics = centralImage.attachAsset('picture', {
anchorX: 0.5,
anchorY: 0.5
});
centralImage.x = 1024; // Center horizontally
centralImage.y = 200; // Center vertically
LK.setTimeout(function () {
centralImage.visible = false;
centralImage.destroy();
}, 3000);
naprTapCount = 0; // Reset tap count
}
} else {
naprTapCount = 1; // Reset tap count if more than 2 seconds pass
}
naprLastTapTime = currentTime;
};
// Add 'Tap' image to the center of the screen
var tap = game.addChild(new Container());
var tapGraphics = tap.attachAsset('Tap', {
anchorX: 0.5,
anchorY: 0.5
});
tap.x = 1024; // Center horizontally
tap.y = 1366; // Center vertically
// Function to scale the 'tap' image down by 50 pixels and then scale it back up over 2 seconds
function scaleTap() {
var originalScaleX = tap.scale.x;
var originalScaleY = tap.scale.y;
var targetScaleX = (tapGraphics.width - 40) / tapGraphics.width;
var targetScaleY = (tapGraphics.height - 40) / tapGraphics.height;
var scaleCount = 0;
// Scale down
var scaleDownInterval = LK.setInterval(function () {
if (tap.scale.x > targetScaleX && tap.scale.y > targetScaleY) {
tap.scale.x -= 0.01 / 0.8; // Adjust for 2 seconds
tap.scale.y -= 0.01 / 0.8; // Adjust for 2 seconds
} else {
LK.clearInterval(scaleDownInterval);
// Scale up
var scaleUpInterval = LK.setInterval(function () {
if (tap.scale.x < originalScaleX && tap.scale.y < originalScaleY) {
tap.scale.x += 0.01 / 0.8; // Adjust for 2 seconds
tap.scale.y += 0.01 / 0.8; // Adjust for 2 seconds
} else {
LK.clearInterval(scaleUpInterval);
scaleCount++;
if (scaleCount < 2) {
scaleTap();
} else {
tap.visible = false;
tap.destroy();
}
}
}, 16.67); // 60FPS
}
}, 16.67); // 60FPS
}
// Call the function to start the scaling
scaleTap();
// Remove the 'tap' image after 3 seconds of gameplay
LK.setTimeout(function () {
tap.visible = false;
tap.destroy();
}, 1650);
// Add an XVOST object to the game
var xvost = game.addChild(new XVOST());
xvost.x = Math.random() * (1800 - 200) + 200; // Randomize x position between 200 and 1800
xvost.y = 2732 - xvost.height / 2; // Position at the bottom of the screen
// Main game loop
LK.on('tick', function () {
// Move bullets
for (var i = playerBullets.length - 1; i >= 0; i--) {
playerBullets[i]._move_migrated();
if (playerBullets[i].y < 0) {
// Remove bullets that go off screen
playerBullets[i].destroy();
playerBullets.splice(i, 1);
}
}
// Move enemies
for (var j = enemies.length - 1; j >= 0; j--) {
enemies[j]._move_migrated();
if (enemies[j].x > 2135 && !enemies[j].hit) {
// Correctly remove opacity from 'vzriv' after enemy crosses the border
ideaGraphics.alpha = 1; // Set opacity to 100%
LK.setTimeout(function () {
vzrivGraphics.alpha = 1; // Remove opacity from 'vzriv'
}, 500); // Corrected delay for removing opacity from 'vzriv'
} else if (enemies[j].y > 2300) {
// Remove enemies that go off screen or become too small
if (enemies[j].y > 2300 || enemies[j].scale.x <= 0 || enemies[j].scale.y <= 0) {
// If the enemy crosses the bottom border, add a dog at its position
if (enemies[j].y > 2300) {
var enemyX = enemies[j].x;
var enemyY = enemies[j].y;
LK.setTimeout(function () {
var dog = new Dog();
dog.x = enemyX;
dog.y = enemyY;
game.addChild(dog);
// Remove the dog after 2 seconds
LK.setTimeout(function () {
dog.visible = false;
dog.destroy();
}, 1000);
}, 800);
}
enemies[j].destroy();
enemies.splice(j, 1);
}
}
}
// Check for collisions
for (var b = playerBullets.length - 1; b >= 0; b--) {
var bullet = playerBullets[b];
if (bullet) {
for (var e = enemies.length - 1; e >= 0; e--) {
var enemy = enemies[e];
if (enemy && !enemy.hit && bullet.intersects(enemy) && bullet.distanceTo(enemy) <= 100) {
// Mark enemy as hit, destroy the bullet on collision, and handle XVOST visibility
bullet.destroy();
playerBullets.splice(b, 1);
enemy.hit = true;
LK.setScore(LK.getScore() + 1); // Increment score by 1
scoreTxt.setText(LK.getScore().toString()); // Update score display
LK.setTimeout(function () {
xvost.visible = false; // Hide XVOST 1 second after collision
}, 1200);
if (!xvost.visible) {
LK.clearTimeout(xvostVisibilityTimer); // Clear existing timer if XVOST is currently invisible
}
xvostVisibilityTimer = LK.setTimeout(function () {
xvost.visible = true; // Reappear XVOST after 5 seconds
}, 4000);
break; // Exit loop after collision to avoid errors
}
}
}
}
// Update the position of the XVOST object
xvost.update();
// Spawn enemies
if (enemySpawnTimer <= 0) {
spawnEnemy();
enemySpawnTimer = spawnEnemyInterval;
} else {
enemySpawnTimer--;
}
});
черный шар. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
УТКА МУЛЬЯШНАЯ ЛЕТИТ. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
задний фон. небо голубое внизу картинки кусты. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Указательный палец нажимает. Мультяшный. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Белая мультяшная утка держит ружье и направляет в экран.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
вывеска на двух ниточках с надписью: TImakovDS. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
снайперская винтовка. мультяшная. вид от первого лица. направлено вверх. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.