Skip to content

Commit 708fa06

Browse files
Merge pull request #811 from 2222k3060/patch-9
Create Bottle flip game.html
2 parents 2190c76 + 20fbbe8 commit 708fa06

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

Bottle flip game.html

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Bottle Flip Game</title>
7+
<style>
8+
body {
9+
font-family: 'Arial', sans-serif;
10+
display: flex;
11+
flex-direction: column;
12+
align-items: center;
13+
justify-content: center;
14+
height: 100vh;
15+
margin: 0;
16+
background-color: #f4f4f4;
17+
}
18+
19+
h1 {
20+
margin-bottom: 20px;
21+
color: #333;
22+
}
23+
24+
.bottle {
25+
width: 100px;
26+
height: 300px;
27+
background: url('https://static.vecteezy.com/system/resources/previews/012/628/136/non_2x/transparent-plastic-bottle-on-transparent-background-free-png.png') no-repeat center;
28+
background-size: cover;
29+
transform-origin: bottom;
30+
transition: transform 1s ease-in-out;
31+
}
32+
33+
.container {
34+
display: flex;
35+
flex-direction: column;
36+
align-items: center;
37+
}
38+
39+
button {
40+
padding: 10px 15px;
41+
font-size: 18px;
42+
margin-top: 20px;
43+
background-color: #28a745;
44+
color: white;
45+
border: none;
46+
border-radius: 5px;
47+
cursor: pointer;
48+
outline: none;
49+
}
50+
51+
button:hover {
52+
background-color: #218838;
53+
}
54+
55+
.result {
56+
font-size: 24px;
57+
font-weight: bold;
58+
margin-top: 20px;
59+
}
60+
</style>
61+
</head>
62+
<body>
63+
64+
<div class="container">
65+
<h1>Bottle Flip Game</h1>
66+
<div class="bottle" id="bottle"></div>
67+
<button onclick="flipBottle()">Flip the Bottle</button>
68+
<div class="result" id="result"></div>
69+
</div>
70+
71+
<script>
72+
function flipBottle() {
73+
var bottle = document.getElementById('bottle');
74+
var result = document.getElementById('result');
75+
76+
// Reset the result text
77+
result.textContent = '';
78+
79+
// Randomly determine the rotation angle (between 360 and 1080 degrees)
80+
var rotation = Math.floor(Math.random() * 720) + 360;
81+
82+
// Apply the rotation to the bottle
83+
bottle.style.transform = 'rotate(' + rotation + 'deg)';
84+
85+
// Determine if the flip was successful (approximate upright position)
86+
setTimeout(function() {
87+
if (rotation % 360 >= 330 || rotation % 360 <= 30) {
88+
result.textContent = 'Success! 🏆';
89+
result.style.color = 'green';
90+
} else {
91+
result.textContent = 'Fail! 😢';
92+
result.style.color = 'red';
93+
}
94+
}, 1000);
95+
}
96+
</script>
97+
98+
</body>
99+
</html>

0 commit comments

Comments
 (0)