Update index.html
Browse files- index.html +32 -23
index.html
CHANGED
|
@@ -1319,7 +1319,7 @@
|
|
| 1319 |
});
|
| 1320 |
gameState.bullets = gameState.bullets.filter(bullet => bullet.x < canvas.width);
|
| 1321 |
|
| 1322 |
-
//
|
| 1323 |
gameState.enemyBullets.forEach(bullet => {
|
| 1324 |
const bulletRect = {
|
| 1325 |
x: bullet.x - bullet.size / 2,
|
|
@@ -1742,19 +1742,33 @@
|
|
| 1742 |
);
|
| 1743 |
}
|
| 1744 |
|
| 1745 |
-
//
|
| 1746 |
if (obstacle.canShoot) {
|
| 1747 |
-
//
|
| 1748 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1749 |
ctx.beginPath();
|
| 1750 |
ctx.moveTo(-obstacle.width/2, 0);
|
| 1751 |
ctx.lineTo(obstacle.width/2, -obstacle.height/3);
|
| 1752 |
ctx.lineTo(obstacle.width/2, obstacle.height/3);
|
| 1753 |
ctx.closePath();
|
| 1754 |
ctx.fill();
|
|
|
|
| 1755 |
|
| 1756 |
-
//
|
| 1757 |
-
|
|
|
|
|
|
|
|
|
|
| 1758 |
ctx.beginPath();
|
| 1759 |
ctx.moveTo(-obstacle.width/4, 0);
|
| 1760 |
ctx.lineTo(obstacle.width/4, -obstacle.height/2);
|
|
@@ -1771,13 +1785,23 @@
|
|
| 1771 |
ctx.closePath();
|
| 1772 |
ctx.fill();
|
| 1773 |
|
| 1774 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1775 |
ctx.beginPath();
|
| 1776 |
ctx.moveTo(-obstacle.width/2, 0);
|
| 1777 |
ctx.lineTo(-obstacle.width/3, -obstacle.height/4);
|
| 1778 |
ctx.lineTo(-obstacle.width/4, -obstacle.height/4);
|
| 1779 |
ctx.lineTo(-obstacle.width/3, 0);
|
| 1780 |
ctx.closePath();
|
|
|
|
| 1781 |
ctx.fill();
|
| 1782 |
|
| 1783 |
ctx.beginPath();
|
|
@@ -1788,18 +1812,11 @@
|
|
| 1788 |
ctx.closePath();
|
| 1789 |
ctx.fill();
|
| 1790 |
|
| 1791 |
-
// 驾驶舱
|
| 1792 |
-
ctx.fillStyle = '#3498db';
|
| 1793 |
-
ctx.beginPath();
|
| 1794 |
-
ctx.arc(obstacle.width/4, 0, obstacle.width/8, 0, Math.PI * 2);
|
| 1795 |
-
ctx.fill();
|
| 1796 |
-
|
| 1797 |
// 如果是Boss,添加特殊标记
|
| 1798 |
if (obstacle.isBoss) {
|
| 1799 |
ctx.fillStyle = 'gold';
|
| 1800 |
-
ctx.font = 'bold
|
| 1801 |
ctx.textAlign = 'center';
|
| 1802 |
-
ctx.textBaseline = 'middle';
|
| 1803 |
ctx.fillText('BOSS', 0, 0);
|
| 1804 |
}
|
| 1805 |
} else {
|
|
@@ -2023,14 +2040,6 @@
|
|
| 2023 |
ctx.restore();
|
| 2024 |
}
|
| 2025 |
}
|
| 2026 |
-
|
| 2027 |
-
// 绘制难度提示
|
| 2028 |
-
if (gameState.difficulty > 1.5) {
|
| 2029 |
-
ctx.fillStyle = 'rgba(255, 0, 0, 0.5)';
|
| 2030 |
-
ctx.font = '20px Arial';
|
| 2031 |
-
ctx.textAlign = 'right';
|
| 2032 |
-
ctx.fillText(`难度: ${gameState.difficulty.toFixed(1)}x`, canvas.width - 20, 30);
|
| 2033 |
-
}
|
| 2034 |
}
|
| 2035 |
|
| 2036 |
// 辅助函数: 获取FontAwesome图标的Unicode
|
|
|
|
| 1319 |
});
|
| 1320 |
gameState.bullets = gameState.bullets.filter(bullet => bullet.x < canvas.width);
|
| 1321 |
|
| 1322 |
+
// 检查敌人子弹与飞机的碰撞
|
| 1323 |
gameState.enemyBullets.forEach(bullet => {
|
| 1324 |
const bulletRect = {
|
| 1325 |
x: bullet.x - bullet.size / 2,
|
|
|
|
| 1742 |
);
|
| 1743 |
}
|
| 1744 |
|
| 1745 |
+
// 判断是否为敌人飞机(带有射击能力的障碍物)
|
| 1746 |
if (obstacle.canShoot) {
|
| 1747 |
+
// 使用渐变和阴影美化敌机主体
|
| 1748 |
+
let bodyGradient = ctx.createLinearGradient(-obstacle.width/2, 0, obstacle.width/2, 0);
|
| 1749 |
+
if (obstacle.isBoss) {
|
| 1750 |
+
bodyGradient.addColorStop(0, '#ff4d4d');
|
| 1751 |
+
bodyGradient.addColorStop(1, '#8B0000');
|
| 1752 |
+
} else {
|
| 1753 |
+
bodyGradient.addColorStop(0, '#666');
|
| 1754 |
+
bodyGradient.addColorStop(1, '#333');
|
| 1755 |
+
}
|
| 1756 |
+
ctx.fillStyle = bodyGradient;
|
| 1757 |
+
ctx.shadowColor = 'rgba(0,0,0,0.4)';
|
| 1758 |
+
ctx.shadowBlur = 4;
|
| 1759 |
ctx.beginPath();
|
| 1760 |
ctx.moveTo(-obstacle.width/2, 0);
|
| 1761 |
ctx.lineTo(obstacle.width/2, -obstacle.height/3);
|
| 1762 |
ctx.lineTo(obstacle.width/2, obstacle.height/3);
|
| 1763 |
ctx.closePath();
|
| 1764 |
ctx.fill();
|
| 1765 |
+
ctx.shadowBlur = 0;
|
| 1766 |
|
| 1767 |
+
// 绘制机翼
|
| 1768 |
+
let wingGradient = ctx.createLinearGradient(-obstacle.width/4, 0, obstacle.width/4, 0);
|
| 1769 |
+
wingGradient.addColorStop(0, obstacle.isBoss ? '#a83232' : '#444');
|
| 1770 |
+
wingGradient.addColorStop(1, obstacle.isBoss ? '#600000' : '#222');
|
| 1771 |
+
ctx.fillStyle = wingGradient;
|
| 1772 |
ctx.beginPath();
|
| 1773 |
ctx.moveTo(-obstacle.width/4, 0);
|
| 1774 |
ctx.lineTo(obstacle.width/4, -obstacle.height/2);
|
|
|
|
| 1785 |
ctx.closePath();
|
| 1786 |
ctx.fill();
|
| 1787 |
|
| 1788 |
+
// 绘制驾驶舱(使用径向渐变)
|
| 1789 |
+
let cockpitGradient = ctx.createRadialGradient(obstacle.width/4, 0, 0, obstacle.width/4, 0, obstacle.width/8);
|
| 1790 |
+
cockpitGradient.addColorStop(0, '#80dfff');
|
| 1791 |
+
cockpitGradient.addColorStop(1, '#3498db');
|
| 1792 |
+
ctx.fillStyle = cockpitGradient;
|
| 1793 |
+
ctx.beginPath();
|
| 1794 |
+
ctx.arc(obstacle.width/4, 0, obstacle.width/8, 0, Math.PI * 2);
|
| 1795 |
+
ctx.fill();
|
| 1796 |
+
|
| 1797 |
+
// 绘制尾翼
|
| 1798 |
ctx.beginPath();
|
| 1799 |
ctx.moveTo(-obstacle.width/2, 0);
|
| 1800 |
ctx.lineTo(-obstacle.width/3, -obstacle.height/4);
|
| 1801 |
ctx.lineTo(-obstacle.width/4, -obstacle.height/4);
|
| 1802 |
ctx.lineTo(-obstacle.width/3, 0);
|
| 1803 |
ctx.closePath();
|
| 1804 |
+
ctx.fillStyle = obstacle.isBoss ? '#800000' : '#555';
|
| 1805 |
ctx.fill();
|
| 1806 |
|
| 1807 |
ctx.beginPath();
|
|
|
|
| 1812 |
ctx.closePath();
|
| 1813 |
ctx.fill();
|
| 1814 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1815 |
// 如果是Boss,添加特殊标记
|
| 1816 |
if (obstacle.isBoss) {
|
| 1817 |
ctx.fillStyle = 'gold';
|
| 1818 |
+
ctx.font = 'bold 16px Arial';
|
| 1819 |
ctx.textAlign = 'center';
|
|
|
|
| 1820 |
ctx.fillText('BOSS', 0, 0);
|
| 1821 |
}
|
| 1822 |
} else {
|
|
|
|
| 2040 |
ctx.restore();
|
| 2041 |
}
|
| 2042 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2043 |
}
|
| 2044 |
|
| 2045 |
// 辅助函数: 获取FontAwesome图标的Unicode
|