-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame1.html
73 lines (66 loc) · 2.54 KB
/
game1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<link rel="icon" type="image/x-icon" href="Aku.jpg">
<!--Masukkan css java-script python dan bahasa pemrograman lainnya di sini-->
<link rel="stylesheet" href="style.css">
<style>
body {
background-image: url('download.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>
</head>
<body>
<div class="game-container">
<h1>Tebak Nama Batu</h1>
<p>Kami telah memilih sebuah nama batu.
Nama Batu-Batu Tadi adalah
<p>
Kuarsa, Obsidian, Koral, Basal, Batu pasir, Batu Kapur & Batu Dendrit
</p>
Selamat menebak tebak!</p>
<input type="text" id="guess" placeholder="Masukkan nama batu">
<button onclick="checkGuess()">Tebak</button>
<p id="message"></p>
<p>Skor: <span id="score">0</span></p>
<p>Waktu: <span id="time">100</span> detik</p>
</div>
<script>
alert("Selamat datang di Game Tebak Nama Batu Level Hard!");
alert("Anda memiliki waktu 100 detik untuk menebak nama batu.");
alert("Selamat bermain!");
var batu = ['Kuarsa', 'Obsidian', 'Koral', 'Basal', 'Batu pasir', 'Batu Kapur', 'Batu Dendrit'];
var batuTerpilih = batu[Math.floor(Math.random() * batu.length)];
var score = 0;
var time = 100;
function checkGuess() {
var guess = document.getElementById('guess').value;
var message = '';
if (guess.toLowerCase() === batuTerpilih) {
message = 'Selamat! Anda berhasil menebak nama batu.';
score++;
document.getElementById('score').innerText = score;
batuTerpilih = batu[Math.floor(Math.random() * batu.length)];
} else {
message = 'Maaf, tebakan Anda salah. Coba lagi.';
}
document.getElementById('message').innerText = message;
}
setInterval(function() {
time--;
document.getElementById('time').innerText = time;
if (time <= 0) {
alert('Waktu habis! Skor akhir Anda adalah ' + score);
score = 0;
time = 100;
document.getElementById('score').innerText = score;
document.getElementById('time').innerText = time;
batuTerpilih = batu[Math.floor(Math.random() * batu.length)];
}
}, 1000);
</script>
</body>
</html>