Start Menu
12
Main.html
@ -10,6 +10,18 @@
|
||||
<div id="game">
|
||||
<canvas id="canvas" height="650" width="1280"></canvas>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="startMenu">
|
||||
<h1 class="title">GALAXY STRIKER</h1>
|
||||
|
||||
<button class="menuButton" id="startBtn">Start</button>
|
||||
<button class="menuButton" id="optionsBtn">Options</button>
|
||||
<button class="menuButton" id="musicBtn">Music: ON</button>
|
||||
<button class="menuButton" id="exitBtn">Exit</button>
|
||||
</div>
|
||||
|
||||
<script src="Script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
53
Script.js
@ -84,8 +84,61 @@ function init() {
|
||||
document.addEventListener('keydown', keyDownPressed, false);
|
||||
document.addEventListener('keyup', keyUpPressed, false);
|
||||
gameLoop();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
document.getElementById("startBtn").onclick = () => {
|
||||
document.getElementById("startMenu").style.display = "none";
|
||||
gameStarted = true;
|
||||
gameLoop();
|
||||
};
|
||||
|
||||
document.getElementById("musicBtn").onclick = () => {
|
||||
musicMuted = !musicMuted;
|
||||
backgroundMusic.muted = musicMuted;
|
||||
|
||||
document.getElementById("musicBtn").innerText = musicMuted
|
||||
? "Music: OFF"
|
||||
: "Music: ON";
|
||||
};
|
||||
|
||||
document.getElementById("optionsBtn").onclick = () => {
|
||||
alert(
|
||||
"Options menu belum dibuat. Kamu bisa tambah difficulty, sensitivity, dll."
|
||||
);
|
||||
};
|
||||
|
||||
document.getElementById("exitBtn").onclick = () => {
|
||||
window.close();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function gameLoop() {
|
||||
if (!gameStarted) return;
|
||||
|
||||
clearGame();
|
||||
updateGame();
|
||||
drawGame();
|
||||
requestAnimationFrame(gameLoop);
|
||||
}
|
||||
|
||||
|
||||
function keyDownPressed(e) {
|
||||
if (e.keyCode == 87) {
|
||||
keys.up = true;
|
||||
|
||||
49
Style.css
@ -23,3 +23,52 @@ body {
|
||||
margin: 0px;
|
||||
background-color: rgb(0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#startMenu {
|
||||
position: absolute;
|
||||
width: 1280px;
|
||||
height: 650px;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: rgba(0,0,0,0.85);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 10;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 60px;
|
||||
margin-bottom: 50px;
|
||||
color: white;
|
||||
letter-spacing: 3px;
|
||||
}
|
||||
|
||||
.menuButton {
|
||||
font-size: 30px;
|
||||
padding: 10px 40px;
|
||||
margin: 10px;
|
||||
cursor: pointer;
|
||||
background: #222;
|
||||
border: 2px solid white;
|
||||
color: white;
|
||||
border-radius: 10px;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.menuButton:hover {
|
||||
background: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
BIN
img/SBS - 2D Planet Pack 2 - Shaded 512x512.rar
Normal file
|
After Width: | Height: | Size: 445 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 459 KiB |
|
After Width: | Height: | Size: 450 KiB |
|
After Width: | Height: | Size: 455 KiB |
|
After Width: | Height: | Size: 466 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 458 KiB |
|
After Width: | Height: | Size: 458 KiB |
|
After Width: | Height: | Size: 466 KiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 503 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 494 KiB |
|
After Width: | Height: | Size: 444 KiB |
|
After Width: | Height: | Size: 472 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 498 KiB |
|
After Width: | Height: | Size: 502 KiB |
|
After Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 502 KiB |
|
After Width: | Height: | Size: 396 KiB |
|
After Width: | Height: | Size: 382 KiB |
|
After Width: | Height: | Size: 397 KiB |
|
After Width: | Height: | Size: 396 KiB |
|
After Width: | Height: | Size: 377 KiB |
|
After Width: | Height: | Size: 508 KiB |
|
After Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 512 KiB |
|
After Width: | Height: | Size: 514 KiB |
|
After Width: | Height: | Size: 513 KiB |
|
After Width: | Height: | Size: 478 KiB |
|
After Width: | Height: | Size: 490 KiB |
|
After Width: | Height: | Size: 471 KiB |
|
After Width: | Height: | Size: 470 KiB |
|
After Width: | Height: | Size: 475 KiB |
|
After Width: | Height: | Size: 531 KiB |
|
After Width: | Height: | Size: 534 KiB |
|
After Width: | Height: | Size: 535 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 542 KiB |
|
After Width: | Height: | Size: 510 KiB |
|
After Width: | Height: | Size: 528 KiB |
|
After Width: | Height: | Size: 515 KiB |
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 498 KiB |
|
After Width: | Height: | Size: 546 KiB |
|
After Width: | Height: | Size: 543 KiB |
|
After Width: | Height: | Size: 554 KiB |
|
After Width: | Height: | Size: 568 KiB |
|
After Width: | Height: | Size: 581 KiB |
|
After Width: | Height: | Size: 500 KiB |
|
After Width: | Height: | Size: 497 KiB |
|
After Width: | Height: | Size: 502 KiB |
|
After Width: | Height: | Size: 501 KiB |
|
After Width: | Height: | Size: 497 KiB |
|
After Width: | Height: | Size: 437 KiB |
|
After Width: | Height: | Size: 434 KiB |
|
After Width: | Height: | Size: 434 KiB |
|
After Width: | Height: | Size: 439 KiB |
|
After Width: | Height: | Size: 443 KiB |
|
After Width: | Height: | Size: 448 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 447 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 446 KiB |
|
After Width: | Height: | Size: 485 KiB |
|
After Width: | Height: | Size: 472 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 406 KiB |
|
After Width: | Height: | Size: 408 KiB |
|
After Width: | Height: | Size: 406 KiB |
|
After Width: | Height: | Size: 413 KiB |
|
After Width: | Height: | Size: 412 KiB |
|
After Width: | Height: | Size: 499 KiB |
|
After Width: | Height: | Size: 508 KiB |
|
After Width: | Height: | Size: 505 KiB |
|
After Width: | Height: | Size: 499 KiB |
|
After Width: | Height: | Size: 509 KiB |
|
After Width: | Height: | Size: 496 KiB |
|
After Width: | Height: | Size: 474 KiB |
|
After Width: | Height: | Size: 586 KiB |
|
After Width: | Height: | Size: 450 KiB |
|
After Width: | Height: | Size: 510 KiB |
|
After Width: | Height: | Size: 444 KiB |
|
After Width: | Height: | Size: 453 KiB |
|
After Width: | Height: | Size: 465 KiB |
|
After Width: | Height: | Size: 445 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 541 KiB |