Spaces:
Running
Running
Update index.html
Browse files- index.html +329 -216
index.html
CHANGED
@@ -879,7 +879,7 @@ const defaultPlayerStats = {
|
|
879 |
constructor(y) {
|
880 |
this.y = y;
|
881 |
this.startTime = Date.now();
|
882 |
-
this.duration =
|
883 |
}
|
884 |
|
885 |
draw(ctx) {
|
@@ -1684,137 +1684,147 @@ bullets = bullets.filter(bullet => {
|
|
1684 |
}
|
1685 |
}
|
1686 |
function drawGame() {
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1812 |
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
}
|
1819 |
//bf109 ํํธ ์์คํ
|
1820 |
function updateBF109Damage() {
|
@@ -2007,73 +2017,120 @@ class Enemy {
|
|
2007 |
}
|
2008 |
|
2009 |
shoot() {
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2077 |
}
|
2078 |
// ๋ณด์ค ์คํ
์ด์ง ์์ ํจ์ ์์
|
2079 |
function startBossStage() {
|
@@ -2165,18 +2222,38 @@ function fireBullet() {
|
|
2165 |
const now = Date.now();
|
2166 |
if ((keys[' '] || autoFire) && now - lastShot > weapon.fireRate) {
|
2167 |
weapon.sound.cloneNode().play();
|
2168 |
-
effects.push(new Effect(
|
2169 |
-
player.x + Math.cos(player.angle) * 30,
|
2170 |
-
player.y + Math.sin(player.angle) * 30,
|
2171 |
-
500,
|
2172 |
-
'fire',
|
2173 |
-
player.angle,
|
2174 |
-
player
|
2175 |
-
));
|
2176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2177 |
bullets.push({
|
2178 |
-
x:
|
2179 |
-
y:
|
2180 |
angle: player.angle,
|
2181 |
speed: hasAPCR ? 20 : 10,
|
2182 |
isEnemy: false,
|
@@ -2201,6 +2278,17 @@ class Effect {
|
|
2201 |
this.offset = { x: Math.cos(angle) * 30, y: Math.sin(angle) * 30 };
|
2202 |
this.img = new Image();
|
2203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2204 |
// ์ดํํธ ํ์
์ ๋ฐ๋ฅธ ์ด๋ฏธ์ง ์ค์
|
2205 |
if (type === 'death') {
|
2206 |
this.img.src = 'bang.png';
|
@@ -2208,21 +2296,46 @@ class Effect {
|
|
2208 |
this.img.src = 'bomb1.png';
|
2209 |
} else if (type === 'hit') {
|
2210 |
this.img.src = 'fire3.png';
|
|
|
|
|
|
|
|
|
2211 |
} else {
|
2212 |
this.img.src = 'fire2.png';
|
2213 |
}
|
2214 |
|
2215 |
-
// ์ดํํธ
|
2216 |
-
this.size = type === 'bomb' ? 100 :
|
2217 |
type === 'death' ? 75 :
|
2218 |
-
type === 'hit' ? 30 : 42;
|
2219 |
-
}
|
2220 |
|
2221 |
update() {
|
2222 |
-
if(this.parent
|
2223 |
-
this.
|
2224 |
-
|
2225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2226 |
}
|
2227 |
}
|
2228 |
|
|
|
879 |
constructor(y) {
|
880 |
this.y = y;
|
881 |
this.startTime = Date.now();
|
882 |
+
this.duration = 750; // 0.75์ด
|
883 |
}
|
884 |
|
885 |
draw(ctx) {
|
|
|
1684 |
}
|
1685 |
}
|
1686 |
function drawGame() {
|
1687 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
1688 |
+
|
1689 |
+
// ๋ฐฐ๊ฒฝ ๊ทธ๋ฆฌ๊ธฐ
|
1690 |
+
const pattern = ctx.createPattern(backgroundImg, 'repeat');
|
1691 |
+
ctx.fillStyle = pattern;
|
1692 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
1693 |
+
|
1694 |
+
// ํ๋ ์ด์ด ๊ทธ๋ฆฌ๊ธฐ
|
1695 |
+
ctx.save();
|
1696 |
+
ctx.translate(player.x, player.y);
|
1697 |
+
ctx.rotate(player.angle);
|
1698 |
+
ctx.drawImage(playerImg, -player.width/2, -player.height/2, player.width, player.height);
|
1699 |
+
ctx.restore();
|
1700 |
+
|
1701 |
+
// ์ฒด๋ ฅ๋ฐ ๊ทธ๋ฆฌ๊ธฐ
|
1702 |
+
drawHealthBar(canvas.width/2, 30, player.health, player.maxHealth, 200, 20, 'green');
|
1703 |
+
|
1704 |
+
// ์ ๊ทธ๋ฆฌ๊ธฐ
|
1705 |
+
enemies.forEach(enemy => {
|
1706 |
+
ctx.save();
|
1707 |
+
ctx.translate(enemy.x, enemy.y);
|
1708 |
+
ctx.rotate(enemy.angle);
|
1709 |
+
const img = enemy.enemyImg;
|
1710 |
+
ctx.drawImage(img, -enemy.width/2, -enemy.height/2, enemy.width, enemy.height);
|
1711 |
+
ctx.restore();
|
1712 |
+
drawHealthBar(enemy.x, enemy.y - 40, enemy.health, enemy.maxHealth, 60, 5, 'red');
|
1713 |
+
});
|
1714 |
+
|
1715 |
+
// ์๊ตฐ ์ ๋ ๊ทธ๋ฆฌ๊ธฐ
|
1716 |
+
allyUnits.forEach(ally => {
|
1717 |
+
ctx.save();
|
1718 |
+
ctx.translate(ally.x, ally.y);
|
1719 |
+
ctx.rotate(ally.angle);
|
1720 |
+
ctx.drawImage(ally.img, -ally.width/2, -ally.height/2, ally.width, ally.height);
|
1721 |
+
ctx.restore();
|
1722 |
+
drawHealthBar(ally.x, ally.y - 40, ally.health, ally.maxHealth, 60, 5, 'blue');
|
1723 |
+
});
|
1724 |
+
|
1725 |
+
// ๊ฒฝ๊ณ ์ ๊ทธ๋ฆฌ๊ธฐ
|
1726 |
+
warningLines.forEach(line => line.draw(ctx));
|
1727 |
+
|
1728 |
+
// ์คํํ์ด์ด ๊ฒฝ๊ณ ์ ๊ทธ๋ฆฌ๊ธฐ
|
1729 |
+
p51WarningLines.forEach(line => line.draw(ctx));
|
1730 |
+
|
1731 |
+
// B-29 ๊ฒฝ๊ณ ์ ๊ทธ๋ฆฌ๊ธฐ
|
1732 |
+
b29WarningLines.forEach(line => line.draw(ctx));
|
1733 |
+
|
1734 |
+
// P51 ๊ทธ๋ฆฌ๊ธฐ
|
1735 |
+
p51s.forEach(p51 => {
|
1736 |
+
ctx.save();
|
1737 |
+
ctx.translate(p51.x, p51.y);
|
1738 |
+
ctx.rotate(Math.PI / 2);
|
1739 |
+
ctx.drawImage(p51.img, -p51.width/2, -p51.height/2, p51.width, p51.height);
|
1740 |
+
ctx.restore();
|
1741 |
+
});
|
1742 |
+
|
1743 |
+
// B-29 ๊ทธ๋ฆฌ๊ธฐ
|
1744 |
+
b29s.forEach(b29 => {
|
1745 |
+
ctx.save();
|
1746 |
+
ctx.translate(b29.x, b29.y);
|
1747 |
+
ctx.rotate(Math.PI);
|
1748 |
+
ctx.drawImage(b29.img, -b29.width/2, -b29.height/2, b29.width, b29.height);
|
1749 |
+
ctx.restore();
|
1750 |
+
});
|
1751 |
+
|
1752 |
+
// ์คํํ์ด์ด ๊ทธ๋ฆฌ๊ธฐ
|
1753 |
+
spitfires.forEach(spitfire => {
|
1754 |
+
ctx.save();
|
1755 |
+
ctx.translate(spitfire.x, spitfire.y);
|
1756 |
+
ctx.rotate(Math.PI);
|
1757 |
+
ctx.drawImage(spitfire.img, -spitfire.width/2, -spitfire.height/2, spitfire.width, spitfire.height);
|
1758 |
+
ctx.restore();
|
1759 |
+
});
|
1760 |
+
|
1761 |
+
// ์ง์ ์ ๋ ๊ทธ๋ฆฌ๊ธฐ
|
1762 |
+
supportUnits.forEach(unit => {
|
1763 |
+
ctx.save();
|
1764 |
+
ctx.translate(unit.x, unit.y);
|
1765 |
+
ctx.rotate(unit.angle);
|
1766 |
+
ctx.drawImage(unit.img, -unit.width/2, -unit.height/2, unit.width, unit.height);
|
1767 |
+
ctx.restore();
|
1768 |
+
});
|
1769 |
+
|
1770 |
+
// ์ด์ ๊ทธ๋ฆฌ๊ธฐ
|
1771 |
+
bullets.forEach(bullet => {
|
1772 |
+
if (bullet.isEnemy || !bullet.isAPCR) {
|
1773 |
+
ctx.beginPath();
|
1774 |
+
ctx.fillStyle = bullet.color || (bullet.isEnemy ? 'red' : 'blue');
|
1775 |
+
ctx.arc(bullet.x, bullet.y, bullet.size, 0, Math.PI * 2);
|
1776 |
+
ctx.fill();
|
1777 |
+
} else {
|
1778 |
+
ctx.save();
|
1779 |
+
ctx.translate(bullet.x, bullet.y);
|
1780 |
+
ctx.rotate(bullet.angle);
|
1781 |
+
const width = currentWeapon === 'machinegun' ? 10 : 20;
|
1782 |
+
const height = currentWeapon === 'machinegun' ? 5 : 10;
|
1783 |
+
ctx.drawImage(bulletImg, -width/2, -height/2, width, height);
|
1784 |
+
ctx.restore();
|
1785 |
+
}
|
1786 |
+
});
|
1787 |
+
|
1788 |
+
// ์์ดํ
๊ทธ๋ฆฌ๊ธฐ
|
1789 |
+
items.forEach(item => {
|
1790 |
+
ctx.beginPath();
|
1791 |
+
ctx.fillStyle = 'green';
|
1792 |
+
ctx.arc(item.x, item.y, 10, 0, Math.PI * 2);
|
1793 |
+
ctx.fill();
|
1794 |
+
});
|
1795 |
+
|
1796 |
+
// UI ๊ทธ๋ฆฌ๊ธฐ
|
1797 |
+
ctx.fillStyle = 'white';
|
1798 |
+
ctx.font = '24px Arial';
|
1799 |
+
ctx.fillText(`Stage ${currentStage} - Round ${currentRound}/${currentStage === 3 ? 20 : 10}`, 10, 30);
|
1800 |
+
ctx.fillText(`Gold: ${gold}`, 10, 60);
|
1801 |
+
|
1802 |
+
// ์ดํํธ ๊ทธ๋ฆฌ๊ธฐ
|
1803 |
+
effects = effects.filter(effect => !effect.isExpired());
|
1804 |
+
effects.forEach(effect => {
|
1805 |
+
effect.update();
|
1806 |
+
ctx.save();
|
1807 |
+
ctx.translate(effect.x, effect.y);
|
1808 |
+
if (effect.type === 'fire' || effect.type === 'cannon_fire') {
|
1809 |
+
ctx.rotate(effect.angle);
|
1810 |
+
}
|
1811 |
+
|
1812 |
+
if (effect.type === 'cannon_fire') {
|
1813 |
+
// ์บ๋
ผ ๋ฐ์ฌ ํจ๊ณผ๋ ํ์ฌ ๋จ๊ณ์ ํฌ๊ธฐ์ ๋ง์ถฐ ๊ทธ๋ฆฌ๊ธฐ
|
1814 |
+
const size = effect.currentSize;
|
1815 |
+
ctx.drawImage(effect.img, -size.width/2, -size.height/2, size.width, size.height);
|
1816 |
+
} else {
|
1817 |
+
// ๋ค๋ฅธ ์ดํํธ๋ค์ ๊ธฐ์กด ๋ฐฉ์๋๋ก ๊ทธ๋ฆฌ๊ธฐ
|
1818 |
+
ctx.drawImage(effect.img, -effect.size/2, -effect.size/2, effect.size, effect.size);
|
1819 |
+
}
|
1820 |
+
ctx.restore();
|
1821 |
+
});
|
1822 |
|
1823 |
+
// ์นด์ดํธ๋ค์ด ์ค๋ฒ๋ ์ด
|
1824 |
+
if (isCountingDown) {
|
1825 |
+
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
1826 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
1827 |
+
}
|
1828 |
}
|
1829 |
//bf109 ํํธ ์์คํ
|
1830 |
function updateBF109Damage() {
|
|
|
2017 |
}
|
2018 |
|
2019 |
shoot() {
|
2020 |
+
if (currentStage === 3) {
|
2021 |
+
if (this.isBoss) {
|
2022 |
+
const bossSound = new Audio('fireenemy2.ogg');
|
2023 |
+
bossSound.volume = 0.5;
|
2024 |
+
bossSound.play();
|
2025 |
+
|
2026 |
+
// ๋ณด์ค์ ์ด๊ตฌ ์์น ๊ณ์ฐ (์ข์ฐ ์์ชฝ์์ ๋ฐ์ฌ)
|
2027 |
+
const gunPositions = [
|
2028 |
+
{ x: this.x + Math.cos(this.angle) * 30, y: this.y + Math.sin(this.angle) * 30 },
|
2029 |
+
{ x: this.x + Math.cos(this.angle + Math.PI) * 30, y: this.y + Math.sin(this.angle + Math.PI) * 30 }
|
2030 |
+
];
|
2031 |
+
|
2032 |
+
// ๊ฐ ์ด๊ตฌ์์ ๋ฐ์ฌ ํจ๊ณผ ์์ฑ
|
2033 |
+
gunPositions.forEach(pos => {
|
2034 |
+
effects.push(new Effect(
|
2035 |
+
pos.x,
|
2036 |
+
pos.y,
|
2037 |
+
750, // 0.75์ด ๋์ ์ง์
|
2038 |
+
'cannon_fire',
|
2039 |
+
this.angle,
|
2040 |
+
this
|
2041 |
+
));
|
2042 |
+
|
2043 |
+
bullets.push({
|
2044 |
+
x: pos.x,
|
2045 |
+
y: pos.y,
|
2046 |
+
angle: this.angle,
|
2047 |
+
speed: 15,
|
2048 |
+
isEnemy: true,
|
2049 |
+
damage: 450,
|
2050 |
+
size: 5
|
2051 |
+
});
|
2052 |
+
});
|
2053 |
+
} else if (this.isElite) {
|
2054 |
+
const eliteSound = new Audio('fireenemy3.ogg');
|
2055 |
+
eliteSound.volume = 0.5;
|
2056 |
+
eliteSound.play();
|
2057 |
+
|
2058 |
+
effects.push(new Effect(
|
2059 |
+
this.x + Math.cos(this.angle) * 30,
|
2060 |
+
this.y + Math.sin(this.angle) * 30,
|
2061 |
+
750, // 0.75์ด ๋์ ์ง์
|
2062 |
+
'cannon_fire',
|
2063 |
+
this.angle,
|
2064 |
+
this
|
2065 |
+
));
|
2066 |
+
|
2067 |
+
bullets.push({
|
2068 |
+
x: this.x + Math.cos(this.angle) * 30,
|
2069 |
+
y: this.y + Math.sin(this.angle) * 30,
|
2070 |
+
angle: this.angle,
|
2071 |
+
speed: 8,
|
2072 |
+
isEnemy: true,
|
2073 |
+
damage: 200,
|
2074 |
+
size: 4
|
2075 |
+
});
|
2076 |
+
} else {
|
2077 |
+
enemyFireSound.cloneNode().play();
|
2078 |
+
|
2079 |
+
effects.push(new Effect(
|
2080 |
+
this.x + Math.cos(this.angle) * 30,
|
2081 |
+
this.y + Math.sin(this.angle) * 30,
|
2082 |
+
500,
|
2083 |
+
'fire',
|
2084 |
+
this.angle,
|
2085 |
+
this
|
2086 |
+
));
|
2087 |
+
|
2088 |
+
bullets.push({
|
2089 |
+
x: this.x + Math.cos(this.angle) * 30,
|
2090 |
+
y: this.y + Math.sin(this.angle) * 30,
|
2091 |
+
angle: this.angle,
|
2092 |
+
speed: 5,
|
2093 |
+
isEnemy: true,
|
2094 |
+
damage: 100,
|
2095 |
+
size: 3
|
2096 |
+
});
|
2097 |
+
}
|
2098 |
+
} else {
|
2099 |
+
const sound = this.isBoss ? new Audio('firemn.ogg') : enemyFireSound.cloneNode();
|
2100 |
+
sound.play();
|
2101 |
+
|
2102 |
+
// ๋ณด์ค์ ์ ์ ์ ๋์ cannon_fire ํจ๊ณผ๋ฅผ ์ฌ์ฉ
|
2103 |
+
if (this.isBoss || this.isElite) {
|
2104 |
+
effects.push(new Effect(
|
2105 |
+
this.x + Math.cos(this.angle) * 30,
|
2106 |
+
this.y + Math.sin(this.angle) * 30,
|
2107 |
+
750, // 0.75์ด ๋์ ์ง์
|
2108 |
+
'cannon_fire',
|
2109 |
+
this.angle,
|
2110 |
+
this
|
2111 |
+
));
|
2112 |
+
} else {
|
2113 |
+
effects.push(new Effect(
|
2114 |
+
this.x + Math.cos(this.angle) * 30,
|
2115 |
+
this.y + Math.sin(this.angle) * 30,
|
2116 |
+
500,
|
2117 |
+
'fire',
|
2118 |
+
this.angle,
|
2119 |
+
this
|
2120 |
+
));
|
2121 |
+
}
|
2122 |
+
|
2123 |
+
bullets.push({
|
2124 |
+
x: this.x + Math.cos(this.angle) * 30,
|
2125 |
+
y: this.y + Math.sin(this.angle) * 30,
|
2126 |
+
angle: this.angle,
|
2127 |
+
speed: this.isBoss ? 10 : 5,
|
2128 |
+
isEnemy: true,
|
2129 |
+
size: this.isBoss ? 5 : 3,
|
2130 |
+
damage: this.isBoss ? 450 : 150
|
2131 |
+
});
|
2132 |
+
}
|
2133 |
+
}
|
2134 |
}
|
2135 |
// ๋ณด์ค ์คํ
์ด์ง ์์ ํจ์ ์์
|
2136 |
function startBossStage() {
|
|
|
2222 |
const now = Date.now();
|
2223 |
if ((keys[' '] || autoFire) && now - lastShot > weapon.fireRate) {
|
2224 |
weapon.sound.cloneNode().play();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2225 |
|
2226 |
+
// ์ด๊ตฌ ์์น ๊ณ์ฐ
|
2227 |
+
const muzzleX = player.x + Math.cos(player.angle) * (player.width/2);
|
2228 |
+
const muzzleY = player.y + Math.sin(player.angle) * (player.width/2);
|
2229 |
+
|
2230 |
+
// ๋ฌด๊ธฐ ํ์
์ ๋ฐ๋ฅธ ์ดํํธ ์์ฑ
|
2231 |
+
if (currentWeapon === 'cannon') {
|
2232 |
+
// ์บ๋
ผ ๋ฐ์ฌ ํจ๊ณผ (shot1->shot2->shot3 ์์๋ก ๋ณ๊ฒฝ)
|
2233 |
+
effects.push(new Effect(
|
2234 |
+
muzzleX,
|
2235 |
+
muzzleY,
|
2236 |
+
1500, // ์ ์ฒด ์ง์์๊ฐ 1.5์ด
|
2237 |
+
'cannon_fire', // ์บ๋
ผ ๋ฐ์ฌ ์ ์ฉ ํ์
|
2238 |
+
player.angle,
|
2239 |
+
player
|
2240 |
+
));
|
2241 |
+
} else {
|
2242 |
+
// ๊ธฐ๊ด์ด ๋ฐ์ฌ ํจ๊ณผ
|
2243 |
+
effects.push(new Effect(
|
2244 |
+
player.x + Math.cos(player.angle) * 30,
|
2245 |
+
player.y + Math.sin(player.angle) * 30,
|
2246 |
+
500,
|
2247 |
+
'fire',
|
2248 |
+
player.angle,
|
2249 |
+
player
|
2250 |
+
));
|
2251 |
+
}
|
2252 |
+
|
2253 |
+
// ์ด์ ์์ฑ
|
2254 |
bullets.push({
|
2255 |
+
x: muzzleX, // ์ด๊ตฌ ์์น์์ ๋ฐ์ฌ
|
2256 |
+
y: muzzleY,
|
2257 |
angle: player.angle,
|
2258 |
speed: hasAPCR ? 20 : 10,
|
2259 |
isEnemy: false,
|
|
|
2278 |
this.offset = { x: Math.cos(angle) * 30, y: Math.sin(angle) * 30 };
|
2279 |
this.img = new Image();
|
2280 |
|
2281 |
+
// ์บ๋
ผ ์ท ํจ๊ณผ๋ฅผ ์ํ ์ถ๊ฐ ์์ฑ
|
2282 |
+
this.currentShot = 1;
|
2283 |
+
this.lastShotChange = Date.now();
|
2284 |
+
|
2285 |
+
// ๊ฐ ์ท๋ณ ํฌ๊ธฐ ์ ์ (width, height)
|
2286 |
+
this.shotSizes = {
|
2287 |
+
1: { width: 40, height: 40 }, // shot1.png - ์์ ํ์ผ
|
2288 |
+
2: { width: 60, height: 60 }, // shot2.png - ์ค๊ฐ ํ์ผ
|
2289 |
+
3: { width: 80, height: 80 } // shot3.png - ํฐ ํ์ผ
|
2290 |
+
};
|
2291 |
+
|
2292 |
// ์ดํํธ ํ์
์ ๋ฐ๋ฅธ ์ด๋ฏธ์ง ์ค์
|
2293 |
if (type === 'death') {
|
2294 |
this.img.src = 'bang.png';
|
|
|
2296 |
this.img.src = 'bomb1.png';
|
2297 |
} else if (type === 'hit') {
|
2298 |
this.img.src = 'fire3.png';
|
2299 |
+
} else if (type === 'cannon_fire') {
|
2300 |
+
this.img.src = 'shot1.png';
|
2301 |
+
this.duration = 750; // ์ด 0.75์ด (0.25์ด ร 3)
|
2302 |
+
this.currentSize = this.shotSizes[1]; // ์ด๊ธฐ ํฌ๊ธฐ ์ค์
|
2303 |
} else {
|
2304 |
this.img.src = 'fire2.png';
|
2305 |
}
|
2306 |
|
2307 |
+
// ๊ธฐ๋ณธ ์ดํํธ ํฌ๊ธฐ ์ค์
|
2308 |
+
this.size = type === 'bomb' ? 100 :
|
2309 |
type === 'death' ? 75 :
|
2310 |
+
type === 'hit' ? 30 : 42;
|
2311 |
+
}
|
2312 |
|
2313 |
update() {
|
2314 |
+
if(this.parent) {
|
2315 |
+
if(this.type === 'cannon_fire') {
|
2316 |
+
this.x = this.parent.x + Math.cos(this.parent.angle) * (this.parent.width/2);
|
2317 |
+
this.y = this.parent.y + Math.sin(this.parent.angle) * (this.parent.width/2);
|
2318 |
+
this.angle = this.parent.angle;
|
2319 |
+
|
2320 |
+
const now = Date.now();
|
2321 |
+
const elapsedTime = now - this.startTime;
|
2322 |
+
|
2323 |
+
// 0.25์ด๋ง๋ค ์ด๋ฏธ์ง ๋ณ๊ฒฝํ๊ณ , ๋ง์ง๋ง shot3์ 0.25์ด๋ง ์ง์
|
2324 |
+
if (elapsedTime < 250) {
|
2325 |
+
this.currentShot = 1;
|
2326 |
+
} else if (elapsedTime < 500) {
|
2327 |
+
this.currentShot = 2;
|
2328 |
+
} else {
|
2329 |
+
this.currentShot = 3;
|
2330 |
+
}
|
2331 |
+
|
2332 |
+
this.img.src = `shot${this.currentShot}.png`;
|
2333 |
+
this.currentSize = this.shotSizes[this.currentShot];
|
2334 |
+
} else if(this.type === 'fire') {
|
2335 |
+
this.x = this.parent.x + this.offset.x;
|
2336 |
+
this.y = this.parent.y + this.offset.y;
|
2337 |
+
this.angle = this.parent.angle;
|
2338 |
+
}
|
2339 |
}
|
2340 |
}
|
2341 |
|