-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (103 loc) · 2.62 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<script src="main.js"></script>
<script src="DOMObject.js"></script>
<script src="player.js"></script>
<script src="ball.js"></script>
<script src="engine.js"></script>
<script></script>
<style>
body {
text-align: center;
}
.container {
display: inline-block;
margin: 0 auto;
}
.brick {
height: 20%;
width: 1%;
background-color: black;
position: absolute;
top: 50%;
/* transform: translateY(-50%); */
transition: top 0.3s ease; /* Adding smooth transition */
}
.gameCanvas {
width: 50vw;
height: 40vw;
border: 1px solid gray;
/* border-top: 20px solid black;
border-bottom: 20px solid black; */
position: relative;
}
.ball {
height: 20px;
width: 20px;
top: 20%;
left: 50%;
position: absolute;
background-color: black;
border-radius: 20px;
transition: 0.3s ease; /* Adding smooth transition */
}
.score-card {
width: 50vw;
display: flex;
justify-content: space-between;
}
.p1-score {
font-size: large;
width: auto;
}
.p2-score {
font-size: large;
width: auto;
}
#p1-points {
font-size: xx-large;
color: red;
}
#p2-points {
font-size: xx-large;
color: green;
}
</style>
<body>
<div class="container">
<div class="gameCanvas" id="gameCanvas">
<div id="player1" class="brick"></div>
<div id="ball" class="ball"></div>
<div style="left: 99%" id="player2" class="brick"></div>
</div>
<h1>Ping Pong vs AI</h1>
<div class="score-card">
<div class="p1-score">
<span id="p1-name">0</span>:
<b><span id="p1-points"> 0</span></b>
</div>
<div class="p2-score">
<span id="p2-name"></span>:
<b><span id="p2-points"> 0</span></b>
</div>
</div>
<div>
<span style="font-size: 22px; font-weight: bold">Level: </span>
<span
style="font-size: 24px; font-weight: bold; color: blue"
id="level-number"
></span>
</div>
<div>
Ball Speed: <b><span id="ball-speed"></span></b>
<button onclick="increaseSpeed()">Increase</button>
<button onclick="decreaseSpeed()">Decrease</button>
</div>
<div>
Player Speed: <b><span id="player-speed"></span></b>
<button onclick="increasePlayerSpeed()">Increase</button>
<button onclick="decreasePlayerSpeed()">Decrease</button>
</div>
</div>
</body>
</html>