User prompt
добавить новый объект idea в центр экрана
User prompt
исправить ошибку, когда idea не появлятся после пересечения противником правой стороны экрана
User prompt
переместить idea на самый верхний слой
User prompt
если противник пересек правую часть экрана, при этом пуля в него не попала, то показывать картинку idea 2 секунды
User prompt
исправить ошибку, когда LIST Не видно за BACKGROUND
User prompt
переместить list на слой выше относительно background
User prompt
добавить картинку LIST x=1800 Y = 2500
User prompt
исправить ошибку, когда после попадания пули по противнику счетчик не прибавляет +1
User prompt
сделать цифру счетчика пожирнее
Code edit (8 edits merged)
Please save this source code
User prompt
выводить счетчик очков в правый верхний угол
User prompt
добавить счетчик очков. После каждого попадания в противника прибавлять 1 очко
Code edit (1 edits merged)
Please save this source code
User prompt
первые 10 врагов Frames until next enemy spawns = 230 с 11 по 24 врагов Frames until next enemy spawns = 190 с 25 по 40 врагов Frames until next enemy spawns = 150 С 41 по 55 врагов Frames until next enemy spawns = 120 С 56 врага и далее Frames until next enemy spawns = 100
User prompt
исправить ошибку, когда spawnEnemyInterval не работает согласно логике
User prompt
исправить ошибку, когда в через 10 секунд враги не стали появляться чаще
Code edit (4 edits merged)
Please save this source code
User prompt
с 0 секунды по 10 секунду Frames until next enemy spawns = 230 с 10й секунды по 20 секунду Frames until next enemy spawns = 190 С 20й секунды по 30 секунду Frames until next enemy spawns = 150 С 30й секунды по 40 секунду Frames until next enemy spawns = 120 С 50й секунды и далее Frames until next enemy spawns = 100
Code edit (3 edits merged)
Please save this source code
User prompt
первые 10 секунд противники появляются с размером 200, следующие 10 секунд противник появляются с размером 170
Code edit (6 edits merged)
Please save this source code
User prompt
если 5 раз нажать на картинку napr в течение 2х секунд, то в центре экрана появляется картинка на 3 секунды
Code edit (2 edits merged)
Please save this source code
User prompt
если после того, как пуля попала в противника, а хвост невидимый, то счетчик 5 секунд обновляется
Code edit (1 edits merged)
Please save this source code
/****
* 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: 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
****/
// 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() * (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].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.setTimeout(function () {
xvost.visible = false; // Hide XVOST 1 second after collision
}, 1000);
LK.setTimeout(function () {
xvost.visible = true; // Reappear XVOST after 2 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.