-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
199 lines (172 loc) · 6.37 KB
/
game.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ColySeus</title>
<link href="node_modules/leaflet/dist/leaflet.css" rel="stylesheet">
<link href="node_modules/toastr/build/toastr.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-compass/dist/leaflet-compass.min.css" />
<link rel="stylesheet" href="node_modules/leaflet-plugin-trackplayback/dist/control.playback.css">
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
z-index: 0;
}
#chat.minimized {
height: 80px; /* Atur tinggi chat ketika diperkecil */
overflow: hidden;
}
#chat.expanded {
height: auto; /* Atur kembali tinggi chat ketika diperluas */
}
#chat {
position: absolute;
bottom: 10px;
right: 10px;
background-color: #fff;
border: 1px solid #ccc;
padding: 10px;
max-width: 300px;
z-index: 1;
}
#chat-messages {
height: 200px;
overflow-y: auto;
border: 1px solid #ccc;
padding: 5px;
}
#chat-input {
width: 100%;
padding: 5px;
margin-top: 5px;
}
button {
margin-top: 5px;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- Chat Modal -->
<div id="chat" class="expanded">
<button>minimize</button>
<div>Health: <b id="healthBar">100</b></div>
<div>Speed: <b id="speedBar">100</b></div>
<div>Points: <b id="pointsBar">0</b></div>
<div id="chat-messages"></div>
<input type="text" id="chat-input" placeholder="Ketik pesan anda disini..." />
<!-- <button onclick="Helper.sendMessage()">Send</button> -->
<!-- Analog Buttons -->
<div class="analog-buttons">
<button onclick="Helper.moveMap('up')">Up</button>
<br>
<button onclick="Helper.moveMap('left')">Left</button>
<button onclick="Helper.moveMap('right')">Right</button>
<br>
<button onclick="Helper.moveMap('down')">Down</button>
</div>
<audio controls" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<script src="node_modules/leaflet/dist/leaflet.js"></script>
<script src="https://cdn.jsdelivr.net/npm/leaflet-compass/dist/leaflet-compass.min.js"></script>
<script src="node_modules/leaflet-plugin-trackplayback/dist/control.trackplayback.js"></script>
<script src="node_modules/leaflet-plugin-trackplayback/dist/leaflet.trackplayback.js"></script>
<script src="node_modules/colyseus.js/dist/colyseus.js"></script>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/moment/min/moment.min.js"></script>
<script src="node_modules/toastr/toastr.js"></script>
<script src="node_modules/turf/turf.min.js"></script>
<script src="dist/Auth.js"></script>
<script src="dist/Bounds.js"></script>
<script src="dist/PlayerDetail.js"></script>
<script src="dist/Player.js"></script>
<script src="dist/ObjectMap.js"></script>
<script src="dist/BotEnemy.js"></script>
<script src="dist/MapLeaflet.js"></script>
<script src="dist/Helper.js"></script>
<script src="dist/multiplayers.js"></script>
<script>
const chatElement = document.getElementById("chat");
const minimizeButton = document.querySelector("#chat button");
minimizeButton.addEventListener("click", function () {
if (chatElement.classList.contains("expanded")) {
chatElement.classList.remove("expanded");
chatElement.classList.add("minimized");
minimizeButton.textContent = "Maximize";
} else {
chatElement.classList.remove("minimized");
chatElement.classList.add("expanded");
minimizeButton.textContent = "Minimize";
}
});
const inputElement = document.getElementById("chat-input");
inputElement.addEventListener("keypress", function (event) {
// Mengecek apakah tombol yang ditekan adalah "Enter" (kode 13)
if (event.keyCode === 13) {
// Mencegah pengiriman formulir (halaman tidak akan refresh)
event.preventDefault();
// Memanggil fungsi sendMessage() saat "Enter" ditekan
Helper.sendMessage();
}
});
document.addEventListener("keydown", function(event) {
var key = event.key.toLowerCase();
switch (key) {
case "w": // Tombol "w" untuk bergerak ke atas (up)
Helper.moveMap("up");
break;
case "s": // Tombol "s" untuk bergerak ke bawah (down)
Helper.moveMap("down");
break;
case "a": // Tombol "a" untuk bergerak ke kiri (left)
Helper.moveMap("left");
break;
case "d": // Tombol "d" untuk bergerak ke kanan (right)
Helper.moveMap("right");
break;
default:
break;
}
});
// Leaflet.center = [
// -7.78278,
// 110.36083
// ];
// // change location view
// Leaflet.map.setView(Leaflet.center, 17);
// // set marker
// delete this interval
// let startTrackPlayback = setInterval(function() {
// Leaflet.setPergerakanBot()
// // get element by class
// let element = document.getElementsByClassName('leaflet-control-playback leaflet-control');
// // style display none element
// element[0].style.display = 'none';
// console.log('startTrackPlayback')
// }, 5000);
// setTimeout(function() {
// clearInterval(startTrackPlayback);
// }, 10000);
// setInterval(function() {
// if (Leaflet.trackplayback != null) {
// console.log('check pl.ayback')
// if (Leaflet.trackplayback.isPlaying() == false) {
// Leaflet.trackplayback.rePlaying();
// console.log('replay')
// }
// } else {
// console.log('belum ada playback')
// }
// }, 1000);
</script>
</body>
</html>