продолжай!
- User
продолжай!
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
продолжай!
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Продолжаю код игры Space Invaders:
// Рисуем щит (кольцо вокруг)
ctx.strokeStyle = bossAlien.moveCounter < 50 ? '#ff5555' :
bossAlien.moveCounter < 75 ? '#ffaa00' : '#ffff00';
ctx.lineWidth = 3;
ctx.beginPath();
ctx.arc(bossAlien.x + bossAlien.width/2, bossAlien.y + bossAlien.height/2,
bossAlien.width/2 + 5, 0, Math.PI * 2);
ctx.stroke();
// Глаза
ctx.fillStyle = '#000';
ctx.beginPath();
ctx.arc(bossAlien.x + 20, bossAlien.y + 20, 6, 0, Math.PI * 2);
ctx.arc(bossAlien.x + bossAlien.width - 20, bossAlien.y + 20, 6, 0, Math.PI * 2);
ctx.fill();
// "Щупальца"
ctx.fillStyle = '#ff0000';
for (let i = 0; i < 4; i++) {
ctx.beginPath();
ctx.moveTo(bossAlien.x + 10 + i * 20, bossAlien.y + bossAlien.height);
ctx.lineTo(bossAlien.x + 15 + i * 20, bossAlien.y + bossAlien.height + 10);
ctx.lineTo(bossAlien.x + 20 + i * 20, bossAlien.y + bossAlien.height);
ctx.closePath();
ctx.fill();
}
}
// Рисуем счет
ctx.fillStyle = '#fff';
ctx.font = '20px Arial, sans-serif';
ctx.textAlign = 'left';
ctx.fillText(`Счет: ${score}`, 20, 30);
// Рисуем уровень
ctx.textAlign = 'center';
ctx.fillText(`Уровень: ${level}`, canvas.width / 2, 30);
// Рисуем жизни
ctx.textAlign = 'right';
ctx.fillText(`Жизни: ${lives}`, canvas.width - 20, 30);
// Если игра приостановлена
if (!gameActive && lives > 0) {
ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#fff';
ctx.font = '30px Arial, sans-serif';
ctx.textAlign = 'center';
ctx.fillText('ПАУЗА', canvas.width / 2, canvas.height / 2);
ctx.font = '20px Arial, sans-serif';
ctx.fillText('Нажмите P для продолжения', canvas.width / 2, canvas.height / 2 + 40);
}
}
// Рисуем звезды на фоне
function drawStars() {
// Создаем звезды только при первом запуске
if (!window.stars) {
window.stars = [];
// Количество звезд
const starCount = 100;
for (let i = 0; i < starCount; i++) {
window.stars.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
size: Math.random() * 2 + 1,
brightness: Math.random()
});
}
}
// Рисуем звезды
window.stars.forEach(star => {
// Меняем яркость для мерцания
star.brightness += Math.random() * 0.1 - 0.05;
if (star.brightness < 0.3) star.brightness = 0.3;
if (star.brightness > 1) star.brightness = 1;
// Рисуем звезду
const opacity = 0.3 + star.brightness * 0.7;
ctx.fillStyle = `rgba(255, 255, 255, ${opacity})`;
ctx.beginPath();
ctx.arc(star.x, star.y, star.size, 0, Math.PI * 2);
ctx.fill();
});
// Добавляем эффект паралакса при движении игрока
if (keys['ArrowLeft'] && gameActive) {
window.stars.forEach(star => {
star.x += 0.2 * star.size;
if (star.x > canvas.width) star.x = 0;
});
}
if (keys['ArrowRight'] && gameActive) {
window.stars.forEach(star => {
star.x -= 0.2 * star.size;
if (star.x < 0) star.x = canvas.width;
});
}
}
// Запускаем игру
init();
</script>
</body>
</html>
Вот и всё! Теперь у вас есть полноценная HTML-игра Space Invaders с современным дизайном, анимациями и прогрессивной сложностью. Игра включает:
Вы можете сохранить этот код в HTML-файл и запустить его в любом современном браузере.
Хотите, чтобы я объяснил какую-то часть кода или добавил дополнительные функции?