Compare commits
No commits in common. "06ffdaaf7d17d8ccad7cfad6fb9abdd6036b1623" and "1191fdfca718ffc76c5fc549e479b3833478e1d1" have entirely different histories.
06ffdaaf7d
...
1191fdfca7
27
GameLogic.js
27
GameLogic.js
@ -2,6 +2,7 @@
|
|||||||
var canvas = document.getElementById("game");
|
var canvas = document.getElementById("game");
|
||||||
var content = canvas.getContext("2d");
|
var content = canvas.getContext("2d");
|
||||||
const Text = document.getElementById("text");
|
const Text = document.getElementById("text");
|
||||||
|
// const GameoverText = document.getElementById("gameover");
|
||||||
const UpDead = document.getElementById("gameover-overlay");
|
const UpDead = document.getElementById("gameover-overlay");
|
||||||
const ScoreMain = document.getElementById("gameover-score");
|
const ScoreMain = document.getElementById("gameover-score");
|
||||||
const PlayAgain = document.getElementById("ulangi");
|
const PlayAgain = document.getElementById("ulangi");
|
||||||
@ -269,7 +270,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//update teks pada speed kalau score update
|
|
||||||
function Movement() {
|
function Movement() {
|
||||||
if (++count < speed) return;
|
if (++count < speed) return;
|
||||||
if (ArahUlar > 0) ArahUlar--;
|
if (ArahUlar > 0) ArahUlar--;
|
||||||
@ -287,12 +287,10 @@
|
|||||||
if (Ular.cells.length > Ular.maxCells) Ular.cells.pop();
|
if (Ular.cells.length > Ular.maxCells) Ular.cells.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//input keyboard
|
//input keyboard buat jalan
|
||||||
function InputKeyboard() {
|
function InputKeyboard() {
|
||||||
document.addEventListener("keydown", function (e) {
|
document.addEventListener("keydown", function (e) {
|
||||||
if (!GameStart) return;
|
if (!GameStart) return;
|
||||||
|
|
||||||
// jalan buat ular
|
|
||||||
if (
|
if (
|
||||||
ArahUlar == 0 &&
|
ArahUlar == 0 &&
|
||||||
((e.code == "KeyA" && Ular.dx === 0) ||
|
((e.code == "KeyA" && Ular.dx === 0) ||
|
||||||
@ -309,29 +307,12 @@
|
|||||||
ArahUlar = 1;
|
ArahUlar = 1;
|
||||||
Ular.dy = e.code == "KeyW" ? -grid : grid;
|
Ular.dy = e.code == "KeyW" ? -grid : grid;
|
||||||
Ular.dx = 0;
|
Ular.dx = 0;
|
||||||
} else if (
|
|
||||||
ArahUlar == 0 &&
|
|
||||||
((e.code === "ArrowUp" && Ular.dy === 0) ||
|
|
||||||
(e.code == "ArrowDown" && Ular.dy === 0))
|
|
||||||
) {
|
|
||||||
ArahUlar = 1;
|
|
||||||
Ular.dy = e.code == "ArrowUp" ? -grid : grid;
|
|
||||||
Ular.dx = 0;
|
|
||||||
} else if (
|
|
||||||
ArahUlar == 0 &&
|
|
||||||
((e.code === "ArrowLeft" && Ular.dx === 0) ||
|
|
||||||
(e.code == "ArrowRight" && Ular.dx === 0))
|
|
||||||
) {
|
|
||||||
ArahUlar = 1;
|
|
||||||
Ular.dx = e.code == "ArrowLeft" ? -grid : grid;
|
|
||||||
Ular.dy = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.code === "KeyE" || e.code == "KeyQ")
|
if (e.code === "KeyE" || e.code == "KeyQ")
|
||||||
speed =
|
speed =
|
||||||
e.code == "KeyE" && speed > 5
|
e.code == "KeyE" && speed > 4
|
||||||
? speed - 1
|
? speed - 1
|
||||||
: e.code == "KeyQ" && speed < 15
|
: e.code == "KeyQ" && speed < 9
|
||||||
? speed + 1
|
? speed + 1
|
||||||
: speed;
|
: speed;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,10 +2,7 @@
|
|||||||
background-color: rgb(24, 24, 24);
|
background-color: rgb(24, 24, 24);
|
||||||
color: white;
|
color: white;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-family: "Pixelify Sans", sans-serif;
|
font-family: "Comic Sans MS", cursive, sans-serif;
|
||||||
font-optical-sizing: auto;
|
|
||||||
font-weight: 400;
|
|
||||||
font-style: normal;
|
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
}
|
}
|
||||||
header,
|
header,
|
||||||
@ -75,49 +72,6 @@
|
|||||||
#keluar:hover {
|
#keluar:hover {
|
||||||
background-color: #d32f2f;
|
background-color: #d32f2f;
|
||||||
}
|
}
|
||||||
.starting {
|
|
||||||
position: absolute;
|
|
||||||
top: 21px;
|
|
||||||
left: 51px;
|
|
||||||
width: 1056px;
|
|
||||||
height: 480px;
|
|
||||||
background-color: rgba(100, 100, 100, 0.8);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
#start {
|
|
||||||
position: absolute;
|
|
||||||
top: 21px;
|
|
||||||
left: 51px;
|
|
||||||
width: 1056px;
|
|
||||||
height: 480px;
|
|
||||||
background-color: rgba(100, 100, 100, 0.8);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
.popAwal {
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 10px;
|
|
||||||
background-color: rgb(50, 50, 50);
|
|
||||||
padding: 30px;
|
|
||||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
|
||||||
width: 80%;
|
|
||||||
max-width: 400px;
|
|
||||||
}
|
|
||||||
.popAwal h1 {
|
|
||||||
margin-left: 30px;
|
|
||||||
margin-right: 25px;
|
|
||||||
}
|
|
||||||
#keluar {
|
|
||||||
background-color: #f44336;
|
|
||||||
}
|
|
||||||
#keluar:hover {
|
|
||||||
background-color: #d32f2f;
|
|
||||||
}
|
|
||||||
.icon {
|
.icon {
|
||||||
width: 70px;
|
width: 70px;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
@ -155,7 +109,7 @@
|
|||||||
padding: 15px 30px;
|
padding: 15px 30px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: rgb(255, 255, 255);
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin: 10px 5px;
|
margin: 10px 5px;
|
||||||
@ -165,10 +119,6 @@
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
transition: background-color 0.2s, color 0.25s;
|
transition: background-color 0.2s, color 0.25s;
|
||||||
font-family: "Pixelify Sans", sans-serif;
|
|
||||||
font-optical-sizing: auto;
|
|
||||||
font-weight: 400;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
}
|
||||||
#mode-normal {
|
#mode-normal {
|
||||||
background-color: #73e4c2;
|
background-color: #73e4c2;
|
||||||
|
|||||||
10
game.html
10
game.html
@ -1,13 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="GameStyle.css" />
|
<link rel="stylesheet" href="GameStyle.css">
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
||||||
<link
|
|
||||||
href="https://fonts.googleapis.com/css2?family=Coral+Pixels&family=Jacquarda+Bastarda+9&family=Pixelify+Sans:wght@400..700&display=swap"
|
|
||||||
rel="stylesheet"
|
|
||||||
/>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- header -->
|
<!-- header -->
|
||||||
@ -39,7 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<!-- <div class="text">Controls: <br />Movement: W A S D <br /><br /></div> -->
|
<div class="text">Controls: <br />Movement: W A S D <br /><br /></div>
|
||||||
<div id="text" class="text"></div>
|
<div id="text" class="text"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
47
home.html
47
home.html
@ -1,47 +0,0 @@
|
|||||||
<html>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background-image: url();
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 10%;
|
|
||||||
font-size: 85px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
padding: 5px;
|
|
||||||
border: 2px solid; /* Nanti dihapus */
|
|
||||||
border-radius: 7pt; /* Nanti dihapus */
|
|
||||||
width: 70%;
|
|
||||||
justify-self: center;
|
|
||||||
background-image: url();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#button {
|
|
||||||
font-size: 35px;
|
|
||||||
margin-top: 5%;
|
|
||||||
width: 50%;
|
|
||||||
margin-bottom: 5%;
|
|
||||||
border: 1px solid;
|
|
||||||
border-radius: 3pt;
|
|
||||||
padding: 2px;
|
|
||||||
justify-self: center;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1>EAT THAT APPLE</h1>
|
|
||||||
<div class="container">
|
|
||||||
<div id="button">Play Game</div>
|
|
||||||
<div id="button">Leaderboard</div>
|
|
||||||
<div id="button">Quit</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</html>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user