Spaces:
Running
Running
<html lang="ko"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
<title>๋ง๊ณ ํฉ์น๊ธฐ ๊ฒ์</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/matter-js/0.19.0/matter.min.js"></script> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
justify-content: center; | |
height: 100vh; | |
background-color: #FFF3E0; /* ์ฐํ ๋ง๊ณ ์ ๋ฐฐ๊ฒฝ */ | |
font-family: 'Arial', sans-serif; | |
overflow: hidden; /* ์คํฌ๋กค ๋ฐฉ์ง */ | |
touch-action: none; /* ๋ชจ๋ฐ์ผ์์ ๋ถํ์ํ ์คํฌ๋กค/์ค ๋ฐฉ์ง */ | |
} | |
#game-container { | |
position: relative; | |
border: 2px solid #FFA000; /* ์งํ ๋ง๊ณ ์ ํ ๋๋ฆฌ */ | |
background-color: #FFECB3; /* ๊ฒ์ ์์ญ ๋ฐฐ๊ฒฝ */ | |
box-shadow: 0 0 10px rgba(0,0,0,0.2); | |
border-radius: 10px; | |
overflow: hidden; /* ๋ด๋ถ ์์๊ฐ ๋์น์ง ์๋๋ก */ | |
} | |
canvas { | |
display: block; | |
background-color: transparent; /* ์บ๋ฒ์ค ์์ฒด ๋ฐฐ๊ฒฝ์ ํฌ๋ช ํ๊ฒ */ | |
} | |
#ui-container { | |
display: flex; | |
justify-content: space-around; | |
align-items: center; | |
width: 100%; | |
max-width: 400px; /* ๊ฒ์ ์ปจํ ์ด๋ ๋๋น์ ๋ง์ถค */ | |
padding: 10px 0; | |
color: #E65100; /* UI ํ ์คํธ ์์ */ | |
} | |
#score-board, #next-mango-preview { | |
font-size: 1.2em; | |
font-weight: bold; | |
} | |
#game-over-message { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
background-color: rgba(0, 0, 0, 0.7); | |
color: white; | |
padding: 20px; | |
border-radius: 10px; | |
text-align: center; | |
font-size: 1.5em; | |
display: none; /* ์ด๊ธฐ์๋ ์จ๊น */ | |
z-index: 100; | |
} | |
#game-over-message button { | |
padding: 10px 20px; | |
font-size: 0.8em; | |
margin-top: 15px; | |
background-color: #FFA000; | |
color: white; | |
border: none; | |
border-radius: 5px; | |
cursor: pointer; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="ui-container"> | |
<div id="score-board">์ ์: 0</div> | |
<div id="next-mango-preview">๋ค์ ๋ง๊ณ : ?</div> | |
</div> | |
<div id="game-container"> | |
<canvas id="game-canvas"></canvas> | |
<div id="game-over-message"> | |
๊ฒ์ ์ค๋ฒ!<br> | |
์ต์ข ์ ์: <span id="final-score">0</span> | |
<button onclick="restartGame()">๋ค์ ์์</button> | |
</div> | |
</div> | |
<script> | |
// Matter.js ๋ชจ๋ | |
const { Engine, Render, Runner, Bodies, Composite, Events, Mouse, MouseConstraint, Body } = Matter; | |
// ๊ฒ์ ์ค์ | |
const gameContainer = document.getElementById('game-container'); | |
const canvas = document.getElementById('game-canvas'); | |
const scoreBoard = document.getElementById('score-board'); | |
const nextMangoPreview = document.getElementById('next-mango-preview'); | |
const gameOverMessage = document.getElementById('game-over-message'); | |
const finalScoreDisplay = document.getElementById('final-score'); | |
// ํ๋ฉด ํฌ๊ธฐ์ ๋ง๊ฒ ์บ๋ฒ์ค ํฌ๊ธฐ ๋์ ์กฐ์ | |
let canvasWidth = Math.min(window.innerWidth * 0.95, 400); // ํ๋ฉด ๋๋น์ 95% ๋๋ ์ต๋ 400px | |
let canvasHeight = Math.min(window.innerHeight * 0.7, 600); // ํ๋ฉด ๋์ด์ 70% ๋๋ ์ต๋ 600px | |
gameContainer.style.width = `${canvasWidth}px`; | |
gameContainer.style.height = `${canvasHeight}px`; | |
canvas.width = canvasWidth; | |
canvas.height = canvasHeight; | |
// ๋ง๊ณ ์ข ๋ฅ ์ ์ (ํฌ๊ธฐ, ์์, ์ ์) | |
const MANGO_TYPES = [ | |
{ radius: canvasWidth * 0.035, color: '#FFF9C4', score: 10, label: '์ ํ๋ง๊ณ ์จ์' }, // ๋งค์ฐ ์์ | |
{ radius: canvasWidth * 0.045, color: '#FFF176', score: 20, label: '๋ฏธ๋ ๋ง๊ณ ' }, | |
{ radius: canvasWidth * 0.06, color: '#FFEE58', score: 40, label: '์์ ๋ง๊ณ ' }, | |
{ radius: canvasWidth * 0.075, color: '#FFD54F', score: 80, label: '๋ง๊ณ ' }, | |
{ radius: canvasWidth * 0.09, color: '#FFC107', score: 160, label: '์์ต์ ๋ง๊ณ ' }, | |
{ radius: canvasWidth * 0.11, color: '#FFA000', score: 320, label: 'ํน๋ ๋ง๊ณ ' }, | |
{ radius: canvasWidth * 0.13, color: '#FF8F00', score: 640, label: '์ ๋ณด ๋ง๊ณ ' }, | |
{ radius: canvasWidth * 0.15, color: '#FF6F00', score: 1280, label: 'ํน ๋ง๊ณ ' }, | |
{ radius: canvasWidth * 0.18, color: '#E65100', score: 2560, label: '๊ณจ๋ ํน๋ง๊ณ ' } // ๊ฐ์ฅ ํฐ ๋ง๊ณ | |
]; | |
let engine, render, runner; | |
let currentDroppingMango = null; | |
let nextMangoTypeIndex = 0; | |
let score = 0; | |
let gameOver = false; | |
let canDrop = true; // ๋๋ ์ฟจํ์ | |
const DROP_COOLDOWN = 300; // ms | |
const gameOverLineY = canvasHeight * 0.15; // ์ด ์ ์๋ก ๋ง๊ณ ๊ฐ ์์ด๋ฉด ๊ฒ์ ์ค๋ฒ | |
function initGame() { | |
gameOver = false; | |
score = 0; | |
updateScoreDisplay(); | |
gameOverMessage.style.display = 'none'; | |
canDrop = true; | |
// Matter.js ์์ง ์์ฑ | |
engine = Engine.create(); | |
engine.world.gravity.y = 0.9; // ์ค๋ ฅ ์ค์ | |
// Matter.js ๋ ๋๋ฌ ์์ฑ | |
render = Render.create({ | |
canvas: canvas, | |
engine: engine, | |
options: { | |
width: canvasWidth, | |
height: canvasHeight, | |
wireframes: false, // ์์ ์ฑ์ฐ๊ธฐ | |
background: 'transparent' // game-container ๋ฐฐ๊ฒฝ์์ ์ฌ์ฉ | |
} | |
}); | |
// ๋ฒฝ๊ณผ ๋ฐ๋ฅ ์์ฑ | |
const wallOptions = { isStatic: true, render: { fillStyle: '#BCAAA4' } }; // ์ฐ๊ฐ์ ๋ฒฝ | |
Composite.add(engine.world, [ | |
Bodies.rectangle(canvasWidth / 2, canvasHeight + 25, canvasWidth, 50, wallOptions), // ๋ฐ๋ฅ (๋๋ํ๊ฒ ์๋๋ก) | |
Bodies.rectangle(-25, canvasHeight / 2, 50, canvasHeight, wallOptions), // ์ผ์ชฝ ๋ฒฝ | |
Bodies.rectangle(canvasWidth + 25, canvasHeight / 2, 50, canvasHeight, wallOptions) // ์ค๋ฅธ์ชฝ ๋ฒฝ | |
]); | |
// ๊ฒ์ ์ค๋ฒ ๋ผ์ธ (์๊ฐ์ ํ์๋ ์ํจ, ํ์ ์ฉ) | |
// Bodies.rectangle(canvasWidth / 2, gameOverLineY, canvasWidth, 2, { isStatic: true, isSensor: true, render: {fillStyle: 'red' }}) | |
// ๋ค์ ๋ง๊ณ ์ค๋น | |
prepareNextMango(); | |
updateNextMangoPreview(); | |
// ์์ง ์คํ | |
runner = Runner.create(); | |
Runner.run(runner, engine); | |
Render.run(render); | |
// ์ถฉ๋ ์ด๋ฒคํธ ๋ฆฌ์ค๋ | |
Events.on(engine, 'collisionStart', handleCollision); | |
// ๋ง์ฐ์ค/ํฐ์น ์ด๋ฒคํธ | |
gameContainer.addEventListener('click', handleDropInput); | |
gameContainer.addEventListener('mousemove', handleMouseMove); | |
gameContainer.addEventListener('touchmove', handleTouchMove, { passive: false }); // passive false๋ก ์คํฌ๋กค ๋ฐฉ์ง | |
gameContainer.addEventListener('touchend', handleDropInput); | |
// ๊ฒ์ ๋ฃจํ (๊ฒ์์ค๋ฒ ์ฒดํฌ ๋ฑ) | |
Events.on(engine, 'afterUpdate', checkGameOver); | |
// ํ์ฌ ๋จ์ด๋จ๋ฆด ๋ง๊ณ ์์ฑ | |
spawnDroppingMango(); | |
} | |
function spawnDroppingMango() { | |
if (gameOver || !canDrop) return; | |
const mangoType = MANGO_TYPES[nextMangoTypeIndex]; | |
const x = Math.max(mangoType.radius, Math.min(canvasWidth - mangoType.radius, canvasWidth / 2)); // ์ค์์์ ์์ | |
currentDroppingMango = Bodies.circle(x, mangoType.radius * 1.5, mangoType.radius, { | |
isStatic: true, // ๋จ์ด์ง๊ธฐ ์ ์๋ ๊ณ ์ | |
restitution: 0.2, | |
friction: 0.5, | |
label: 'droppingMango', | |
mangoIndex: nextMangoTypeIndex, | |
render: { | |
fillStyle: mangoType.color, | |
strokeStyle: '#5D4037', // ๋ง๊ณ ํ ๋๋ฆฌ | |
lineWidth: 2 | |
} | |
}); | |
Composite.add(engine.world, currentDroppingMango); | |
prepareNextMango(); | |
updateNextMangoPreview(); | |
} | |
function prepareNextMango() { | |
// ์ฒ์ ๋ช ๊ฐ๋ ์์ ๋ง๊ณ ์์ฃผ๋ก | |
if (Composite.allBodies(engine.world).filter(b => b.label === 'mango').length < 5) { | |
nextMangoTypeIndex = Math.floor(Math.random() * 3); // 0, 1, 2 ์ค ํ๋ | |
} else { | |
nextMangoTypeIndex = Math.floor(Math.random() * 5); // 0, 1, 2, 3, 4 ์ค ํ๋ | |
} | |
} | |
function updateNextMangoPreview() { | |
if (gameOver) { | |
nextMangoPreview.textContent = "๋ค์ ๋ง๊ณ : -"; | |
return; | |
} | |
const nextType = MANGO_TYPES[nextMangoTypeIndex]; | |
// ์ด๋ชจ์ง๋ก ํํํ๊ฑฐ๋, ์์ ์์ผ๋ก ํํํ ์๋ ์์ต๋๋ค. | |
nextMangoPreview.innerHTML = `๋ค์: <span style="color:${nextType.color}; font-size:1.2em;">โ</span> ${nextType.label.split(' ')[0]}`; | |
} | |
function handleMouseMove(event) { | |
if (gameOver || !currentDroppingMango || !currentDroppingMango.isStatic) return; | |
const rect = canvas.getBoundingClientRect(); | |
let x = event.clientX - rect.left; | |
const radius = MANGO_TYPES[currentDroppingMango.mangoIndex].radius; | |
x = Math.max(radius, Math.min(canvasWidth - radius, x)); // ์บ๋ฒ์ค ๊ฒฝ๊ณ ์์ผ๋ก ์ ํ | |
Body.setPosition(currentDroppingMango, { x: x, y: currentDroppingMango.position.y }); | |
} | |
function handleTouchMove(event) { | |
if (gameOver || !currentDroppingMango || !currentDroppingMango.isStatic) return; | |
event.preventDefault(); // ์คํฌ๋กค ๋ฐฉ์ง | |
const rect = canvas.getBoundingClientRect(); | |
let x = event.touches[0].clientX - rect.left; | |
const radius = MANGO_TYPES[currentDroppingMango.mangoIndex].radius; | |
x = Math.max(radius, Math.min(canvasWidth - radius, x)); | |
Body.setPosition(currentDroppingMango, { x: x, y: currentDroppingMango.position.y }); | |
} | |
function handleDropInput(event) { | |
if (gameOver || !currentDroppingMango || !canDrop || !currentDroppingMango.isStatic) return; | |
Body.setStatic(currentDroppingMango, false); // ๋ง๊ณ ๋ฅผ ๋จ์ด๋จ๋ฆผ | |
currentDroppingMango.label = 'mango'; // ์ผ๋ฐ ๋ง๊ณ ๋ก ๋ ์ด๋ธ ๋ณ๊ฒฝ | |
currentDroppingMango = null; | |
canDrop = false; | |
// ๋ค์ ๋ง๊ณ ์คํฐ ์ฟจ๋ค์ด | |
setTimeout(() => { | |
canDrop = true; | |
if (!gameOver) { | |
spawnDroppingMango(); | |
} | |
}, DROP_COOLDOWN); | |
} | |
function handleCollision({ pairs }) { | |
if (gameOver) return; | |
pairs.forEach(pair => { | |
const bodyA = pair.bodyA; | |
const bodyB = pair.bodyB; | |
if (bodyA.label === 'mango' && bodyB.label === 'mango' && | |
bodyA.mangoIndex !== undefined && bodyB.mangoIndex !== undefined && | |
bodyA.mangoIndex === bodyB.mangoIndex) { | |
// ๊ฐ์ ์ข ๋ฅ์ ๋ง๊ณ ๊ฐ ์ถฉ๋ํ๋ฉด | |
const currentTypeIndex = bodyA.mangoIndex; | |
if (currentTypeIndex < MANGO_TYPES.length - 1) { | |
// ํฉ์ณ์ง ์์น (๋ ๋ง๊ณ ์ ์ค๊ฐ) | |
const newPosition = { | |
x: (bodyA.position.x + bodyB.position.x) / 2, | |
y: (bodyA.position.y + bodyB.position.y) / 2 | |
}; | |
// ๊ธฐ์กด ๋ง๊ณ ์ ๊ฑฐ | |
Composite.remove(engine.world, [bodyA, bodyB]); | |
// ์ ๋ง๊ณ ์์ฑ | |
const nextTypeIndex = currentTypeIndex + 1; | |
const newMangoType = MANGO_TYPES[nextTypeIndex]; | |
const newMango = Bodies.circle(newPosition.x, newPosition.y, newMangoType.radius, { | |
restitution: 0.2, | |
friction: 0.5, | |
label: 'mango', | |
mangoIndex: nextTypeIndex, | |
render: { | |
fillStyle: newMangoType.color, | |
strokeStyle: '#5D4037', | |
lineWidth: 2 | |
} | |
}); | |
Composite.add(engine.world, newMango); | |
// ์ ์ ์ถ๊ฐ | |
score += newMangoType.score; | |
updateScoreDisplay(); | |
// ํฉ์ณ์ง ๋ ์์ ํจ๊ณผ (์ ํ ์ฌํญ) | |
Body.scale(newMango, 1.1, 1.1); // ์ด์ง ์ปค์ก๋ค๊ฐ | |
setTimeout(() => Body.scale(newMango, 1/1.1, 1/1.1), 50); // ์๋ ํฌ๊ธฐ๋ก | |
} else { | |
// ๊ฐ์ฅ ํฐ ๋ง๊ณ ๋ผ๋ฆฌ ํฉ์ณ์ง๋ฉด ํน๋ณํ ์ฒ๋ฆฌ (์: ๋ณด๋์ค ์ ์) | |
score += MANGO_TYPES[currentTypeIndex].score * 2; // ๋ง์ง๋ง ๋ง๊ณ ํฉ์ฒด ์ ๋ณด๋์ค | |
updateScoreDisplay(); | |
// ์ฌ๊ธฐ์๋ ๊ทธ๋ฅ ๋์ง๋ง, ์ํ๋ค๋ฉด ๋ ๊ฐ๋ฅผ ์ ๊ฑฐํ ์๋ ์์ | |
} | |
} | |
}); | |
} | |
function updateScoreDisplay() { | |
scoreBoard.textContent = `์ ์: ${score}`; | |
} | |
let gameOverCheckTimeout = null; | |
function checkGameOver() { | |
if (gameOver) return; | |
const bodies = Composite.allBodies(engine.world); | |
for (let body of bodies) { | |
// 'droppingMango'๋ ์์ง ๋จ์ด์ง๋ ์ค์ด๋ฏ๋ก ์ ์ธ, isStatic๋ ์ ์ธ (๋ฒฝ ๋ฑ) | |
if (body.label === 'mango' && !body.isStatic) { | |
// ๋ง๊ณ ์ ์ต์๋จ์ด ๊ฒ์ ์ค๋ฒ ๋ผ์ธ๋ณด๋ค ์์ ์๊ณ , ์๋๊ฐ ๊ฑฐ์ ๋ฉ์ท์ ๋ | |
if (body.position.y - MANGO_TYPES[body.mangoIndex].radius < gameOverLineY && Math.abs(body.velocity.y) < 0.1) { | |
// ๋ฐ๋ก ๊ฒ์์ค๋ฒ ์ํค์ง ์๊ณ , ์ ๊น ์ ์ ์๊ฐ์ ๋ (์์ฌ์์ฌํ๊ฒ ๊ฑธ์น๋ ๊ฒฝ์ฐ) | |
if (!gameOverCheckTimeout) { | |
gameOverCheckTimeout = setTimeout(() => { | |
// ์ ์ ์๊ฐ ํ์๋ ์ฌ์ ํ ์กฐ๊ฑด ๋ง์กฑ ์ ๊ฒ์ ์ค๋ฒ | |
if (body.position.y - MANGO_TYPES[body.mangoIndex].radius < gameOverLineY) { | |
triggerGameOver(); | |
} | |
gameOverCheckTimeout = null; | |
}, 1500); // 1.5์ด ์ ์ | |
} | |
return; // ํ๋๋ผ๋ ๊ฑธ๋ฆฌ๋ฉด ์ผ๋จ ๋๊ธฐ | |
} | |
} | |
} | |
// ๊ฒ์์ค๋ฒ ๋ผ์ธ์ ๊ฑธ๋ฆฐ ๋ง๊ณ ๊ฐ ์์ผ๋ฉด ์ ์ ํ์ด๋จธ ์ทจ์ | |
if (gameOverCheckTimeout) { | |
clearTimeout(gameOverCheckTimeout); | |
gameOverCheckTimeout = null; | |
} | |
} | |
function triggerGameOver() { | |
if (gameOver) return; // ์ค๋ณต ํธ์ถ ๋ฐฉ์ง | |
gameOver = true; | |
canDrop = false; // ๋ ์ด์ ๋๋ ๋ถ๊ฐ | |
finalScoreDisplay.textContent = score; | |
gameOverMessage.style.display = 'block'; | |
// ํ์ฌ ์์ง์ด๋ ๋ง๊ณ ๊ฐ ์๋ค๋ฉด ์ ๊ฑฐ | |
if(currentDroppingMango) { | |
Composite.remove(engine.world, currentDroppingMango); | |
currentDroppingMango = null; | |
} | |
updateNextMangoPreview(); // ๋ค์ ๋ง๊ณ ํ์ ์์ ๊ธฐ | |
// Runner.stop(runner); // ๋ฌผ๋ฆฌ์์ง ๋ฉ์ถ๊ธฐ (์ ํ) | |
// Render.stop(render); // ๋ ๋๋ง ๋ฉ์ถ๊ธฐ (์ ํ) | |
console.log("๊ฒ์ ์ค๋ฒ! ์ต์ข ์ ์:", score); | |
} | |
function restartGame() { | |
// ๊ธฐ์กด Matter.js ๊ฐ์ฒด๋ค ์ ๋ฆฌ | |
if (runner) Runner.stop(runner); | |
if (render) Render.stop(render); | |
if (engine) { | |
Composite.clear(engine.world, false); // false๋ ๋ฒฝ ๋ฑ static body๋ ๋จ๊ธฐ์ง ์์ | |
Engine.clear(engine); | |
} | |
// ์ด๋ฒคํธ ๋ฆฌ์ค๋๋ ์ ๊ฑฐํด์ผ ํ ์ ์์ผ๋, ์ฌ๊ธฐ์๋ gameContainer๋ฅผ ํต์งธ๋ก ์ฐ๋ฏ๋ก ๊ด์ฐฎ์ ์ ์์ | |
// gameContainer.removeEventListener('click', handleDropInput); | |
// ... (๋ค๋ฅธ ๋ฆฌ์ค๋๋ค๋) | |
// ๊ฒ์ ์ฌ์์ | |
initGame(); | |
} | |
// ์ฐฝ ํฌ๊ธฐ ๋ณ๊ฒฝ ์ ๊ฒ์ ๋ค์ ๋ก๋ (๊ฐ๋จํ ์ฒ๋ฆฌ) | |
// ์ข ๋ ๋ถ๋๋ฌ์ด ๋ฆฌ์ฌ์ด์ง์ ์ํ๋ฉด, Matter.js์ Render.setPixelRatio, Body.scale ๋ฑ์ ์ฌ์ฉํด์ผ ํจ | |
window.addEventListener('resize', () => { | |
// ๊ฒ์์ด ์งํ ์ค์ด์๋ค๋ฉด, ์ฌ์ฉ์์๊ฒ ์๋ฆฌ๊ณ ์ฌ์์ ์ ๋ํ๋ ๊ฒ์ด ์ข์ | |
// ์ฌ๊ธฐ์๋ ๊ฐ๋จํ๊ฒ ์๋ก๊ณ ์นจ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌํ๊ฑฐ๋, restartGame() ํธ์ถ | |
// alert("ํ๋ฉด ํฌ๊ธฐ๊ฐ ๋ณ๊ฒฝ๋์ด ๊ฒ์์ ์ฌ์์ํฉ๋๋ค."); | |
// location.reload(); // ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ | |
// ํน์ ๋์ ์ผ๋ก ์บ๋ฒ์ค ํฌ๊ธฐ๋ง ์กฐ์ (๋ ๋ณต์กํจ) | |
canvasWidth = Math.min(window.innerWidth * 0.95, 400); | |
canvasHeight = Math.min(window.innerHeight * 0.7, 600); | |
gameContainer.style.width = `${canvasWidth}px`; | |
gameContainer.style.height = `${canvasHeight}px`; | |
if (render) { | |
render.canvas.width = canvasWidth; | |
render.canvas.height = canvasHeight; | |
render.options.width = canvasWidth; | |
render.options.height = canvasHeight; | |
// ๋ฒฝ ์์น ์ ๋ฐ์ดํธ | |
const bodies = Composite.allBodies(engine.world); | |
const ground = bodies.find(b => b.label === 'Rectangle Body' && b.position.y > canvasHeight - 50); // ๋๋ต์ ๋ฐ๋ฅ ์ฐพ๊ธฐ | |
const leftWall = bodies.find(b => b.label === 'Rectangle Body' && b.position.x < 0); | |
const rightWall = bodies.find(b => b.label === 'Rectangle Body' && b.position.x > canvasWidth - 50); | |
if(ground) Body.setPosition(ground, { x: canvasWidth / 2, y: canvasHeight + 25 }); | |
if(leftWall) Body.setPosition(leftWall, { x: -25, y: canvasHeight / 2 }); | |
if(rightWall) Body.setPosition(rightWall, { x: canvasWidth + 25, y: canvasHeight / 2 }); | |
// ๊ณผ์ผ ํฌ๊ธฐ๋ ๋น์จ์ ๋ง๊ฒ ์ฌ์กฐ์ ํ์ | |
// MANGO_TYPES์ radius๋ฅผ canvasWidth ๊ธฐ์ค์ผ๋ก ๋ค์ ๊ณ์ฐํ๊ณ , | |
// ํ์ฌ ํ๋ฉด์ ๋ชจ๋ ๋ง๊ณ ๋ค์ ํฌ๊ธฐ๋ฅผ Body.scale๋ก ์กฐ์ ํด์ผ ํจ. (์ด ๋ถ๋ถ์ ์๋ตํจ, ๋ณต์ก๋ ์ฆ๊ฐ) | |
// ๊ฐ๋จํ restartGame()์ ํธ์ถํ๋ ๊ฒ์ด ๋ ๋์ ์ ์์. | |
} | |
// ์ค์ ๋ก๋ ๋ ๋ณต์กํ ๋ฆฌ์ฌ์ด์ฆ ์ฒ๋ฆฌ๊ฐ ํ์. ์ฌ๊ธฐ์๋ ๊ฐ๋จํ UI๋ง ๋ง์ถค. | |
// ๊ฒ์์ ์ฒ์๋ถํฐ ๋ค์ ์์ํ๋๊ฒ ๊ฐ์ฅ ์์ ์ ์ผ ์ ์์. | |
}); | |
// ๊ฒ์ ์์ | |
initGame(); | |
</script> | |
</body> | |
</html> |