Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added coin tosser game #4910

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Games/Coin_Tosser/assets/images/coin_tosser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Coin_Tosser/assets/images/heads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Coin_Tosser/assets/images/tails.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions Games/Coin_Tosser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class=”container”>
<div class=”coin” id=”coin”>
<div class=”heads”>
<img src=”head.jpg”>
</div>
<div class=”tails”>
<img src=”tails.jpg”>
</div>
</div>
</div>

<style>
*{
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: β€œRubik”,sans-serif;
}
body{
height: 100%;
background: #1f5a82;
}
.container{
background-color: #ffffff;
width: 400px;
padding: 35px;
position: absolute;
transform: translate(-50%,-50%);
top: 50%;
left: 50%;
box-shadow: 15px 30px 35px rgba(0,0,0,0.1);
border-radius: 10px;
-webkit-perspective: 300px;
perspective: 300px;
}

.coin{
height: 150px;
width: 150px;
position: relative;
margin: 32px auto;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.coin img{
width: 145px;
}
.heads,.tails{
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.tails{
transform: rotateX(180deg);
}

</style>
</body>
</html>

<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Coin Toss Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Coin Toss Game</h1>
<button onclick="tossCoin()">Toss Coin</button>
<div class="coin" id="coin">
<div class="side heads"></div>
<div class="side tails"></div>
</div>
<div class="result" id="result"></div>
</div>

<script src="script.js"></script>
</body>
</html> -->
21 changes: 21 additions & 0 deletions Games/Coin_Tosser/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// function tossCoin() {
// const coin = document.getElementById('coin');
// const resultElement = document.getElementById('result');

// // Remove the flip class to restart the animation
// coin.classList.remove('flip');

// // Randomly select heads or tails
// const result = Math.random() < 0.5 ? 'Heads' : 'Tails';

// // Delay to allow the animation to reset
// setTimeout(() => {
// coin.classList.add('flip');
// resultElement.innerText = '';
// }, 100);

// // Set the result after the animation completes
// setTimeout(() => {
// resultElement.innerText = result;
// }, 1100);
// }
73 changes: 73 additions & 0 deletions Games/Coin_Tosser/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
.container {
text-align: center;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
button {
padding: 10px 20px;
font-size: 16px;
margin-top: 20px;
cursor: pointer;
border: none;
background-color: #007BFF;
color: white;
border-radius: 5px;
}
button:hover {
background-color: #0056b3;
}
.coin {
position: relative;
width: 100px;
height: 100px;
margin: 20px auto;
perspective: 1000px;
}
.side {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
background-size: cover;
background-position: center;
}
.heads {
background-image: url('images/heads.png');
}
.tails {
background-image: url('images/tails.png');
transform: rotateY(180deg);
}
.coin.flip .heads {
animation: flipHeads 1s forwards;
}
.coin.flip .tails {
animation: flipTails 1s forwards;
}
@keyframes flipHeads {
from { transform: rotateY(0); }
to { transform: rotateY(180deg); }
}
@keyframes flipTails {
from { transform: rotateY(180deg); }
to { transform: rotateY(360deg); }
}
.result {
margin-top: 20px;
font-size: 24px;
font-weight: bold;
} */
Loading