Code edit (1 edits merged)
Please save this source code
User prompt
добавить рандом в случайном появлении хвоста по X от 200 до 1800
User prompt
убрать рандом в скорости движения XVOST
Code edit (2 edits merged)
Please save this source code
User prompt
движение XVOST всегда начинается справа на лево
Code edit (4 edits merged)
Please save this source code
User prompt
при пересечении XVOST границ, он отображается зеркально
Code edit (2 edits merged)
Please save this source code
User prompt
при столкновении, XVOST начинает отображаться зеркально
Code edit (5 edits merged)
Please save this source code
User prompt
вращение хвоста происходит не от центра картинки, а от нижней ее части
User prompt
вращать хвост в лево и вправо каждую секунду, а не от столкновений
User prompt
XVOST rotation всегда, а не только от столкновения с границами
User prompt
XVOST поворачивается всегда, а не только от столкновения с границами
User prompt
XVOST поворачивается не от ударов об стену, а всегде сам
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
уменьшить время между поворотами XVOST
User prompt
поворот XVOST сделать на равном расстоянии что влево, что в право
Code edit (1 edits merged)
Please save this source code
User prompt
направление движения хвоста всегда горизонтальное
User prompt
скорость xvost всегда равна 3
Code edit (2 edits merged)
Please save this source code
User prompt
наклон xvost происходит плавно в течении 0,5 секунд
User prompt
сделать наклоны XVOST влево и вправо на 10 градусов
/****
* 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 = Math.random() * (6 - 4) + 4;
self.hit = false;
self._move_migrated = function () {
if (self.hit) {
var angle = 70 * (Math.PI / 180); // Convert angle to radians
self.x += 15 * Math.cos(angle); // Move horizontally based on the angle
self.y += 15 * Math.sin(angle); // Move vertically based on the angle
self.scale.x -= 15 / 60 / enemyGraphics.width; // Decrease width by 20 pixels per second
self.scale.y -= 15 / 60 / enemyGraphics.height; // Decrease height by 20 pixels per second
self.rotation += Math.PI / 4 / 60; // Rotate by 45 degrees per second
} 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 = -23;
self._move_migrated = function () {
self.x += self.speed * Math.cos(this.direction);
self.y += self.speed * Math.sin(this.direction);
self.scale.x -= 10 / 60 / bulletGraphics.width; // Decrease width by 3 pixels per second
self.scale.y -= 10 / 60 / bulletGraphics.height; // Decrease height by 3 pixels per second
};
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: 0.5
});
self.speed = Math.random() * (6 - 4) + 4;
self.direction = Math.random() * 2 * Math.PI; // Random direction in radians
self.update = function () {
self.x += self.speed * Math.cos(self.direction);
self.y += self.speed * Math.sin(self.direction);
// Add code to tilt XVOST to the left and right by 10 degrees
if (self.direction > Math.PI) {
self.rotation = -10 * (Math.PI / 180);
} else {
self.rotation = 10 * (Math.PI / 180);
}
// Limit the movement of XVOST object within the specified range
if (self.x < 100) {
self.x = 100;
self.direction = Math.PI - self.direction; // Change direction
} else if (self.x > 1900) {
self.x = 1900;
self.direction = Math.PI - self.direction; // Change direction
}
if (self.y < 2200) {
self.y = 2200;
self.direction = -self.direction; // Change direction
} else if (self.y > 2350) {
self.y = 2350;
self.direction = -self.direction; // Change direction
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFFFFF // Init game with white background
});
/****
* Game Code
****/
// 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 = [];
var spawnEnemyInterval = 150; // Frames until next enemy spawns
var enemySpawnTimer = 0;
// Function to spawn enemies
function spawnEnemy() {
var enemySize = 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 - 150) + 150; // 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 = 2450; // 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 >= 60 || 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
});
weapon.x = 1024; // Center horizontally
weapon.y = 2632; // Bottom of the screen
// Add 'Napr' image to the center of the screen
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
// 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() * 2048; // Random position from 0 to 2048
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].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 and destroy the bullet on collision
bullet.destroy();
playerBullets.splice(b, 1);
enemy.hit = true;
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.