-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.html
97 lines (96 loc) · 2.2 KB
/
Controller.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
<!DOCTYPE html>
<html>
<head>
<title>Snake Game Controller</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(to bottom, #1e3c72, #2a5298);
margin: 0;
}
.container {
text-align: center;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 15px;
padding: 40px;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
width: 320px;
}
h1 {
color: #333;
font-size: 28px;
margin-bottom: 20px;
}
button {
background-color: #3498db;
color: white;
border: none;
padding: 25px;
font-size: 24px;
margin: 10px;
border-radius: 50%;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 6px 15px rgba(52, 152, 219, 0.3);
}
button:hover {
background-color: #2980b9;
transform: translateY(-4px);
box-shadow: 0 8px 20px rgba(52, 152, 219, 0.5);
}
button:active {
transform: translateY(2px);
box-shadow: 0 3px 10px rgba(52, 152, 219, 0.4);
}
.controls {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
grid-template-rows: 1fr 1fr 1fr;
margin-top: 20px;
justify-items: center;
}
.controls button {
width: 80px;
height: 80px;
}
.up {
grid-column: 2;
grid-row: 1;
}
.down {
grid-column: 2;
grid-row: 3;
}
.left {
grid-column: 1;
grid-row: 2;
}
.right {
grid-column: 3;
grid-row: 2;
}
</style>
</head>
<body>
<div class="container">
<h1>Snake Game Controller</h1>
<div class="controls">
<button class="up" onclick="sendCommand('up')">↑</button>
<button class="left" onclick="sendCommand('left')">←</button>
<button class="right" onclick="sendCommand('right')">→</button>
<button class="down" onclick="sendCommand('down')">↓</button>
</div>
</div>
<script>
const ws = new WebSocket('ws://192.168.4.1:81');
function sendCommand(command) {
ws.send(command);
}
</script>
</body>
</html>