Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
633 changes: 633 additions & 0 deletions kimyunyeong/app.js

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/Pplayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/attack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/enemyShip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/glitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/house8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/laser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/present1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/present2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/snowhill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/starrynight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kimyunyeong/assets/tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions kimyunyeong/graphic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");

// 이미지 로드 함수
function loadImages(imageSources) {
return Promise.all(
imageSources.map((src) => {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = (error) => reject(error);
img.src = src;
});
})
);
}

// 이미지 경로
const imageSource = "assets/snowhill.png";

// 이미지 로드 및 그리기
loadImage(imageSource)
.then((img) => {
// 이미지를 캔버스 하단에 그립니다.
ctx.drawImage(img, 0, canvas.height - img.height, canvas.width, img.height);
})
.catch((error) => {
console.error("Error loading image:", error);
});
62 changes: 62 additions & 0 deletions kimyunyeong/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="main" role="main">
<canvas id="canvas" width="1024" height="768"></canvas>
<div id="gameOverScreen" style="display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">
<p>게임 오버!</p>
<button id="restartButton" style="margin-top: 10px;">게임 재시작</button>
</div>
</div>

<!-- Stats.js CDN 추가 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/stats.js/r16/Stats.min.js"></script>
<script src="app.js"></script>
<script>
let gameLoopId;
const gameOverScreen = document.getElementById('gameOverScreen');
const restartButton = document.getElementById('restartButton');
// Stats.js로 프레임 속도 표시
const stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.left = '0px';
stats.domElement.style.top = '0px';

document.getElementById('main').appendChild(stats.domElement);

setInterval(() => {
stats.update();
}, 1000 / 60);

// 페이지 로딩이 완료되면 게임 초기화 실행
window.onload = () => {
// resetCanvas();
initGame(); // initGame 함수 호출
handleEvents();
gameLoop(); // gameLoop를 초기에 실행하도록 수정
};



restartButton.addEventListener('click', () => {
resetCanvas(); // 캔버스 리셋
initGame(); // initGame 함수 호출
isGameOver = false;
gameOverScreen.style.display = 'none';
// cancelAnimationFrame(gameLoopId); // 현재의 게임 루프를 정지

// gameObjects 배열에서 hero 객체를 찾기
const heroIndex = gameObjects.findIndex(go => go === hero);

gameObjects = [];

});
</script>
</body>
</html>
29 changes: 29 additions & 0 deletions kimyunyeong/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
body {
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #222;
overflow: hidden;
}

#main {
position: relative;
}

#canvas {
border: 1px solid #fff;
background-image: url('assets/starrynight.png'); /* 배경 이미지 파일 경로로 수정해주세요 */
background-size: cover; /* 배경 이미지를 캔버스에 맞게 조절합니다 */
}

#merry-christmas {
height: 200px;
top: 10px; /* 캔버스 위쪽에 위치하도록 조정합니다. */
left: 50%;
transform: translateX(-50%);
text-align: center;
font-size: 24px;
color: red;
}